/* ============ Anchor — editorial ink & paper ============ */

:root {
  --bg: #f3efe7;
  --bg-soft: #e9e4d8;
  --card: #faf8f2;
  --card-soft: #f0ecE2;
  --ink: #17150f;
  --muted: #8a8577;
  --line: rgba(23, 21, 15, 0.14);
  --line-soft: rgba(23, 21, 15, 0.07);
  --accent: #e8501f;
  --accent-soft: rgba(232, 80, 31, 0.09);
  --on-accent: #fff4ec;
  --green: #2f9e6e;
  --amber: #d9a521;
  --red: #b02e37;
  --shadow: 0 1px 0 rgba(23, 21, 15, 0.03), 0 10px 30px -18px rgba(23, 21, 15, 0.25);
  --shadow-big: 0 2px 6px rgba(23, 21, 15, 0.06), 0 24px 60px -24px rgba(23, 21, 15, 0.4);
  --glass: rgba(250, 248, 242, 0.88);
  --radius: 14px;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Fragment Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #12100c;
  --bg-soft: #1c1913;
  --card: #191612;
  --card-soft: #211d17;
  --ink: #f2ede3;
  --muted: #97917f;
  --line: rgba(242, 237, 227, 0.16);
  --line-soft: rgba(242, 237, 227, 0.07);
  --accent: #ff5c2a;
  --accent-soft: rgba(255, 92, 42, 0.12);
  --on-accent: #fff4ec;
  --green: #3db183;
  --amber: #e3b13a;
  --red: #d95560;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 10px 30px -18px rgba(0, 0, 0, 0.6);
  --shadow-big: 0 2px 6px rgba(0, 0, 0, 0.3), 0 24px 60px -24px rgba(0, 0, 0, 0.75);
  --glass: rgba(25, 22, 18, 0.88);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
  line-height: 1.5;
  font-size: 15px;
  overscroll-behavior-y: none;
  transition: background 0.3s ease, color 0.3s ease;
}

/* paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] body::before { opacity: 0.07; }

::selection { background: var(--accent); color: var(--on-accent); }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 0;
  position: relative; z-index: 1;
}

/* ============ type utilities ============ */
.mono-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ============ top bar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 8px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--bg) 72%, transparent);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.brand-dot { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: transform 0.15s ease, color 0.2s ease, border-color 0.2s ease;
}
.icon-btn:active { transform: scale(0.92); color: var(--ink); border-color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; stroke-width: 1.8; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
}
.streak-chip .mark { color: var(--accent); font-size: 13px; }

/* ============ layout ============ */
#main { flex: 1; padding: 4px 20px 128px; }
.view { display: none; animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1); }
.view.active { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 10px;
}

h2.section-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin: 30px 2px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
h2.section-title .idx { color: var(--accent); margin-right: 9px; }
h2.section-title .cnt { color: var(--accent); margin-left: 7px; }

/* ============ today: hero ============ */
.hero { padding: 14px 2px 4px; }
.hero .kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.hero .greeting {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.04;
}
.hero .greeting em { font-style: italic; font-weight: 350; }

/* day meter — ticks (time-blindness aid) */
.dayline { margin: 22px 0 4px; }
.dayline .ticks {
  display: flex; justify-content: space-between; align-items: flex-end;
  height: 16px;
}
.dayline .ticks i {
  width: 2px; height: 10px;
  border-radius: 2px;
  background: var(--line);
}
.dayline .ticks i.past { background: var(--ink); opacity: 0.75; }
.dayline .ticks i.now { background: var(--accent); height: 16px; width: 3px; }
.dayline .labels {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-top: 8px;
}
.dayline .labels .now-label { color: var(--accent); }

/* while-you-were-away digest */
.digest { background: var(--accent-soft); border-color: transparent; }
.digest .digest-title { font-family: var(--font-display); font-style: italic; font-size: 17px; margin-bottom: 6px; }
.digest ul { list-style: none; margin: 4px 0 10px; }
.digest li { padding: 3px 0; color: var(--muted); font-size: 14px; }
.digest li b { color: var(--ink); font-weight: 600; }

