:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1f2430; --muted: #6b7280; --line: #e6e3dc;
  --accent: #5b8def; --accent-ink: #fff; --soft: #eef3fd;
  --high: #e8833a; --high-bg: #fdf0e6; --med: #4f9d8a; --med-bg: #e7f4f0; --low: #8a7fd1; --low-bg: #efedfb;
  --ok: #3a9d5d; --danger: #d0533f; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
:root[data-theme="dark"] {
  --bg: #15171c; --panel: #1e2128; --ink: #e8e9ec; --muted: #9298a3; --line: #2e323b;
  --accent: #7aa2f7; --accent-ink: #10131a; --soft: #232a3a;
  --high: #f0a36a; --high-bg: #3a2a1e; --med: #6cc3ae; --med-bg: #1d332e; --low: #a99cf0; --low-bg: #29263f;
  --ok: #5cc27f; --danger: #ef7a66; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171c; --panel: #1e2128; --ink: #e8e9ec; --muted: #9298a3; --line: #2e323b;
    --accent: #7aa2f7; --accent-ink: #10131a; --soft: #232a3a;
    --high: #f0a36a; --high-bg: #3a2a1e; --med: #6cc3ae; --med-bg: #1d332e; --low: #a99cf0; --low-bg: #29263f;
    --ok: #5cc27f; --danger: #ef7a66; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.app { max-width: 820px; margin: 0 auto; padding: 20px 16px 80px; }
.muted { color: var(--muted); font-weight: 400; }
a { color: var(--accent); }

/* header */
.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand .dot { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle, #fff 30%, var(--accent) 32%); }
h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.date { color: var(--muted); font-size: 13px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; white-space: nowrap; }
.stat b { font-variant-numeric: tabular-nums; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 10px; width: 36px; height: 36px; cursor: pointer; }
.icon-btn:hover { background: var(--soft); }

/* energy */
.energy { margin: 20px 0 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.energy .label { font-weight: 600; }
.energy-hint { color: var(--muted); font-size: 13px; flex-basis: 100%; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; }
.seg button:hover { background: var(--soft); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seg button[data-e="high"].on { background: var(--high); color: #fff; }
.seg button[data-e="medium"].on { background: var(--med); color: #fff; }
.seg button[data-e="low"].on { background: var(--low); color: #fff; }
.seg.small button { padding: 5px 10px; font-size: 14px; }

/* capture */
.capture { display: flex; gap: 8px; flex-wrap: wrap; }
.capture input { flex: 1; min-width: 0; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); font-size: 16px; outline: none; }
.capture input:focus { border-color: var(--accent); }
.capture > button { padding: 0 20px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.capture-help { flex-basis: 100%; font-size: 12px; color: var(--muted); }
code, kbd { background: var(--soft); border-radius: 5px; padding: 0 5px; font-size: 12px; }

.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.toggle { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-left: auto; cursor: pointer; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.big { padding: 12px 26px; font-size: 17px; border-radius: 14px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.count { font-size: 12px; background: var(--soft); border-radius: 999px; padding: 0 7px; margin-left: 2px; }
.count:empty { display: none; }

/* cards */
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.list { display: flex; flex-direction: column; gap: 8px; }
.card { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); transition: opacity .2s, transform .2s; }
.card.e-high { border-left-color: var(--high); }
.card.e-medium { border-left-color: var(--med); }
.card.e-low { border-left-color: var(--low); }
.card.dim { opacity: .45; }
.card.dragging { opacity: .4; }
.card.now { padding: 20px; border-width: 1px 1px 1px 6px; }
.card.now .title { font-size: 20px; font-weight: 600; }
.card .body { flex: 1; min-width: 0; cursor: pointer; }
.card .title { font-weight: 500; overflow-wrap: anywhere; }
.card .first { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card .first b { color: var(--ink); font-weight: 500; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.chip.high { background: var(--high-bg); color: var(--high); }
.chip.medium { background: var(--med-bg); color: var(--med); }
.chip.low { background: var(--low-bg); color: var(--low); }
.chip.due-soon { background: var(--high-bg); color: var(--high); }
.chip.overdue { background: var(--danger); color: #fff; }
.chip.stale { border: 1px dashed var(--muted); background: none; }
.check { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid var(--muted); background: none; cursor: pointer; margin-top: 1px; display: grid; place-items: center; color: transparent; font-size: 13px; }
.check:hover { border-color: var(--ok); color: var(--ok); }
.check.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.card-actions { display: flex; gap: 4px; flex: none; align-items: center; }
.card-actions button, .card-actions select { border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px 8px; cursor: pointer; color: var(--muted); font-size: 13px; }
.card-actions button:hover, .card-actions select:hover { border-color: var(--line); color: var(--ink); }
.card-actions .go { color: var(--accent); font-weight: 600; }
.progress { height: 4px; background: var(--soft); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; }
.empty .big { font-size: 34px; }
.note { font-size: 13px; color: var(--muted); background: var(--soft); border-radius: 10px; padding: 10px 14px; margin: 8px 0; }
.suggest .card { box-shadow: none; }

/* done */
.week { display: flex; gap: 6px; align-items: flex-end; height: 90px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.week div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 11px; color: var(--muted); }
.week i { width: 100%; max-width: 36px; background: var(--ok); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.done-item { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.done-item .t { flex: 1; text-decoration: line-through; color: var(--muted); }
.done-item button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(10,12,18,.45); display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px; overflow-y: auto; z-index: 20; }
.modal[hidden], .focus[hidden] { display: none; }
.sheet { background: var(--panel); border-radius: 18px; width: 100%; max-width: 620px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.sheet label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.sheet input, .sheet select, .sheet textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); outline: none; }
.sheet input:focus, .sheet textarea:focus, .sheet select:focus { border-color: var(--accent); }
.sheet-head { display: flex; gap: 8px; }
.title-input { font-size: 19px !important; font-weight: 600; border-color: transparent !important; background: none !important; padding-left: 0 !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.est-row { display: flex; gap: 4px; }
.est-row button { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 0 10px; cursor: pointer; }
.est-row button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.est-row input { width: 70px !important; }
.sheet-foot { display: flex; gap: 8px; margin-top: 20px; align-items: center; }
.spacer { flex: 1; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.steps li .check { width: 20px; height: 20px; font-size: 11px; }
.steps li span { flex: 1; overflow-wrap: anywhere; }
.steps li.done span { text-decoration: line-through; color: var(--muted); }
.steps li .x { background: none; border: 0; color: var(--muted); cursor: pointer; opacity: 0; }
.steps li:hover .x { opacity: 1; }
.step-add input { margin-top: 4px; }

/* focus mode */
.focus { position: fixed; inset: 0; background: var(--bg); z-index: 30; overflow-y: auto; }
.focus-close { position: absolute; top: 16px; right: 16px; }
.focus-inner { max-width: 560px; margin: 0 auto; padding: 48px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.focus-label { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; color: var(--muted); font-weight: 600; }
.focus h2 { font-size: 30px; margin: 0; letter-spacing: -.02em; overflow-wrap: anywhere; }
.first-step { background: var(--soft); border-radius: 12px; padding: 10px 16px; }
.first-step:empty { display: none; }
.timer { position: relative; width: 220px; height: 220px; margin-top: 8px; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 7; }
.timer .track { stroke: var(--line); }
.timer .ring { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 339.3; transition: stroke-dashoffset .3s linear; }
.timer .time { position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; font-weight: 600; font-variant-numeric: tabular-nums; }
.presets { display: flex; gap: 6px; }
.presets button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.presets button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.focus-ctrl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.focus-steps { width: 100%; text-align: left; }
.focus .step-add, .park { width: 100%; }
.focus input { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.park input { border-style: dashed; }

/* toast + confetti */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; transition: transform .25s; z-index: 50; max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; }

@media (max-width: 600px) {
  .grid2 { grid-template-columns: 1fr; }
  .card-actions .mv { display: none; }
  .toggle { margin-left: 0; }
  .focus h2 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
a.icon-btn { display: grid; place-items: center; text-decoration: none; color: inherit; }
