/* Tour de contrôle — styles */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fbfbf9;
  --ink: #1b1c1e;
  --ink-2: #3d4046;
  --muted: #74777e;
  --faint: #a3a6ac;
  --line: #e7e6e1;
  --line-2: #efeeea;
  --accent: #2f55d4;
  --accent-soft: #e9eefc;
  --danger: #c8372d;
  --danger-soft: #fbeceb;
  --warn: #b86e00;
  --warn-soft: #fdf3e2;
  --ok: #1f8a5b;
  --ok-soft: #e6f4ed;
  --star: #e0a100;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 4px 16px rgba(20, 20, 20, .04);
  --shadow-lg: 0 12px 40px rgba(20, 20, 20, .16);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", "Inter", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --side-w: 236px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131415;
    --surface: #1b1c1e;
    --surface-2: #18191b;
    --ink: #ececea;
    --ink-2: #c9cac7;
    --muted: #92959b;
    --faint: #63666c;
    --line: #2a2b2e;
    --line-2: #232427;
    --accent: #7d9bff;
    --accent-soft: #1f2640;
    --danger: #ff7a6e;
    --danger-soft: #3a1f1d;
    --warn: #f0a93b;
    --warn-soft: #33281a;
    --ok: #4cc58c;
    --ok-soft: #17301f;
    --star: #f2bd2c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- logo */
.logo {
  width: 22px; height: 22px; border-radius: 50%; flex: none; position: relative;
  background:
    radial-gradient(circle, var(--accent) 0 2.5px, transparent 3px),
    radial-gradient(circle, transparent 0 6px, color-mix(in srgb, var(--accent) 35%, transparent) 6px 7px, transparent 7.5px),
    conic-gradient(from 20deg, color-mix(in srgb, var(--accent) 55%, transparent), transparent 25%);
  border: 1.5px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; font-size: 15px; padding: 4px 8px 18px; }
.brand-lg { font-size: 20px; justify-content: center; padding-bottom: 8px; }
.brand-lg .logo { width: 28px; height: 28px; }

/* ---------- layout */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 18px 12px; border-right: 1px solid var(--line); background: var(--surface-2);
  display: flex; flex-direction: column;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--ink-2); cursor: pointer; user-select: none;
}
.nav-link:hover { background: var(--line-2); }
.nav-link.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 560; }
.nav-link .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.nav-link .count.hot { color: #fff; background: var(--danger); border-radius: 10px; padding: 0 7px; font-weight: 600; }
.side-label { margin: 22px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; }
.scope { display: flex; flex-direction: column; gap: 1px; }
.scope .nav-link { padding: 6px 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.side-foot { margin-top: auto; padding-top: 16px; }

/* ---------- top bar */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.capture { position: relative; flex: 1; display: flex; align-items: center; }
.capture-ic { position: absolute; left: 12px; color: var(--accent); pointer-events: none; }
#quick {
  width: 100%; height: 40px; padding: 0 14px 0 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); outline: none;
}
#quick:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-preview {
  position: absolute; top: 46px; left: 0; right: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 12.5px;
}
.quick-preview .qp-title { font-weight: 560; margin-right: 4px; }
.quick-preview .qp-hint { color: var(--faint); margin-left: auto; }
.ac {
  position: absolute; top: 46px; left: 0; min-width: 240px; max-width: 100%; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 4px;
}
.ac-item { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.ac-item.sel, .ac-item:hover { background: var(--accent-soft); }
.ac-item small { color: var(--muted); margin-left: auto; }
.search { position: relative; display: flex; align-items: center; width: 240px; }
.search .ic { position: absolute; left: 10px; color: var(--muted); pointer-events: none; width: 16px; height: 16px; }
.search input {
  width: 100%; height: 40px; padding: 0 30px 0 34px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; outline: none;
}
.search input:focus { border-color: var(--accent); background: var(--surface); }
kbd {
  font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px;
  position: absolute; right: 9px; pointer-events: none;
}

/* ---------- views */
.view { padding: 26px 28px 80px; max-width: 1240px; width: 100%; }
.view-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h1 { font-size: 24px; }
.view-head .sub { color: var(--muted); margin-top: 3px; }
.view-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.crumb a:hover { color: var(--ink); }

.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; align-items: start; }
.today-grid > aside { position: sticky; top: 92px; }