/* progress card */
.today-progress { display: flex; align-items: center; gap: 18px; padding: 20px 18px; }
.today-progress .frac {
  font-family: var(--font-display);
  line-height: 1;
  flex-shrink: 0;
  display: flex; align-items: baseline;
}
.today-progress .frac .num { font-size: 44px; font-weight: 500; }
.today-progress .frac .den { font-size: 20px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.today-progress .words { flex: 1; min-width: 0; }
.today-progress .words .head { font-weight: 600; font-size: 15.5px; letter-spacing: -0.01em; }
.today-progress .words .sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.seg-meter { display: flex; gap: 3px; margin-top: 10px; }
.seg-meter i {
  flex: 1; height: 5px;
  border-radius: 3px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
}
.seg-meter i.on { background: var(--accent); border-color: transparent; }

/* big 3 */
.big3-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.big3-slot {
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  text-align: left;
  width: 100%; min-width: 0;
  transition: transform 0.15s ease;
}
.big3-slot:active { transform: scale(0.985); }
.big3-slot .n {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  border: 1px solid var(--line);
  color: var(--ink);
}
.big3-slot.empty { border-style: dashed; background: transparent; box-shadow: none; }
.big3-slot.empty .n { color: var(--muted); }
.big3-slot.empty .t { color: var(--muted); font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: 15px; }
.big3-slot .t { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.big3-slot.done .t { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--muted); }
.big3-slot.done .n { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-style: normal; font-family: var(--font-ui); font-size: 13px; }

/* now card — the hot moment */
.now-card {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow-big);
  position: relative;
  overflow: hidden;
}
.now-card .wm {
  position: absolute;
  right: -28px; top: -55px;
  font-family: var(--font-display);
  font-size: 170px;
  line-height: 1;
  opacity: 0.14;
  pointer-events: none;
  user-select: none;
}
.now-card .label {
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  opacity: 0.8;
}
.now-card .title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 450;
  font-size: 23px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 8px 0 18px;
  position: relative;
}
.now-card .actions { display: flex; gap: 10px; position: relative; }
.btn-white {
  background: var(--on-accent); color: #c23805;
  font-weight: 600; font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  transition: transform 0.15s ease;
}
.btn-white:active { transform: scale(0.96); }
.btn-ghost-white {
  background: transparent;
  border: 1px solid rgba(255, 244, 236, 0.5);
  color: var(--on-accent); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 10px;
  transition: transform 0.15s ease;
}
.btn-ghost-white:active { transform: scale(0.96); }

/* ============ quick add ============ */
.quick-add { display: flex; gap: 9px; margin: 8px 0 12px; }
.quick-add input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease;
}
.quick-add input:focus { border-color: var(--accent); }
.quick-add input::placeholder { color: var(--muted); font-family: var(--font-display); font-style: italic; font-size: 15px; }
.quick-add .add-btn {
  width: 48px; flex-shrink: 0;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 22px; font-weight: 400;
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  display: grid; place-items: center;
  line-height: 1;
}
.quick-add .add-btn:active { transform: scale(0.9) rotate(90deg); }

/* ============ task rows ============ */
.task-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.task-row {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  min-width: 0;
  animation: rise 0.25s ease;
  transition: opacity 0.3s ease;
}
.task-row.done { opacity: 0.5; }

