/* Themes: the unthemed :root is "Deep Blue"; the others override it via
   <html data-theme="...">, set by /static/theme.js from localStorage. */
:root {
  color-scheme: dark;
  --bg: #0b1626; --card: #112238; --fg: #e6eefb; --muted: #9db2cf; --line: #213a5a;
  --accent: #6cb4ff; --accent-fg: #07121f; --danger: #ff9aa2; --danger-bg: #3a1a26; --chip: #1b3350;
  --cup: #1d3554; --cup-line: #9cc7f5; --coffee: #3f86d6; --saucer: #274a73;
}
:root[data-theme="dracula-pro"] {
  --bg: #22212c; --card: #2b2a3a; --fg: #f8f8f2; --muted: #b3aed6; --line: #454158;
  --accent: #9580ff; --accent-fg: #17161f; --danger: #ff9580; --danger-bg: #3d2a33; --chip: #3a3750;
  --cup: #3a3750; --cup-line: #80ffea; --coffee: #9580ff; --saucer: #454158;
}
:root[data-theme="nord"] {
  --bg: #2e3440; --card: #3b4252; --fg: #eceff4; --muted: #b6c0d2; --line: #4c566a;
  --accent: #88c0d0; --accent-fg: #1f252f; --danger: #e8a0a8; --danger-bg: #4a3a44; --chip: #434c5e;
  --cup: #434c5e; --cup-line: #d8dee9; --coffee: #5e81ac; --saucer: #4c566a;
}
:root[data-theme="abyss"] {
  --bg: #000c18; --card: #051d33; --fg: #d6e6ff; --muted: #8aa4c8; --line: #0f3252;
  --accent: #3fd0ff; --accent-fg: #00121f; --danger: #ff8d95; --danger-bg: #330f1c; --chip: #0b2945;
  --cup: #0b2945; --cup-line: #7fd8ff; --coffee: #1f8fd0; --saucer: #123a60;
}
:root[data-theme="glacier"] {
  color-scheme: light;
  --bg: #eef4fb; --card: #ffffff; --fg: #0f2440; --muted: #4a6283; --line: #cdd9e8;
  --accent: #0b4fa8; --accent-fg: #ffffff; --danger: #a1160f; --danger-bg: #fdecea; --chip: #e1ebf7;
  --cup: #e6f0fb; --cup-line: #1c3f6e; --coffee: #2b66b3; --saucer: #c5d6ea;
}
/* The original brown palette, following the OS light/dark setting. */
:root[data-theme="coffee"] {
  color-scheme: light;
  --bg: #faf5ee; --card: #ffffff; --fg: #2a1c12; --muted: #5f4e41; --line: #e2d4c2;
  --accent: #8a4f12; --accent-fg: #ffffff; --danger: #a1160f; --danger-bg: #fdecea; --chip: #f1e6d7;
  --cup: #f4e9dc; --cup-line: #5b3a29; --coffee: #6f4a33; --saucer: #e2d2c0;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="coffee"] {
    color-scheme: dark;
    --bg: #17100b; --card: #231913; --fg: #f6ecdf; --muted: #cdbba3; --line: #3f3025;
    --accent: #e0a96d; --accent-fg: #17100b; --danger: #ff9f95; --danger-bg: #3a1a17; --chip: #33261d;
    --cup: #3a2a20; --cup-line: #d9b99a; --coffee: #8a5a3c; --saucer: #4a372a;
  }
}
* { box-sizing: border-box; }
html { font-size: 112.5%; } /* 18px base for comfortable reading */
body { margin: 0; background: var(--bg); color: var(--fg); font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.logo { width: 96px; height: 96px; }

.btn { font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; border: 2px solid transparent;
  min-height: 44px; padding: .45rem 1rem; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-secondary { background: transparent; color: var(--fg); border-color: var(--muted); }
.btn-link { background: none; color: var(--fg); text-decoration: underline; min-height: 44px; }
a.btn { display: inline-flex; align-items: center; }
input[type=password] { width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; color: var(--fg);
  background: var(--card); border: 2px solid var(--muted); border-radius: 10px; }
label { font-weight: 600; }
.error, .err { color: var(--danger); font-weight: 600; margin: .5rem 0 0; }

body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card h1 { margin: .25rem 0 1.25rem; font-size: 1.6rem; font-weight: 700; }
.login-card form { text-align: left; display: grid; gap: .5rem; }
.login-card .btn { margin-top: .75rem; background: var(--accent); color: var(--accent-fg); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .5rem 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; }
.brand .logo { width: 40px; height: 40px; }

/* One column on phones (panels in configured order via .pN); two independent
   stacks on wide screens so a short panel never waits on a tall neighbour. */
.panels { display: flex; flex-direction: column; gap: 20px; padding: 20px 16px 40px; max-width: 1200px; margin: 0 auto; }
.col { display: contents; }
@media (min-width: 920px) {
  .panels { flex-direction: row; align-items: flex-start; }
  .col { display: flex; flex-direction: column; gap: 20px; flex: 1; min-width: 0; }
}
.panel { order: 99; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.25rem; }
.p0{order:0} .p1{order:1} .p2{order:2} .p3{order:3} .p4{order:4} .p5{order:5} .p6{order:6} .p7{order:7} .p8{order:8} .p9{order:9} .p10{order:10} .p11{order:11}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding-bottom: .6rem; border-bottom: 2px solid var(--line); margin-bottom: .25rem; }
.panel-head { cursor: pointer; list-style: none; min-height: 44px; }
.panel-head::-webkit-details-marker { display: none; }
.panel-head::before { content: "\25BE"; color: var(--muted); flex-shrink: 0; transition: transform .15s; }
.panel:not([open]) > .panel-head::before { transform: rotate(-90deg); }
.panel:not([open]) > .panel-head { border-bottom-color: transparent; padding-bottom: 0; margin-bottom: 0; }
.panel-head h2 { margin: 0; margin-right: auto; font-size: 1.35rem; }
.count { font-weight: 700; color: var(--accent); }
.count-clear { color: var(--muted); font-weight: 600; }
.empty { color: var(--muted); margin: 1rem 0 .25rem; }

.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start;
  padding: .9rem 0 .9rem .75rem; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; }