.section { margin-bottom: 26px; }
.section-head {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px 2px;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 650; color: var(--muted);
}
.section-head .n { font-weight: 500; color: var(--faint); }
.section-head.overdue { color: var(--danger); }
.section-head.today { color: var(--accent); }
.section-head .grow { flex: 1; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > .item + .item { border-top: 1px solid var(--line-2); }
.list-empty { padding: 14px 16px; color: var(--faint); font-size: 13px; }

/* ---------- item row */
.item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px; transition: background .12s, opacity .3s; }
.item:hover { background: var(--surface-2); }
.check {
  width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; border: 1.6px solid var(--faint);
  background: transparent; cursor: pointer; flex: none; padding: 0; display: grid; place-items: center; transition: all .15s;
}
.check:hover { border-color: var(--ok); background: var(--ok-soft); }
.item.is-recur .check { border-style: dashed; }
.item.is-prio .check { border-color: var(--star); }
.item.is-done .check, .item.completing .check { background: var(--ok); border-color: var(--ok); border-style: solid; }
.item.is-done .check::after, .item.completing .check::after {
  content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px);
}
.item.completing { opacity: .35; }
.item.is-done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.item-body { flex: 1; min-width: 0; cursor: pointer; }
.item-title { overflow-wrap: anywhere; }
.item-title .star { color: var(--star); width: 13px; height: 13px; vertical-align: -1px; margin-right: 4px; display: inline-flex; }
.item-title .star svg { fill: currentColor; stroke: none; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.meta { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.meta .ic { width: 13px; height: 13px; }
.meta.overdue { color: var(--danger); font-weight: 560; }
.meta.today { color: var(--accent); font-weight: 560; }
.meta.soon { color: var(--ink-2); }
.meta.wait { color: var(--warn); }
.item-side { display: flex; gap: 4px; align-items: center; }
.triage { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.triage select, .triage .chip-btn { height: 28px; font-size: 12.5px; }

/* ---------- radar / cards */
.radar { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; display: block; transition: border-color .12s, transform .12s;
}
a.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub b { color: var(--ink-2); font-weight: 520; }
.alerts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 560; padding: 1px 8px; border-radius: 20px;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.progress { height: 4px; border-radius: 4px; background: var(--line-2); margin-top: 10px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.company-block { margin-bottom: 30px; }
.company-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.company-head h2 { font-size: 16px; }
.company-head .dot { width: 11px; height: 11px; }
.company-head .grow { flex: 1; }
.card.loose { background: transparent; border-style: dashed; box-shadow: none; color: var(--muted); }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 22px;
  background: var(--accent-soft); color: var(--accent); font-weight: 520;
}
.banner .grow { flex: 1; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.empty h3 { color: var(--ink); margin-bottom: 4px; font-size: 16px; }

.desc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 24px; color: var(--ink-2);
}
.desc a { color: var(--accent); text-decoration: underline; }
.inline-add { margin-bottom: 10px; }
.inline-add input {
  width: 100%; height: 38px; border: 1px dashed var(--line); border-radius: 10px; background: transparent; padding: 0 14px; outline: none;
}
.inline-add input:focus { border-style: solid; border-color: var(--accent); background: var(--surface); }
details.done-block { margin-top: 18px; }
details.done-block > summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin: 0 0 8px 2px; list-style: none; }
details.done-block > summary::before { content: "▸ "; }
details.done-block[open] > summary::before { content: "▾ "; }

/* ---------- buttons & forms */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 520; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-2); }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 0 8px; cursor: pointer; color: var(--ink-2); }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
select, input[type=text], input[type=date], input[type=number], input[type=password], textarea {
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 10px; height: 36px; outline: none;
  max-width: 100%;
}
textarea { padding: 8px 10px; height: auto; min-height: 90px; resize: vertical; width: 100%; line-height: 1.5; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input[type=text], .field select { width: 100%; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.daypick { display: flex; gap: 4px; flex-wrap: wrap; }
.daypick label { cursor: pointer; }
.daypick input { display: none; }
.daypick span {
  display: grid; place-items: center; width: 38px; height: 30px; border-radius: 7px; border: 1px solid var(--line); font-size: 12.5px;
}
.daypick input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { cursor: pointer; }
.seg input { display: none; }
.seg span { display: block; padding: 6px 12px; font-size: 13px; border-right: 1px solid var(--line); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- modal */
.modal-wrap {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 10, 12, .38); display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px; overflow-y: auto; animation: fade .15s;
}
.modal {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); animation: pop .16s;
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 6px; }
.modal-head h2 { font-size: 16px; flex: 1; }
.modal-body { padding: 10px 20px 4px; }
.modal-foot { display: flex; gap: 8px; padding: 12px 20px 18px; align-items: center; }
.modal-foot .grow { flex: 1; }
.title-input { width: 100%; font-size: 17px; font-weight: 600; border: 0 !important; padding: 0 !important; height: 34px !important; background: transparent !important; }
.hint { font-size: 12px; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ---------- toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg);
  display: flex; gap: 14px; align-items: center; font-size: 13.5px; animation: pop .2s; max-width: 92vw;
}
.toast.error { background: var(--danger); color: #fff; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; }

/* ---------- settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 15px; margin-bottom: 12px; }
.co-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.co-row:last-child { border-bottom: 0; }
.co-row input[type=text] { flex: 1; min-width: 0; }
.co-row input[type=color] { width: 34px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.syntax { width: 100%; border-collapse: collapse; font-size: 13px; }
.syntax td { padding: 6px 0; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.syntax td:first-child { font-family: var(--mono); color: var(--accent); white-space: nowrap; padding-right: 14px; }

/* ---------- journal */
.day-group { margin-bottom: 20px; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); padding: 28px; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.login-card input { width: 100%; }
.login-card input[type=checkbox] { width: auto; margin: 0; }
.login-err.note { color: var(--warn); }
.login-err { color: var(--danger); margin: -4px 0 12px; font-size: 13px; }
.login-card .btn-primary { justify-content: center; height: 40px; }
.login-info { margin: 0 0 14px; color: var(--ink-2); font-size: 13.5px; }
.login-trust { margin: -2px 0 16px; font-size: 13px; color: var(--ink-2); }
.login-links { display: flex; justify-content: space-between; margin-top: 10px; }
.code-input { font: 600 22px/1 var(--mono) !important; letter-spacing: .25em; text-align: center; height: 48px !important; }
.sess { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.sess:last-child { border-bottom: 0; }
.sess .ua { color: var(--ink-2); }
.sess small { color: var(--muted); display: block; }

/* ---------- tabbar (mobile) */
.tabbar { display: none; }
.mobile-only { display: none !important; }
.scrim { display: none; }

@media (max-width: 1080px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); }
  .today-grid > aside { position: static; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .mobile-only { display: grid !important; }
  .desktop-only { display: none; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; width: 280px; transform: translateX(-100%);
    transition: transform .2s; box-shadow: var(--shadow-lg);
  }
  .app.drawer .side { transform: none; }
  .app.drawer .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .3); }
  .top { padding: 10px 16px; gap: 8px; flex-wrap: wrap; }
  .capture { order: 3; flex-basis: 100%; }
  .search { flex: 1; width: auto; }
  .view { padding: 18px 16px 110px; }
  .view-head h1 { font-size: 21px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--surface);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); padding: 4px 0; position: relative; }
  .tabbar a.active { color: var(--accent); }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar .badge { position: absolute; top: 0; left: 55%; background: var(--danger); color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; font-weight: 700; }
  .toasts { bottom: 86px; }
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
  .item { padding: 11px 12px; }
  .cards { grid-template-columns: 1fr; }
}
