:root {
  --accent: #8e44ad; --accent-2: #6c3483; --accent-soft: #f1e6f6;
  --ink: #211a29; --paper: #faf8fc; --card: #ffffff; --line: #e4dcec; --muted: #8d8396;
  --l1: #e8d6f0; --l2: #cda3dd; --l3: #a862c4; --l4: #8e44ad;
  --good: #2f7d6d; --good-soft: #dff0eb; --bad: #b8536b; --lazy: #cfe0f2;
  --st-raw: #64748b; --st-checking: #b45309; --st-progress: #2563eb; --st-killed: #7f1d1d; --st-done: #059669;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #b47ad0; --accent-2: #c99be0; --accent-soft: #2e2238;
    --ink: #eee8f3; --paper: #16121b; --card: #211b28; --line: #352c3f; --muted: #9b90a6;
    --l1: #3d2a4a; --l2: #5e3a73; --l3: #8a52a6; --l4: #b47ad0;
    --good: #6cc4ad; --good-soft: #1e3530; --bad: #e08a9e; --lazy: #2b3d52;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* shell */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-title { font-weight: 800; font-size: 18px; flex: 1; }
.save-ind { font-size: 12px; color: var(--muted); }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 36px; height: 36px; font-size: 17px; }
.wrap { max-width: 600px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav button { flex: 1; border: 0; background: none; padding: 8px 4px 10px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bottomnav button span { font-size: 19px; line-height: 1.2; }
.bottomnav button.on { color: var(--accent); font-weight: 700; }

/* generic */
.eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.sec { margin-bottom: 22px; }
.sec-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.sec-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.sec-sub { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.empty { font-size: 13px; color: var(--muted); font-style: italic; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.btn-primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; }
.btn-ghost { background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.btn-link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 4px; font-size: 13px; }
.btn-danger { background: none; border: 0; color: var(--bad); font-size: 13px; padding: 4px; }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* date nav */
.datenav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.datenav .arrow { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 18px; }
.datenav .arrow:disabled { opacity: .35; cursor: default; }
.datenav .dlabel { flex: 1; text-align: center; }
.dlabel b { display: block; font-size: 17px; text-transform: capitalize; }
.dlabel small { color: var(--muted); font-size: 12px; }
.past-banner { font-size: 12px; background: var(--accent-soft); color: var(--accent-2); padding: 6px 10px; border-radius: 8px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }

/* stats */
.stats { display: flex; gap: 10px; margin-bottom: 14px; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat-num { font-size: 22px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--muted); }
.progress { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 13px; padding: 6px 12px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--card); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.dark.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.lazy.on { background: #6f8fb8; border-color: #6f8fb8; color: #fff; }

/* checklist */
.item { padding: 11px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-row { display: flex; align-items: flex-start; gap: 12px; }
.item-row.clickable { cursor: pointer; user-select: none; }
.box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); flex-shrink: 0; margin-top: 1px; position: relative; }
.item.done .box { background: var(--accent); border-color: var(--accent); }
.item.done .box::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(40deg); }
.item.done .label { color: var(--muted); text-decoration: line-through; }
.label { font-size: 15px; }
.sub { font-size: 12px; color: var(--muted); }
.item .chips, .item .add-row, .item .extra { margin: 8px 0 0 34px; }
.add-row { display: flex; gap: 8px; }
.add-row input { max-width: 200px; border-radius: 20px; padding: 6px 12px; font-size: 13px; }
.round-btn { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--line); color: var(--accent); font-weight: 800; flex-shrink: 0; }
.time-input { width: auto; padding: 6px 10px; margin-left: auto; }

/* bars, calendar */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.bar-row .bl { width: 120px; flex-shrink: 0; }
.bar-track { flex: 1; height: 7px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar-track > div { height: 100%; background: var(--accent); }
.bar-row .bp { width: 36px; text-align: right; color: var(--muted); }
.hist { display: flex; align-items: flex-end; gap: 8px; height: 96px; }
.hcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10px; color: var(--muted); }
.hbar { width: 100%; max-width: 26px; background: var(--line); border-radius: 5px 5px 0 0; margin: 3px 0 4px; }
.hbar.today { background: var(--accent); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .wd { font-size: 10px; color: var(--muted); text-align: center; }
.cell { aspect-ratio: 1; border-radius: 6px; background: var(--line); border: 0; padding: 0; font-size: 10px; color: var(--muted); }
.cell.empty { background: transparent; }
.cell.l1 { background: var(--l1); } .cell.l2 { background: var(--l2); } .cell.l3 { background: var(--l3); color: #fff; } .cell.l4 { background: var(--l4); color: #fff; }
.cell.lazy { background: var(--lazy); }
.cell.sel { box-shadow: 0 0 0 2px var(--accent-2) inset; }
.legend { display: flex; gap: 4px; align-items: center; justify-content: flex-end; font-size: 10px; color: var(--muted); margin-top: 8px; }
.legend .cell { width: 11px; height: 11px; aspect-ratio: auto; }
.an-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.an-line:last-child { border-bottom: 0; }
.up { color: var(--good); font-weight: 700; } .down { color: var(--bad); font-weight: 700; }
.hist-list { font-size: 12px; color: var(--muted); margin-top: 8px; }
.hist-list div { margin-bottom: 4px; }
.hist-list b { color: var(--ink); font-weight: 500; }
.big-num { font-size: 28px; font-weight: 800; }
.saved-tag { font-size: 11px; color: var(--good); min-height: 14px; margin-top: 4px; }

/* safety */
.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.scale button { aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 13px; padding: 0; }
.scale button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .chips { margin: 10px 0; }

/* ideas & achievements */
.list-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.li-head { display: flex; gap: 8px; align-items: flex-start; }
.li-title { font-weight: 600; flex: 1; }
.li-date { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-2); margin: 6px 4px 0 0; }
.stars { color: var(--line); letter-spacing: 1px; }
.stars .on { color: var(--accent); }
.star-pick button { border: 0; background: none; font-size: 22px; padding: 0 2px; color: var(--line); }
.star-pick button.on { color: var(--accent); }
.status-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.st { font-size: 12px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
.st.on.raw { background: var(--st-raw); color: #fff; border-color: transparent; }
.st.on.checking { background: var(--st-checking); color: #fff; border-color: transparent; }
.st.on.progress { background: var(--st-progress); color: #fff; border-color: transparent; }
.st.on.killed { background: var(--st-killed); color: #fff; border-color: transparent; }
.st.on.done { background: var(--st-done); color: #fff; border-color: transparent; }
.overdue { color: var(--bad); }
.form { display: flex; flex-direction: column; gap: 10px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 12px; padding: 4px 9px; border-radius: 10px; background: var(--accent-soft); }
.badge.off { opacity: .35; }
.pot { font-size: 26px; font-weight: 800; color: var(--good); }

/* modal & toast */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20,12,28,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: var(--paper); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.modal-head { display: flex; align-items: center; margin-bottom: 12px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 18px; }
.cfg-item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.cfg-item.hiddenitem { opacity: .55; }
.cfg-item .row input, .cfg-item .row select { padding: 6px 10px; font-size: 13px; }
.cfg-item label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.cfg-item label input { width: auto; }
.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: 90%; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

@media (max-width: 380px) {
  .bar-row .bl { width: 96px; }
  .scale { gap: 3px; }
}