.checkbox {
  width: 25px; height: 25px; flex-shrink: 0;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  display: grid; place-items: center;
  transition: all 0.2s ease;
}
.checkbox svg { width: 13px; height: 13px; stroke: var(--on-accent); opacity: 0; transform: scale(0.4); transition: all 0.2s ease; }
.task-row.done .checkbox, .checkbox.on {
  background: var(--accent);
  border-color: var(--accent);
  animation: stamp 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.task-row.done .checkbox svg, .checkbox.on svg { opacity: 1; transform: scale(1); }
.checkbox:active { transform: scale(0.85); }
@keyframes stamp {
  0% { transform: scale(0.6) rotate(-14deg); }
  55% { transform: scale(1.15) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.task-main { flex: 1; min-width: 0; text-align: left; }
.task-title { font-weight: 600; font-size: 15px; word-wrap: break-word; letter-spacing: -0.01em; }
.task-title span {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 56%;
  background-size: 0% 1.5px;
  transition: background-size 0.35s ease 0.05s;
}
.task-row.done .task-title { color: var(--muted); }
.task-row.done .task-title span { background-size: 100% 1.5px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.meta-chip {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3.5px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 5px;
}
.meta-chip .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.meta-chip svg { width: 10px; height: 10px; }
.meta-chip.rem { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.meta-chip.big { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.empty-note {
  text-align: center;
  color: var(--muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  padding: 24px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

/* ============ focus (watch face) ============ */
.focus-wrap { display: flex; flex-direction: column; align-items: center; padding-top: 10px; }
.focus-task-pick {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14.5px;
  margin-bottom: 10px;
  appearance: none;
  text-align: center;
  text-align-last: center;
}
.cat-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 18px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
  transition: all 0.15s ease;
}
.cat-chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.cat-chip.on { border-color: currentColor; color: var(--ink); background: var(--card); }

.mode-seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.mode-seg button {
  padding: 8px 18px;
  font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
  border-left: 1px solid var(--line);
  transition: all 0.2s ease;
}
.mode-seg button:first-child { border-left: none; }
.mode-seg button.active { background: var(--ink); color: var(--bg); }

.ring-box { position: relative; width: min(76vw, 300px); aspect-ratio: 1; margin: 10px 0 6px; }
.ring-box svg { width: 100%; height: 100%; }
#fticks line { stroke: var(--line); transition: stroke 0.3s ease; }
#fticks line.lit { stroke: var(--accent); }
#ringDot { fill: var(--accent); }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
}
.ring-center .mode-label {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
}
.ring-center .time {
  font-family: var(--font-mono);
  font-size: 58px;
  letter-spacing: -0.04em;
  line-height: 1;
}
.ring-center .on-task {
  max-width: 76%;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--muted); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 4px;
}
.focus-wrap.running .ring-box { animation: breathe 4s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.012); }
}

.session-ticks { display: flex; gap: 6px; margin: 6px 0 20px; }
.session-ticks i {
  width: 12px; height: 3px;
  border-radius: 2px;
  background: var(--line);
}
.session-ticks i.filled { background: var(--accent); }

.focus-controls { display: flex; align-items: center; gap: 16px; }
.play-btn {
  width: 78px; height: 78px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  box-shadow: var(--shadow-big);
  transition: transform 0.15s ease, background 0.3s ease;
}
.focus-wrap.running .play-btn { background: var(--accent); color: var(--on-accent); }
.play-btn:active { transform: scale(0.93); }
.play-btn svg { width: 28px; height: 28px; }
.small-ctrl {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  display: grid; place-items: center;
  transition: transform 0.15s ease, color 0.2s, border-color 0.2s;
}
.small-ctrl:active { transform: scale(0.9); color: var(--ink); border-color: var(--ink); }
.small-ctrl svg { width: 19px; height: 19px; }

.focus-stat-line {
  margin-top: 22px;
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
}

/* ============ wins ============ */
.wins-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 22px 22px;
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.wins-hero .mark { color: var(--accent); font-size: 20px; display: block; margin-bottom: 4px; }
.wins-hero .streak-big {
  font-family: var(--font-display);
  font-size: 64px; font-weight: 450; line-height: 1;
  letter-spacing: -0.03em;
}
.wins-hero .streak-sub {
  font-family: var(--font-mono);
  color: var(--muted); margin-top: 8px;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
}
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.stat-card { text-align: center; padding: 18px 12px 15px; margin-bottom: 0; }
.stat-card .v {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 500; letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-card .k {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  margin-top: 4px;
}

/* time by category */
.tc-bar {
  display: flex; height: 14px; gap: 2px;
  border-radius: 4px; overflow: hidden;
  margin-bottom: 14px;
}
.tc-bar .tc-seg { min-width: 6px; border-radius: 3px; }
.tc-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; }
.tc-row .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tc-row .tc-name { flex: 1; font-weight: 600; font-size: 14px; }
.tc-row .tc-min { font-family: var(--font-mono); color: var(--muted); font-size: 12.5px; }
.tc-scope { display: flex; gap: 3px; }
.tc-scope button {
  padding: 5px 11px; border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  border: 1px solid transparent;
}
.tc-scope button.on { border-color: var(--line); color: var(--ink); background: var(--card); }

.tl-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--line-soft); }
.tl-row:first-of-type { border-top: none; }
.tl-row .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tl-row .tl-main { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row .tl-min { font-family: var(--font-mono); color: var(--muted); font-size: 12px; flex-shrink: 0; }

.week-bars { display: flex; align-items: flex-end; gap: 8px; height: 96px; padding: 6px 4px 0; }
.week-bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.week-bars .bar {
  width: 100%;
  border-radius: 4px 4px 2px 2px;
  background: var(--ink);
  opacity: 0.85;
  min-height: 4px;
  transition: height 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.week-bars .bar.zero { background: var(--line-soft); opacity: 1; }
.week-bars .bar-col.today .bar { background: var(--accent); opacity: 1; }
.week-bars .day-label {
  font-family: var(--font-mono);
  font-size: 9.5px; letter-spacing: 0.08em;
  color: var(--muted);
}
.week-bars .bar-col.today .day-label { color: var(--accent); }

.affirmation {
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px; font-weight: 400;
  color: var(--muted);
  padding: 22px 26px;
  background: transparent;
  border: none; box-shadow: none;
  position: relative;
}
.affirmation .q { color: var(--accent); font-size: 26px; line-height: 0; vertical-align: -8px; margin-right: 2px; }
.victory-log .v-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line-soft); }
.victory-log .v-row:last-child { border-bottom: none; }
.victory-log .v-check { color: var(--accent); flex-shrink: 0; font-weight: 700; }
.victory-log .v-title { flex: 1; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.victory-log .v-time { font-family: var(--font-mono); color: var(--muted); font-size: 11.5px; flex-shrink: 0; }

.link-btn {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
}

/* ============ tab bar ============ */
.tabbar {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 480px);
  display: flex;
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 18px;
  padding: 7px;
  box-shadow: var(--shadow-big);
  border: 1px solid var(--line);
  z-index: 30;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 4px 8px;
  border-radius: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.tab svg { width: 20px; height: 20px; stroke-width: 1.7; }
.tab.active { color: var(--bg); background: var(--ink); }

/* ============ bottom sheet ============ */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 13, 9, 0.5);
  backdrop-filter: blur(2px);
  z-index: 40;
  animation: fadein 0.25s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 520px);
  max-height: 88dvh;
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  z-index: 50;
  box-shadow: var(--shadow-big);
  animation: sheetup 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
  display: flex; flex-direction: column;
}
.sheet[hidden], .sheet-backdrop[hidden] { display: none; }
@keyframes sheetup {
  from { transform: translate(-50%, 60%); opacity: 0.4; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--line);
  border-radius: 99px;
  margin: 10px auto 2px;
  flex-shrink: 0;
}
.sheet-body { padding: 14px 22px calc(26px + env(safe-area-inset-bottom)); overflow-y: auto; }

