:root {
  --bg: #ececee; --surface: #ffffff; --surface-2: #f3f3f6; --surface-3: #e7e7ec;
  --line: #e3e3e8; --line-2: #cfcfd8;
  --text: #0c0c12; --text-2: #4b4b58; --muted: #8b8b98;
  --accent: #2619d9; --accent-ink: #ffffff; --accent-soft: rgba(38, 25, 217, 0.09);
  --tint: #cfe6fb; --tint-ink: #2619d9;
  --ink: #0c0c12; --ink-fg: #ffffff;
  --ok: #12804a; --ok-soft: rgba(18, 128, 74, 0.1); --warn: #b7791f;
  --danger: #d12b3a; --danger-soft: rgba(209, 43, 58, 0.08);
  --radius: 22px; --radius-sm: 14px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabs-h: 72px;
}
[data-theme="dark"] {
  --bg: #0a0a0e; --surface: #15151b; --surface-2: #1d1d26; --surface-3: #282833;
  --line: #25252e; --line-2: #34343f;
  --text: #f4f4f8; --text-2: #b4b4c2; --muted: #7a7a8a;
  --accent: #5a50ff; --accent-ink: #ffffff; --accent-soft: rgba(90, 80, 255, 0.16);
  --tint: rgba(120, 170, 240, 0.2); --tint-ink: #9fc4ff;
  --ink: #f4f4f8; --ink-fg: #0a0a0e;
  --ok: #4ade9a; --ok-soft: rgba(74, 222, 154, 0.12); --warn: #f5b84b;
  --danger: #f0707a; --danger-soft: rgba(240, 112, 122, 0.14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, a, select, input { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.ic { display: inline-flex; width: 22px; height: 22px; flex-shrink: 0; }
.ic svg { width: 100%; height: 100%; }

/* Layout */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 1120px; padding: 6px 32px 40px; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: calc(22px + env(safe-area-inset-top)) 32px 14px;
}
.topbar h1 { flex: 1; margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.035em; }
.round {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  background: var(--ink); color: var(--ink-fg); border: 0; border-radius: 50%; cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.round:active { transform: scale(0.92); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--muted); padding: 7px 12px; border-radius: 999px; background: var(--surface); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.online { color: var(--ok); }
.status.offline { color: var(--warn); }

/* Sidebar (desktop) */
.sidebar { width: 256px; flex-shrink: 0; padding: 26px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 19px; letter-spacing: -0.03em; padding: 0 12px 26px; }
.mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 700; }
.nav-group { margin-bottom: 16px; }
.nav-title { font-size: 12px; font-weight: 500; color: var(--muted); padding: 6px 12px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; margin-bottom: 2px;
  border-radius: 999px; color: var(--text-2); text-decoration: none; font-size: 14.5px; font-weight: 500;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: var(--ink); color: var(--ink-fg); }

/* Bottom tabs (phone / Android) */
.tabs {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding: 8px 8px env(safe-area-inset-bottom); background: var(--surface); border-radius: 26px 26px 0 0;
  box-shadow: 0 -1px 0 var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; font: inherit; font-size: 11.5px; font-weight: 500; color: var(--muted); text-decoration: none; cursor: pointer; border-radius: 16px;
}
.tab.active { color: var(--text); font-weight: 600; }
.tab.active .ic { color: var(--accent); }

/* "All pages" sheet */
.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-bg { position: absolute; inset: 0; background: rgba(8, 8, 14, 0.5); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow-y: auto; background: var(--bg);
  border-radius: 28px 28px 0 0; padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); animation: slideup 0.28s var(--ease);
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 0 auto 14px; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.sheet-link { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; background: var(--surface); border-radius: 18px; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500; }
.sheet-link .ic { color: var(--accent); }
.sheet-link.active { background: var(--ink); color: var(--ink-fg); }
.sheet-link.active .ic { color: inherit; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .tabs { display: flex; }
  main { padding: 4px 16px calc(var(--tabs-h) + 36px + env(safe-area-inset-bottom)); }
  .topbar { padding: calc(18px + env(safe-area-inset-top)) 16px 12px; }
  .topbar h1 { font-size: 28px; }
  input, textarea, select { font-size: 16px !important; }
}

