/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --border: #e3e2de;
  --text: #1b1b1a;
  --text-2: #57564f;
  --muted: #8a8980;
  --danger: #d13b3b;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);

  /* list colors — categorical, fixed order */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c8: #e34948;
  --c9: #0891b2; --c10: #8b5e34; --c11: #5b6b86; --c12: #7cb518; --c0: #a3a29b;

  --accent: #4f46e5;
  --accent-soft: #eceafd;
  --accent-ink: #ffffff;

  --pad: 16px;
  --gap: 14px;
  --row: 40px;
  --radius: 12px;
  --hour: 52px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
:root[data-density="compact"] { --pad: 11px; --gap: 9px; --row: 32px; --hour: 42px; }

:root[data-accent="indigo"] { --accent: #4f46e5; --accent-soft: #eceafd; }
:root[data-accent="teal"]   { --accent: #0d8f86; --accent-soft: #dff4f2; }
:root[data-accent="rose"]   { --accent: #d6285a; --accent-soft: #fce7ed; }
:root[data-accent="amber"]  { --accent: #c26a00; --accent-soft: #fdf0dc; }
:root[data-accent="green"]  { --accent: #178a3e; --accent-soft: #e2f4e7; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1b1b1a; --surface-2: #242423; --border: #33332f;
    --text: #f4f4f1; --text-2: #c3c2b7; --muted: #8e8d84; --danger: #ef6b6b;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
    --c9: #22b3d0; --c10: #b98552; --c11: #8a9ab8; --c12: #8fcc2a; --c0: #6e6d66;
  }
  :root:not([data-theme="light"])[data-accent="indigo"] { --accent: #8b85f5; --accent-soft: #2a2850; --accent-ink: #111; }
  :root:not([data-theme="light"])[data-accent="teal"]   { --accent: #3cc2b6; --accent-soft: #173633; --accent-ink: #111; }
  :root:not([data-theme="light"])[data-accent="rose"]   { --accent: #f2698f; --accent-soft: #42202a; --accent-ink: #111; }
  :root:not([data-theme="light"])[data-accent="amber"]  { --accent: #f0a53a; --accent-soft: #3d2d14; --accent-ink: #111; }
  :root:not([data-theme="light"])[data-accent="green"]  { --accent: #4cc774; --accent-soft: #19361f; --accent-ink: #111; }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1b1b1a; --surface-2: #242423; --border: #33332f;
  --text: #f4f4f1; --text-2: #c3c2b7; --muted: #8e8d84; --danger: #ef6b6b;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  --c9: #22b3d0; --c10: #b98552; --c11: #8a9ab8; --c12: #8fcc2a; --c0: #6e6d66;
}
:root[data-theme="dark"][data-accent="indigo"] { --accent: #8b85f5; --accent-soft: #2a2850; --accent-ink: #111; }
:root[data-theme="dark"][data-accent="teal"]   { --accent: #3cc2b6; --accent-soft: #173633; --accent-ink: #111; }
:root[data-theme="dark"][data-accent="rose"]   { --accent: #f2698f; --accent-soft: #42202a; --accent-ink: #111; }
:root[data-theme="dark"][data-accent="amber"]  { --accent: #f0a53a; --accent-soft: #3d2d14; --accent-ink: #111; }
:root[data-theme="dark"][data-accent="green"]  { --accent: #4cc774; --accent-soft: #19361f; --accent-ink: #111; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 0 10px; height: var(--row);
  border-radius: 9px; color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg, .btn svg { width: 17px; height: 17px; flex: none; }
.sidebar .lock-btn { justify-content: flex-start; }

.main { min-width: 0; padding: 28px 32px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

.topbar { display: none; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.icon { width: 30px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .45; cursor: default; }

.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); outline: none;
}
textarea.input { height: auto; padding: 10px 11px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field, div.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields .full { grid-column: 1 / -1; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.prio-high { color: var(--danger); }
.chip.overdue { color: var(--danger); }

.check {
  appearance: none; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--muted);
  cursor: pointer; flex: none; margin: 0; display: grid; place-items: center; background: var(--surface);
}
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: ""; width: 5px; height: 9px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.check.round { border-radius: 50%; }

.empty { color: var(--muted); padding: 14px 4px; text-align: center; }

/* ---------- Task rows ---------- */
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task .check { margin-top: 1px; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 500; cursor: pointer; overflow-wrap: anywhere; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.subtasks { margin: 7px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.subtasks li { display: flex; gap: 8px; align-items: center; color: var(--text-2); }
.subtasks li.done span { text-decoration: line-through; color: var(--muted); }
.subtasks .check { width: 15px; height: 15px; border-radius: 5px; }
.subtasks .check:checked::after { width: 4px; height: 7px; }
.task-actions { display: flex; gap: 2px; opacity: .55; }
.task:hover .task-actions { opacity: 1; }

/* ---------- Today ---------- */
.today-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.today-grid .span-2 { grid-column: 1 / -1; }
.today-col { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.today-grid .card .empty { padding: 8px 4px; }
.focus-card { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.focus-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.focus-input { width: 100%; border: 0; background: transparent; outline: none; font-size: 21px; font-weight: 600; padding: 6px 0 2px; }
.focus-input::placeholder { color: var(--muted); font-weight: 500; }
.sched { display: flex; flex-direction: column; gap: 6px; }
.sched-item { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border-left: 4px solid var(--c1); cursor: pointer; }
.sched-item.now { outline: 2px solid var(--accent); }
.sched-item .time { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }
.sched-item.done .title { text-decoration: line-through; color: var(--muted); }
.habit-pill { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.habit-pill:last-child { border-bottom: 0; }
.goal { margin-bottom: 12px; }
.goal:last-child { margin-bottom: 0; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }

/* ---------- Calendar ---------- */
.cal-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.tray { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.tray-item { padding: 9px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 7px; cursor: grab; border-left: 4px solid var(--c1); }
.tray-item:active { cursor: grabbing; }
.tray-item .row { margin-top: 6px; }
.cal { padding: 0; overflow: hidden; }
.cal-scroll { max-height: calc(100vh - 190px); overflow: auto; position: relative; }
.cal-head { display: grid; position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); }
.cal-head div { padding: 9px 6px; text-align: center; font-size: 12px; color: var(--text-2); }
.cal-head div b { display: block; font-size: 17px; color: var(--text); }
.cal-head div.is-today b { color: var(--accent); }
.cal-body { display: grid; position: relative; }
.hours { position: relative; }
.hours div { height: var(--hour); font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.day-col { position: relative; border-left: 1px solid var(--border); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), var(--border) calc(var(--hour) - 1px), var(--border) var(--hour)); }
.day-col.drop-over { background-color: var(--accent-soft); }
.day-col.is-today { background-color: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.block {
  position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 4px 7px; font-size: 12px; overflow: hidden;
  background: color-mix(in srgb, var(--bc, var(--c1)) 18%, var(--surface)); border-left: 3px solid var(--bc, var(--c1));
  cursor: pointer; z-index: 1; box-shadow: 0 0 0 1.5px var(--surface);
}
.block:hover { z-index: 2; box-shadow: 0 0 0 1.5px var(--surface), var(--shadow); }
.block b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block span { color: var(--text-2); }
.block.done b { text-decoration: line-through; color: var(--muted); }
.drop-ghost { position: absolute; left: 3px; right: 3px; border-radius: 7px; border: 2px dashed var(--accent); pointer-events: none; z-index: 2; font-size: 11px; color: var(--accent); padding: 2px 6px; font-weight: 600; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month .dow { padding: 8px; font-size: 12px; color: var(--muted); text-align: center; border-bottom: 1px solid var(--border); }
.mcell { min-height: 104px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; cursor: pointer; min-width: 0; }
.mcell:nth-child(7n) { border-right: 0; }
.mcell.other { background: var(--surface-2); }
.mcell.other .mnum { color: var(--muted); }
.mcell.drop-over { background: var(--accent-soft); }
.mnum { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.mcell.is-today .mnum { background: var(--accent); color: var(--accent-ink); border-radius: 99px; display: inline-grid; place-items: center; width: 22px; height: 22px; }
.mchip { font-size: 11px; padding: 2px 6px; border-radius: 5px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--bc, var(--c1)) 16%, var(--surface)); border-left: 3px solid var(--bc, var(--c1)); }

/* ---------- Tasks ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 130px; }
.filters input[type="search"] { flex: 1; min-width: 180px; }

/* ---------- Notes ---------- */
.notes-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.note-list { padding: 8px; max-height: calc(100vh - 170px); overflow: auto; }
.note-item { padding: 10px; border-radius: 9px; cursor: pointer; }
.note-item:hover { background: var(--surface-2); }
.note-item.active { background: var(--accent-soft); }
.note-item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item .p { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.note-title { border: 0; outline: none; background: transparent; font-size: 22px; font-weight: 650; width: 100%; padding: 4px 0; }
.note-body { border: 0; outline: none; background: transparent; width: 100%; min-height: 52vh; resize: vertical; font-size: 15px; line-height: 1.6; padding: 6px 0; }
mark { background: color-mix(in srgb, var(--c4) 40%, transparent); color: inherit; border-radius: 3px; }

/* ---------- Habits ---------- */
.htable { width: 100%; border-collapse: collapse; }
.htable th { font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 4px; text-align: center; }
.htable th:first-child, .htable td:first-child { text-align: left; }
.htable td { padding: 7px 4px; border-top: 1px solid var(--border); text-align: center; }
.htable th.is-today { color: var(--accent); font-weight: 700; }
.tick { width: 30px; height: 30px; border-radius: 9px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; }
.tick.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tick svg { width: 15px; height: 15px; }
.streak { font-variant-numeric: tabular-nums; font-weight: 600; }
.table-scroll { overflow-x: auto; }

/* ---------- Stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.kpi .v { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .axis { fill: var(--muted); font-size: 10px; }
.chart-svg .gridline { stroke: var(--border); stroke-width: 1; }
.chart-svg .val { fill: var(--text-2); font-size: 10px; font-weight: 600; }
.chart-svg .hit { fill: transparent; cursor: default; }
.chart-svg .hit:hover + .barmark, .chart-svg g:hover .barmark { filter: brightness(1.12); }
.hbar { display: grid; grid-template-columns: 110px 1fr 56px; gap: 10px; align-items: center; margin-bottom: 10px; }
.hbar .track { height: 12px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.heat { display: grid; gap: 3px; }
.heat-row { display: grid; grid-template-columns: 120px repeat(30, minmax(0, 1fr)) 48px; gap: 3px; align-items: center; }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); min-width: 0; }
.heat-cell.on { background: var(--accent); }
.heat-row .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heat-row .pct { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-2); }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 7px; white-space: nowrap; box-shadow: var(--shadow); }

/* ---------- Settings ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.set-row:last-child { border-bottom: 0; }
.set-row .l b { display: block; font-weight: 600; }
.set-row .l span { color: var(--muted); font-size: 13px; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent; }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.order-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.order-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.order-list li.dragging { opacity: .5; }
.order-list li.off .name { color: var(--muted); text-decoration: line-through; }
.grip { cursor: grab; color: var(--muted); }

/* ---------- Modal & toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 16px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-foot { display: flex; gap: 8px; margin-top: 18px; }
.sub-edit { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; }

/* ---------- Lock screen ---------- */
.app.blurred { filter: blur(14px) saturate(.9); pointer-events: none; user-select: none; }
.lock {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 45%, transparent);
}
.lock-card { text-align: center; width: min(320px, 100%); }
.lock-card .brand-mark { width: 52px; height: 52px; border-radius: 16px; font-size: 24px; margin: 0 auto 14px; }
.lock-card h1 { font-size: 22px; }
.lock-time { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 26px 0 8px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-2); }
.pin-dots span.on { background: var(--text); border-color: var(--text); }
.pin-dots.shake { animation: shake .4s; }
.pin-dots.shake span { border-color: var(--danger); }
.lock-err { color: var(--danger); font-weight: 600; min-height: 20px; font-size: 13px; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px; justify-content: center; margin-top: 12px; }
.key { width: 72px; height: 72px; border-radius: 50%; border: 0; background: color-mix(in srgb, var(--surface) 80%, transparent); font-size: 24px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow); }
.key:active { background: var(--accent-soft); }
.key.txt { font-size: 13px; background: transparent; box-shadow: none; color: var(--text-2); }
.lock-hint { margin-top: 18px; font-size: 12px; color: var(--muted); }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-9px); } 40%,80% { transform: translateX(9px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .cal-layout, .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .tray { position: static; max-height: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; padding-top: calc(18px + env(safe-area-inset-top, 0px)); width: 240px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; }
  .main { padding: 18px 16px 60px; }
  .today-grid, .grid-2, .fields { grid-template-columns: minmax(0, 1fr); }
  .heat-row { grid-template-columns: 80px repeat(30, minmax(0, 1fr)) 38px; gap: 2px; }
  .hbar { grid-template-columns: 80px 1fr 48px; }
  .sched-item { grid-template-columns: 80px 1fr; }
}

/* ---------- Small additions ---------- */
.chip svg { width: 12px; height: 12px; }
.chart-svg .barmark { fill: var(--accent); }
.tray.drop-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
details summary { cursor: pointer; font-weight: 500; }
.tray-item .row { flex-wrap: wrap; }
.block span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1000px) { .cal-layout > .tray { order: 2; } }

/* ---------- Focus timer, sync status, confirm ---------- */
.timer-display { font-size: 52px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; text-align: center; margin: 14px 0 8px; line-height: 1; }
.timer-display.running { color: var(--accent); }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.sync-status { font-size: 12px; color: var(--muted); padding: 6px 10px; display: flex; align-items: center; gap: 7px; }
.sync-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-status[data-status="synced"]::before { background: var(--c3); }
.sync-status[data-status="saving"]::before, .sync-status[data-status="connecting"]::before { background: var(--c4); }
.sync-status[data-status="error"]::before, .sync-status[data-status="readonly"]::before, .sync-status[data-status="full"]::before { background: var(--danger); }
.sync-key { word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface-2); padding: 5px 9px; border-radius: 7px; user-select: all; }
#cloud-status[data-status="error"] { color: var(--danger); }

/* ---------- Scheduling helpers ---------- */
.quick-add { margin-top: 10px; }
.qa-preview { display: flex; flex-wrap: wrap; gap: 5px; min-height: 22px; margin-top: 6px; }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-undo { border: 0; background: transparent; color: var(--accent-soft); font-weight: 700; cursor: pointer; padding: 2px 4px; text-decoration: underline; }
.picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.pick:hover, .pick:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.pick span { font-size: 12px; color: var(--text-2); }
.place-banner { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.cal-layout.placing .day-col { cursor: crosshair; }
.cal-layout.placing .day-col:hover { background-color: var(--accent-soft); }
.block.busy {
  cursor: pointer; border-left-color: var(--muted); color: var(--text-2);
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, color-mix(in srgb, var(--surface-2) 55%, var(--surface)) 6px 12px);
}
.block .resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; touch-action: none; }
.block .resize::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 22px; height: 3px; margin-left: -11px; border-radius: 2px; background: var(--bc, var(--c1)); opacity: 0; transition: opacity .15s; }
.block:hover .resize::after, .block.resizing .resize::after { opacity: .8; }
@media (hover: none) { .block .resize { height: 14px; } .block .resize::after { opacity: .6; } }
.block.resizing { z-index: 3; box-shadow: 0 0 0 2px var(--accent); }
.sched-item.busy { border-left-color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, color-mix(in srgb, var(--surface-2) 55%, var(--surface)) 6px 12px); color: var(--text-2); }
.catchup { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.catchup .task { align-items: center; }
.busy-row { padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; flex-wrap: wrap; }
.day-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.day-pick input { position: absolute; opacity: 0; pointer-events: none; }
.day-pick span { display: inline-grid; place-items: center; min-width: 46px; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; font-weight: 500; color: var(--text); }
.day-pick input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.day-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 800px) { .picks { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Color categories ---------- */
.task { border-left: 3px solid var(--lc, transparent); padding-left: 10px; }
.catchup .task { border-left: 0; padding-left: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: -8px 0 14px; }
.list-edit { padding: 8px 10px; border: 1px solid var(--border); border-left: 4px solid var(--lc); border-radius: 10px; }
.list-edit .row .input { min-width: 0; }
.kw-input { margin-top: 6px; height: 32px; font-size: 13px; color: var(--text-2); }
.swatch-btn { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 0; background: var(--lc); cursor: pointer; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }
.swatch-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.color-pick { display: grid; grid-template-columns: 22px 1fr; column-gap: 8px; align-items: center; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.color-pick span { grid-row: span 2; width: 22px; height: 22px; border-radius: 50%; background: var(--pc); }
.color-pick small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.color-pick.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.color-pick:hover { background: var(--surface-2); }

/* ---------- Plan my day, split, time tracking ---------- */
.plan-row { display: grid; grid-template-columns: auto 132px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border-left: 4px solid var(--lc, var(--c0)); }
.plan-row .time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-2); }
.plan-row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-row.off { opacity: .6; border-left-color: var(--border); }
div.plan-row { grid-template-columns: 80px minmax(0, 1fr) auto; }
.hint { font-weight: 400; font-size: 12px; color: var(--text-2); }
.est-track { position: relative; overflow: visible; }
.est-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); border-radius: 1px; }
@media (max-width: 800px) { .plan-row { grid-template-columns: auto minmax(0, 1fr) auto; } .plan-row .time { grid-column: 2; grid-row: 2; } div.plan-row { grid-template-columns: minmax(0, 1fr) auto; } }

/* ---------- Color-coded list picker ---------- */
.lp { position: relative; }
.lp-btn { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; font-weight: 500; font-size: 14px; color: var(--text); }
.lp-btn .lp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-btn svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.lp .dot, .lp-grid .dot { width: 12px; height: 12px; }
.lp-menu { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: min(320px, 90vw); max-height: 320px; overflow: auto; padding: 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.lp-group { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 8px 4px; }
.lp-opt { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; font-weight: 500; color: var(--text); }
.lp-opt:hover, .lp-opt:focus-visible { background: var(--surface-2); outline: none; }
.lp-opt[aria-selected="true"] { background: var(--accent-soft); }
.lp-check { margin-left: auto; color: var(--accent); display: inline-flex; }
.lp-check svg { width: 15px; height: 15px; }
.lp-edit { margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; color: var(--text-2); font-weight: 400; }
.lp-edit svg { width: 14px; height: 14px; }
.lp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 6px; }
.lp-grid .lp-group { grid-column: 1 / -1; }
.lp-grid .lp-edit { grid-column: 1 / -1; }
.chip-btn { border: 0; cursor: pointer; font: inherit; font-size: 12px; }
.chip-btn:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--text) 8%); color: var(--text); }
.chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Habits ---------- */
.habit-group { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; }
.habit-group:first-of-type { margin-top: 0; }
.habit-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%;
  min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); border-left: 4px solid var(--lc);
  background: var(--surface); cursor: pointer; text-align: left; color: var(--text);
}
.habit-row:hover { background: var(--surface-2); }
.habit-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.habit-check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--lc); display: grid; place-items: center; color: #fff; }
.habit-check svg { width: 15px; height: 15px; }
.habit-row.done { background: color-mix(in srgb, var(--lc) 10%, var(--surface)); }
.habit-row.done .habit-check { background: var(--lc); }
.habit-row.done .habit-name { color: var(--text-2); }
.habit-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-meta { font-size: 12px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.template { display: grid; grid-template-columns: 12px minmax(0, 1fr) 16px; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); border-left: 4px solid var(--lc); background: var(--surface); cursor: pointer; text-align: left; color: var(--text); }
.template:hover, .template:focus-visible { background: var(--surface-2); outline: none; border-color: var(--lc); }
.template b { display: block; font-weight: 600; }
.template small { display: block; color: var(--text-2); font-size: 12px; }
.template svg { width: 16px; height: 16px; color: var(--muted); }
.htable .tick.on { background: var(--lc, var(--accent)); border-color: var(--lc, var(--accent)); }
.tick.rest:not(.on) { border-style: dashed; background: transparent; opacity: .55; }
.heat-cell.rest { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.seg label { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 500; font-size: 14px; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }
@media (max-width: 800px) { .habit-row { grid-template-columns: 28px minmax(0, 1fr); } .habit-meta { grid-column: 2; } }

/* ---------- Events vs tasks on the calendar ---------- */
.block.event { background: color-mix(in srgb, var(--bc) 30%, var(--surface)); border-left-width: 0; box-shadow: inset 3px 0 0 var(--bc), 0 0 0 1.5px var(--surface); }
.block.event b { font-weight: 700; }
.block.task-block b { display: flex; align-items: center; gap: 5px; }
.block .blk-check {
  display: inline-grid; place-items: center; flex: none; width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid var(--bc); background: var(--surface); color: #fff; cursor: pointer;
}
.block .blk-check svg { width: 9px; height: 9px; }
.block.done .blk-check { background: var(--bc); }
.block .blk-check:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bc) 25%, transparent); }
.mchip.event { background: color-mix(in srgb, var(--bc) 30%, var(--surface)); font-weight: 600; }
.mchip.done { text-decoration: line-through; color: var(--muted); }
.sched-item.event { background: color-mix(in srgb, var(--bc) 22%, var(--surface)); font-weight: 600; }
.sched-item .check { width: 16px; height: 16px; }

/* ---------- Tests, countdowns, classes ---------- */
.countdown { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); border-left: 4px solid var(--lc); margin-bottom: 8px; }
.countdown:last-child { margin-bottom: 0; }
.cd-num { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 56px; padding: 6px 4px; border-radius: 10px; background: color-mix(in srgb, var(--lc) 14%, var(--surface)); line-height: 1; }
.cd-num b { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.cd-num span { font-size: 11px; color: var(--text-2); margin-top: 3px; }
.cd-num.sm { min-width: 46px; padding: 5px 3px; }
.cd-num.sm b { font-size: 18px; }
.cd-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cd-body .bar { margin-top: 4px; }
.cd-clock { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--gap); align-items: start; }
.class-card { border-top: 4px solid var(--lc); }
.class-sec { padding: 10px 0; border-top: 1px solid var(--border); }
.class-sec:first-of-type { border-top: 0; padding-top: 0; }
.class-label { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.class-test { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.class-test .cd-num { --lc: inherit; }
.topics { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.class-task, .class-grade { display: flex; align-items: center; gap: 8px; padding: 4px 0; min-width: 0; }
.class-task .task-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-grade b { font-variant-numeric: tabular-nums; }
.grade-pill { font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 99px; background: color-mix(in srgb, var(--lc) 16%, var(--surface)); color: var(--text); white-space: nowrap; }
@media (max-width: 800px) { .class-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Width handles on shared calendar blocks ---------- */
.block .wresize { position: absolute; top: 0; bottom: 8px; width: 10px; cursor: ew-resize; touch-action: none; z-index: 2; }
.block .wresize.on-right { right: -3px; }
.block .wresize.on-left { left: -3px; }
.block .wresize::after { content: ""; position: absolute; top: 50%; left: 4px; width: 3px; height: 22px; margin-top: -11px; border-radius: 2px; background: var(--bc, var(--muted)); opacity: 0; transition: opacity .15s; }
.block:hover .wresize::after, .block.resizing .wresize::after { opacity: .85; }
@media (hover: none) { .block .wresize { width: 16px; } .block .wresize::after { opacity: .6; } }
