/* Ledger — To-Do with notes. Light and dark via data-theme on <html>. */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1b1b1f;
  --text-2: #5a5b63;
  --muted: #8a8b93;
  --line: #e2e0d9;
  --accent: #1f6f5f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 111, 95, 0.12);
  --danger: #b4232c;
  --high: #c2410c;
  --medium: #a16207;
  --low: #2563eb;
  --overdue: #b4232c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #111214;
  --surface: #191a1e;
  --surface-2: #202227;
  --text: #ecebe6;
  --text-2: #b4b3ad;
  --muted: #7f7f86;
  --line: #2b2d33;
  --accent: #4fb39b;
  --accent-ink: #0d1412;
  --accent-soft: rgba(79, 179, 155, 0.16);
  --danger: #ff6b74;
  --high: #fb923c;
  --medium: #facc15;
  --low: #60a5fa;
  --overdue: #ff6b74;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --surface: #191a1e; --surface-2: #202227; --text: #ecebe6; --text-2: #b4b3ad; --muted: #7f7f86; --line: #2b2d33;
    --accent: #4fb39b; --accent-ink: #0d1412; --accent-soft: rgba(79, 179, 155, 0.16); --danger: #ff6b74; --high: #fb923c; --medium: #facc15; --low: #60a5fa; --overdue: #ff6b74;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 1rem; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { width: 100%; max-width: 46rem; margin-inline: auto; padding-inline: 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 1rem; top: -3rem; padding: 0.5rem 0.9rem; background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-sm); z-index: 10; }
.skip:focus { top: 1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top__row { display: flex; align-items: center; justify-content: space-between; height: 3.5rem; }
.brand { margin: 0; font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 0.5rem; }
.brand__mark { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 0.9rem; }
.top__tools { display: flex; align-items: center; gap: 0.75rem; }
.sync { font-size: 0.8125rem; color: var(--muted); }
.sync.is-busy { color: var(--text-2); }
.sync.is-error { color: var(--danger); }
.icon-btn { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); }
.icon-btn .icon--moon { display: none; }
:root[data-theme="dark"] .icon-btn .icon--sun { display: none; }
:root[data-theme="dark"] .icon-btn .icon--moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .icon-btn .icon--sun { display: none; } :root:not([data-theme="light"]) .icon-btn .icon--moon { display: block; } }

/* Summary */
.summary { padding: 1.75rem 0 0.5rem; }
.summary__count { margin: 0 0 0.6rem; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.progress { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width 400ms ease; }

/* Composer */
.composer { margin-top: 1.25rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.composer__title { width: 100%; padding: 0.8rem 0.9rem; font-size: 1.0625rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.composer__row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; align-items: end; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field--grow { flex: 1 1 12rem; }
.field--inline { flex-direction: row; align-items: center; gap: 0.4rem; }
.field__label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.field__input { padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); min-height: 2.5rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.6rem 1rem; min-height: 2.5rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; align-items: center; margin-top: 1.25rem; }
.search { flex: 1 1 14rem; display: flex; align-items: center; gap: 0.5rem; padding: 0 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); }
.search input { flex: 1; min-width: 0; padding: 0.6rem 0; border: 0; background: transparent; outline: none; }
.filters { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.chip { padding: 0.4rem 0.8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 0.875rem; font-weight: 600; color: var(--text-2); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.hint { margin: 0.9rem 0 0.4rem; font-size: 0.8125rem; color: var(--muted); }

/* List */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.task { display: grid; grid-template-columns: auto auto 1fr; gap: 0.5rem; align-items: start; padding: 0.7rem 0.75rem 0.7rem 0.4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease; }
.task.is-dragging { opacity: 0.5; }
.task.is-over { box-shadow: 0 0 0 2px var(--accent) inset; }
.task.is-done .task__title { text-decoration: line-through; color: var(--muted); }
.task__handle { display: grid; place-items: center; width: 1.75rem; height: 2.25rem; border: 0; background: transparent; color: var(--muted); cursor: grab; touch-action: none; }
.task__handle:active { cursor: grabbing; }
.task__check { width: 1.25rem; height: 1.25rem; margin: 0.5rem 0 0; accent-color: var(--accent); cursor: pointer; }
.task__body { min-width: 0; }
.task__main { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.75rem; min-height: 2.25rem; }
.task__title { flex: 1 1 12rem; min-width: 0; padding: 0.3rem 0.4rem; border-radius: 6px; font-size: 1.0625rem; overflow-wrap: anywhere; }
.task__title:focus { background: var(--bg); outline: 2px solid var(--accent); }
.task__meta { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.badge[hidden] { display: none; }
.badge--priority.is-high { color: var(--high); background: color-mix(in srgb, var(--high) 14%, transparent); }
.badge--priority.is-medium { color: var(--medium); background: color-mix(in srgb, var(--medium) 14%, transparent); }
.badge--priority.is-low { color: var(--low); background: color-mix(in srgb, var(--low) 14%, transparent); }
.badge--due.is-overdue { color: var(--overdue); background: color-mix(in srgb, var(--overdue) 14%, transparent); }
.badge--due.is-today { color: var(--accent); background: var(--accent-soft); }
.task__details { margin-top: 0.25rem; }
.task__summary { cursor: pointer; font-size: 0.8125rem; color: var(--muted); padding: 0.2rem 0.4rem; border-radius: 6px; list-style: none; display: inline-block; }
.task__summary::-webkit-details-marker { display: none; }
.task__summary::before { content: "▸ "; }
.task__details[open] .task__summary::before { content: "▾ "; }
.task__notes { display: block; width: 100%; margin-top: 0.5rem; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); resize: vertical; min-height: 4rem; }
.task__edit { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; margin-top: 0.6rem; }
.task__edit .task__delete { margin-left: auto; }

.empty { margin: 2rem 0; text-align: center; color: var(--muted); }
.footer-actions { display: flex; justify-content: flex-end; margin: 1.25rem 0 3rem; }

@media (max-width: 30rem) {
  .summary__count { font-size: 1.25rem; }
  .task { grid-template-columns: auto auto 1fr; padding-right: 0.6rem; }
  .field--inline .field__label { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