/* Surfaces */
.page-head { margin: 4px 0 20px; }
.greet { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.04em; }
.greet .soft { display: block; color: var(--muted); }
.page-head p { margin: 10px 0 0; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 22px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border-radius: 20px; padding: 20px; }
.tile .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.tile .value { font-size: 26px; font-weight: 700; letter-spacing: -0.035em; margin: 8px 0 4px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--text-2); }

/* Dashboard bento */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.bento > .w2 { grid-column: span 2; } .bento > .w3 { grid-column: span 3; } .bento > .w4 { grid-column: span 4; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; display: block; color: inherit; text-decoration: none; min-width: 0; }
.card .label { font-size: 13px; font-weight: 500; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.card .big { font-size: 34px; font-weight: 700; letter-spacing: -0.04em; margin: 8px 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card .sub { font-size: 13px; color: var(--text-2); }
.stack > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 600; font-size: 14px; }
.stack .s1 { background: var(--surface); color: var(--tint-ink); border-radius: 22px; padding: 14px 20px 32px; }
.stack .s2 { background: var(--tint); color: var(--tint-ink); border-radius: 22px; padding: 14px 20px 32px; margin-top: -20px; }
.stack .s3 { position: relative; flex-direction: column; align-items: stretch; background: var(--accent); color: var(--accent-ink); border-radius: 24px; padding: 20px; margin-top: -20px; }
.stack .s3 .big { margin: 6px 0 0; font-size: 36px; }
.stack .s3 .sub { color: rgba(255, 255, 255, 0.75); }
.bar { height: 10px; border-radius: 10px; background: var(--tint); margin: 14px 0 10px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 10px; background: var(--accent); transition: width 0.9s var(--ease); }
.chart { width: 100%; height: auto; margin-top: 10px; }
.chart text { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.stat { display: flex; flex-direction: column; gap: 14px; }
.stat .chip { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.stat b { display: block; font-size: 22px; letter-spacing: -0.03em; }
.stat span.t { font-size: 13px; color: var(--muted); }
@media (max-width: 700px) {
  .bento > .w3, .bento > .w4 { grid-column: span 6; }
  .bento > .w2 { grid-column: span 3; }
  .bento > .next { grid-column: span 6; }
  .bento > .stat:last-child { grid-column: span 6; }
  .greet { font-size: 30px; }
}

/* Forms */
.form { display: grid; gap: 12px; }
.form.two { grid-template-columns: 1fr 1fr; }
label.small { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.row label.small { display: flex; align-items: center; gap: 8px; }
input, textarea, select {
  width: 100%; min-height: 48px; padding: 12px 15px; font: inherit; font-size: 14.5px; color: var(--text);
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--radius-sm);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; flex-shrink: 0; accent-color: var(--accent); padding: 0; }
select { width: auto; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.row input:not([type="checkbox"]), .row textarea { flex: 1; min-width: 0; }

/* Buttons */
.btn {
  min-height: 46px; padding: 0 20px; font: inherit; font-size: 14.5px; font-weight: 600; color: var(--text);
  background: var(--surface-2); border: 0; border-radius: 999px; cursor: pointer; transition: transform 0.15s var(--ease), filter 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }

.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: 999px; }
.seg button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 13.5px; font-weight: 600; min-height: 38px; padding: 0 18px; border-radius: 999px; cursor: pointer; transition: background 0.25s var(--ease), color 0.25s var(--ease); }
.seg button.on { background: var(--ink); color: var(--ink-fg); }

/* Lists */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.center { text-align: center; }
.item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 8px; background: var(--surface-2); border-radius: 18px; min-height: 56px; }
.item.done .text { text-decoration: line-through; color: var(--muted); }
.item.now { background: var(--ok-soft); box-shadow: inset 0 0 0 1.5px var(--ok); }
.time { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.lead { background: var(--surface-2); border-radius: 18px; padding: 16px; margin-bottom: 10px; display: grid; gap: 8px; }
.lead strong { overflow-wrap: anywhere; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.summary { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.notice { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }

/* Focus timer */
.ring { position: relative; width: min(280px, 72vw); aspect-ratio: 1; margin: 8px auto 20px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.ring .progress { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke 0.3s; }
.timer-display { position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.ring-wrap { text-align: center; }

@media (min-width: 900px) { .form.wide { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