.item:last-child { border-bottom: 0; }
.item.alert, .item.due-soon { border-left-color: var(--danger); background: var(--danger-bg); border-radius: 0 8px 8px 0; }
.item-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item-title { font-size: 1.1rem; font-weight: 650; line-height: 1.35; }
.item-detail { margin: .25rem 0 0; white-space: pre-wrap; }
.item-title a, .item-links a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.item-links { list-style: none; margin: .3rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
.item-links a::after { content: " \2197"; }
.item-meta { margin-top: .4rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem;
  font-size: .9rem; color: var(--muted); }
.chip { background: var(--chip); border-radius: 999px; padding: 0 .6rem; color: var(--fg); }
.badge { display: inline-block; background: var(--danger); color: var(--card); font-size: .75rem; font-weight: 800;
  letter-spacing: .03em; text-transform: uppercase; border-radius: 6px; padding: .05rem .45rem; vertical-align: .1em; }
.item-actions { display: flex; flex-direction: column; gap: .4rem; flex-shrink: 0; }
.is-done .item-title { color: var(--muted); text-decoration: line-through; }

.done { margin-top: .75rem; border-top: 2px solid var(--line); padding-top: .5rem; }
.done summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: .5rem 0; min-height: 44px; }

@media (max-width: 520px) {
  .item { flex-direction: column; }
  .item-actions { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .item-actions .btn { width: 100%; }
  .item-actions form { flex: 1 1 8rem; }
}

.topbar-end { display: flex; align-items: center; gap: .75rem; }
.theme-picker { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--muted); }
.theme-picker label { font-weight: 600; }
.theme-picker select { font: inherit; min-height: 44px; padding: .3rem .6rem; color: var(--fg); background: var(--card);
  border: 2px solid var(--muted); border-radius: 10px; }
body.login .theme-picker { justify-content: center; margin-top: 1.25rem; }