.sheet-title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.field-label {
  font-family: var(--font-mono);
  font-size: 9.5px; color: var(--muted);
  margin: 20px 2px 8px;
  text-transform: uppercase; letter-spacing: 0.18em;
}
.field-label small { text-transform: none; letter-spacing: 0.02em; font-family: var(--font-ui); font-size: 11px; }
.text-input, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease;
}
.text-input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 70px; }

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--card);
}
.seg button {
  flex: 1;
  padding: 10px 6px;
  font-weight: 600; font-size: 13.5px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  transition: all 0.2s ease;
}
.seg button:first-child { border-left: none; }
.seg button.on { background: var(--ink); color: var(--bg); }
.seg button.on.seg-low { background: var(--green); color: #fff; }
.seg button.on.seg-med { background: var(--amber); color: #fff; }
.seg button.on.seg-high { background: var(--red); color: #fff; }

.row-flex { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.switch {
  width: 46px; height: 28px;
  border-radius: 99px;
  background: var(--bg-soft);
  position: relative;
  transition: background 0.25s ease;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.switch::after {
  content: "";
  position: absolute;
  top: 50%; left: 3px;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  transition: left 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { left: 21px; border-color: transparent; }

.step-row, .rem-row, .cat-mgr-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.step-row:last-child, .rem-row:last-child, .cat-mgr-row:last-child { border-bottom: none; }
.step-row .txt { flex: 1; font-size: 14.5px; }
.step-row.done .txt { text-decoration: line-through; color: var(--muted); }
.cat-mgr-row .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cat-mgr-row .txt { flex: 1; font-weight: 600; font-size: 14.5px; }
.mini-x {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--muted);
  display: grid; place-items: center;
  font-size: 12px;
  flex-shrink: 0;
}
.inline-add { display: flex; gap: 8px; margin-top: 8px; }
.inline-add input { flex: 1; }
.inline-add input[type="datetime-local"], .inline-add input[type="date"] { min-width: 0; }
.inline-add .go {
  padding: 0 16px;
  border-radius: 11px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}

.rem-row .when { flex: 1; font-weight: 600; font-size: 14px; }
.rem-row .when small { display: block; color: var(--muted); font-weight: 400; }

.dur-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.dur-presets button {
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}
.dur-presets button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.sheet-actions { display: flex; gap: 10px; margin-top: 26px; }
.btn-primary {
  flex: 1;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600; font-size: 15px;
  padding: 14px;
  border-radius: 12px;
  transition: transform 0.15s ease;
}
.btn-primary:active { transform: scale(0.98); }
.btn-danger {
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--red) 45%, transparent);
  color: var(--red);
  font-weight: 600;
}
.btn-plain {
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
}

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 33px; height: 33px;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-size: 16px;
  color: var(--ink);
}
.stepper .val { min-width: 60px; text-align: center; font-family: var(--font-mono); font-size: 13px; }

/* task picker rows inside sheet */
.pick-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 7px;
  font-weight: 600; font-size: 14.5px;
  transition: transform 0.15s ease;
}
.pick-row:active { transform: scale(0.985); }
.pick-row .dot-n {
  color: var(--accent);
  font-size: 14px;
  flex-shrink: 0;
}

/* ============ toast ============ */
#toast {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  box-shadow: var(--shadow-big);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  z-index: 60;
  max-width: 88%;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ confetti canvas ============ */
#confetti {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 100;
}

/* ============ misc ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 720px) {
  body { padding: 24px 0; }
  #app { min-height: calc(100dvh - 48px); }
}
