/* =====================================================================
   Daily Tracker: an editorial, paper-and-ink look
   ===================================================================== */
:root {
  --paper: #f4f2ed;
  --surface: #fcfbf8;
  --sunken: #ece9e1;
  --line: #e3dfd5;
  --line-strong: #cfcabd;
  --ink: #1b1a17;
  --ink-2: #3a3833;
  --muted: #76726a;
  --faint: #a39f95;

  --accent: #2f6b52;
  --accent-soft: #e2ece5;
  --danger: #b4402f;
  --danger-soft: #f5e2dc;

  --study: #3f5e96;
  --steps: #2f7d5b;
  --food: #c0812b;
  --exercise: #b65a3c;

  --radius: 10px;
  --radius-sm: 6px;
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", ui-serif, Georgia, "Times New Roman", serif;
  --shadow-pop: 0 1px 2px rgba(27, 26, 23, .06), 0 12px 32px -8px rgba(27, 26, 23, .18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131311;
    --surface: #1a1a17;
    --sunken: #24231f;
    --line: #2b2a26;
    --line-strong: #3d3b35;
    --ink: #edeae2;
    --ink-2: #cfcbc1;
    --muted: #918d83;
    --faint: #64615a;

    --accent: #7cc3a0;
    --accent-soft: #1f2d26;
    --danger: #e5735f;
    --danger-soft: #3a221d;

    --study: #8fa8da;
    --steps: #7cc3a0;
    --food: #e0a85a;
    --exercise: #e08a6c;
    --shadow-pop: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -8px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14.5px/1.5 var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "ss01", "cv11";
}

h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: inherit; }
p { margin: 0; }
.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.num { font-variant-numeric: tabular-nums; }

/* ---------- Type ---------- */
.display {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 42px;
  line-height: 1.05;
  letter-spacing: -.01em;
}
.display em { font-style: italic; color: var(--muted); }
.eyebrow, .label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow { margin-bottom: 8px; }
.meta { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- App layout ---------- */
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px 26px;
  font-family: var(--font-serif); font-size: 23px; letter-spacing: -.01em; line-height: 1;
}
.brand img { border-radius: 6px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  height: 36px; padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px;
  transition: background .12s, color .12s;
}
.nav a .ic { color: var(--faint); transition: color .12s; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.active { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.nav a.active .ic { color: var(--accent); }

.sidebar-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 6px 0 10px;
  border-top: 1px solid var(--line);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--ink); color: var(--paper);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.who { min-width: 0; flex: 1; line-height: 1.3; }
.who strong { display: block; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { padding: 40px 48px 64px; max-width: 1240px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 28px;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2:not(.label) { font-size: 15px; }
.panel > :last-child { margin-bottom: 0; }
.stack { display: grid; gap: 20px; }
.stack > .panel { margin-bottom: 0; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.split > .panel { margin-bottom: 0; }

.dash { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }

/* ---------- Goal rings ---------- */
.rings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ring-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  padding: 2px 18px;
  border-left: 1px solid var(--line);
  text-decoration: none; color: inherit;
  min-width: 0;
}
.ring-item:first-child { border-left: 0; padding-left: 0; }
.ring-wrap { position: relative; width: 58px; height: 58px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--sunken); stroke-width: 5; }
.ring-fill { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .7s cubic-bezier(.2, .7, .2, 1); }
.ring-fill.zero { opacity: 0; }
.ring-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ring-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.ring-value { font-size: 26px; font-weight: 600; letter-spacing: -.025em; line-height: 1.15; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ring-value small { font-size: 12.5px; font-weight: 400; letter-spacing: 0; color: var(--muted); margin-left: 3px; }
.ring-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Meter ---------- */
.meter { height: 4px; background: var(--sunken); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--ink); transition: width .5s cubic-bezier(.2, .7, .2, 1); }

/* ---------- Charts ---------- */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.chart-title { font-weight: 600; font-size: 13.5px; }
.chart-stat { font-size: 12.5px; color: var(--muted); }
.chart-stat b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.plot {
  position: relative; height: 132px;
  display: flex; align-items: flex-end; gap: 8px;
  border-bottom: 1px solid var(--line-strong);
}
.plot .col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.plot .bar {
  width: 100%; max-width: 30px; min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: color-mix(in srgb, var(--c) 32%, transparent);
  transition: height .5s cubic-bezier(.2, .7, .2, 1);
}
.plot .col.today .bar { background: var(--c); }
.plot .col:hover .bar { background: color-mix(in srgb, var(--c) 70%, transparent); }
.goal-line {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 1px dashed var(--faint);
  pointer-events: none;
}
.goal-line span {
  position: absolute; right: 0; top: -9px; transform: translateY(-50%);
  font-size: 10.5px; color: var(--muted); background: var(--surface); padding-left: 6px;
}
.axis { display: flex; gap: 8px; margin-top: 6px; }
.axis span { flex: 1; text-align: center; font-size: 11px; color: var(--faint); }
.axis span.today { color: var(--ink); font-weight: 600; }

/* ---------- Consistency (streaks) ---------- */
.streak { display: grid; grid-template-columns: 44px 1fr; gap: 0 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.streak:first-of-type { border-top: 0; padding-top: 0; }
.streak:last-child { padding-bottom: 0; }
.streak-num { font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; }
.streak-num.zero { color: var(--faint); }
.streak-title { font-weight: 500; font-size: 13.5px; }
.streak-sub { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.streak-sub .nudge { color: var(--food); }
.days-strip { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; }
.days-strip i { aspect-ratio: 1; border-radius: 2px; background: var(--sunken); }
.days-strip i.on { background: var(--c, var(--accent)); }
.days-strip i.today { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 2.5px var(--line-strong); }

/* ---------- Target rows ---------- */
.target { padding: 14px 0; border-top: 1px solid var(--line); }
.target:first-child { border-top: 0; padding-top: 0; }
.target:last-child { padding-bottom: 0; }
.target-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.target-title { font-weight: 500; flex: 1; min-width: 140px; }
.target-pct { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.target-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.target.editing, .row.editing { background: var(--sunken); border-radius: var(--radius-sm); margin: 0 -12px; padding: 12px; border-top-color: transparent; }

/* ---------- Buttons ---------- */
button { font: inherit; color: inherit; cursor: pointer; }
.btn, button.primary, form button:not([type=button]):not(.ghost):not(.icon):not(.chip):not(.link) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper);
  font-weight: 500; font-size: 13.5px; white-space: nowrap;
  transition: opacity .12s;
}
form button:not([type=button]):not(.ghost):not(.icon):not(.chip):not(.link):hover { opacity: .88; }
button:disabled { opacity: .5 !important; cursor: default; }
button.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 13.5px; white-space: nowrap;
}
button.ghost:hover { background: var(--sunken); }
button.ghost.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
button.icon {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--faint);
}
button.icon:hover { background: var(--sunken); color: var(--ink); }
button.icon.danger:hover { color: var(--danger); background: var(--danger-soft); }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--ink); }
a.link { color: var(--muted); font-size: 13px; text-decoration: none; }
a.link:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Inputs ---------- */
input, select, textarea {
  font: inherit; color: var(--ink);
  height: 36px; padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
input:disabled { background: var(--sunken); color: var(--muted); }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%2376726a' stroke-width='1.5'%3E%3Cpath d='m1 1 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
input[type="date"] { font-variant-numeric: tabular-nums; }
input.num-input { width: 74px; height: 30px; padding: 0 8px; text-align: right; font-variant-numeric: tabular-nums; }
.inline-num { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }

.check {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px; margin: 0; padding: 0; flex: none;
  border: 1.5px solid var(--line-strong); border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.check:hover { border-color: var(--accent); }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after {
  content: ""; width: 9px; height: 5px;
  border: 2px solid var(--surface); border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}

.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-row > input, .form-row > select { flex: 1 1 130px; }
.form-row > input[type="number"] { flex: 0 1 130px; }
.form-row > select { flex: 0 1 150px; }
.form-row > .wide { flex: 2 1 220px; }
.form-row > button { flex: none; }

.form-stack { display: grid; gap: 16px; max-width: 480px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field small { font-size: 12px; color: var(--muted); }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.days { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 100%; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span {
  display: inline-grid; place-items: center;
  width: 42px; height: 30px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  cursor: pointer; user-select: none; transition: all .12s;
}
.days input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Tabs (underline) ---------- */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button {
  background: none; border: 0; border-radius: 0;
  padding: 0 0 10px; margin-bottom: -1px;
  border-bottom: 1.5px solid transparent;
  color: var(--muted); font-weight: 500; font-size: 13.5px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }
.page-head .tabs { margin-bottom: 0; border-bottom: 0; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.chips .label { margin-right: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); color: var(--ink-2);
  font-size: 12.5px; font-weight: 500;
  transition: border-color .12s, background .12s;
}
.chip:hover { border-color: var(--line-strong); background: var(--sunken); }
.chip small { color: var(--faint); font-weight: 400; font-variant-numeric: tabular-nums; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px;
  border-radius: 4px; border: 1px solid var(--line);
  font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.tag.auto { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); }
.tag.good { color: var(--paper); background: var(--accent); border-color: var(--accent); }
.tag .ic { width: 11px; height: 11px; }

/* ---------- Date nav ---------- */
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-group {
  display: flex; align-items: center; height: 36px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
.date-group button { width: 34px; height: 100%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.date-group button:hover { color: var(--ink); background: var(--sunken); }
.date-group button:first-child { border-radius: 5px 0 0 5px; }
.date-group button:last-child { border-radius: 0 5px 5px 0; }
.date-group input {
  border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  border-radius: 0; height: 100%; width: 150px; background: transparent; text-align: center;
}
.date-group input:focus { box-shadow: none; }

/* ---------- Rows / lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 14px;
  min-height: 52px; padding: 10px 0;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; }
.row-title .sep { color: var(--faint); margin: 0 6px; font-weight: 400; }
.row-title .sub { font-weight: 400; color: var(--ink-2); }
.row-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-value { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.row-value small { color: var(--muted); font-weight: 400; }
.row.done .row-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.actions { display: flex; gap: 2px; }
@media (hover: hover) {
  .row .actions, .target .actions { opacity: 0; transition: opacity .12s; }
  .row:hover .actions, .row:focus-within .actions, .target:hover .actions, .target:focus-within .actions { opacity: 1; }
}
.edit-form { flex: 1 1 100%; }

.group-head { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 0 6px; border-bottom: 1px solid var(--line); }
.group-head:first-child { padding-top: 0; }
.group-head + .list .row:first-child { border-top: 0; }
.group-head .row-value { font-size: 13px; color: var(--muted); }

.add-row { padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }

.empty { padding: 28px 0 12px; text-align: center; color: var(--muted); font-size: 13.5px; }
.empty strong { display: block; font-family: var(--font-serif); font-weight: 400; font-size: 22px; color: var(--ink); margin-bottom: 4px; }
.empty a { color: var(--ink); }

.suggest {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; margin-top: 16px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--muted);
}

/* ---------- Big figure (food, steps) ---------- */
.figure { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.figure-value { font-size: 44px; font-weight: 600; line-height: 1; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.figure-unit { color: var(--muted); font-size: 14px; }
.figure-row { display: flex; gap: 28px; margin-top: 14px; flex-wrap: wrap; }
.figure-row div { font-size: 12.5px; color: var(--muted); }
.figure-row b { display: block; font-size: 15px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

details.routine summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
details.routine summary::-webkit-details-marker { display: none; }
details.routine summary .chev { transition: transform .2s; color: var(--muted); }
details.routine[open] summary .chev { transform: rotate(180deg); }
details.routine[open] summary { margin-bottom: 16px; }

/* ---------- Skeleton ---------- */
.skel { background: var(--sunken); border-radius: var(--radius); position: relative; overflow: hidden; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- Welcome ---------- */
.welcome { max-width: 600px; margin: 24px auto 0; }
.welcome .display { margin-bottom: 10px; }
.welcome .lead { color: var(--muted); font-size: 15px; margin-bottom: 28px; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 14px; padding: 22px 0; border-top: 1px solid var(--line); }
.step-num {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--muted);
}
.step h2 { font-size: 15px; margin-bottom: 14px; }
.step h2 span { color: var(--muted); font-weight: 400; }

/* ---------- FAB + dialog ---------- */
.fab {
  display: none;
  position: fixed; right: 18px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 25;
  width: 54px; height: 54px; border-radius: 50%;
  border: 0; background: var(--ink); color: var(--paper);
  place-items: center;
  box-shadow: var(--shadow-pop);
}
.fab .ic { width: 22px; height: 22px; stroke-width: 2; }
dialog {
  border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 22px;
  width: min(580px, calc(100% - 32px));
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(19, 19, 17, .4); backdrop-filter: blur(2px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.dialog-head h2 { font-family: var(--font-serif); font-weight: 400; font-size: 26px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50;
  transform: translate(-50%, 10px);
  display: flex; align-items: center; gap: 16px;
  max-width: calc(100% - 32px);
  padding: 10px 10px 10px 16px; min-height: 44px;
  background: var(--ink); color: var(--paper);
  border-radius: 8px; box-shadow: var(--shadow-pop);
  font-size: 13.5px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
}
#toast:not(:has(button)) { padding-right: 16px; }
#toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }
#toast button {
  height: 28px; padding: 0 12px; border-radius: 5px;
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  background: transparent; color: inherit; font-weight: 600; font-size: 12.5px;
}

/* ---------- Auth page ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-aside {
  background: #1b1a17; color: #f4f2ed;
  padding: 44px 52px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.auth-aside .brand { padding: 0; color: #f4f2ed; }
.auth-aside h1 { font-family: var(--font-serif); font-weight: 400; font-size: 54px; line-height: 1.02; letter-spacing: -.015em; max-width: 520px; }
.auth-aside h1 em { color: #7cc3a0; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; max-width: 420px; }
.auth-points li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; color: #b9b5ab; font-size: 14px; }
.auth-points li b { color: #f4f2ed; font-weight: 500; }
.auth-points .ic { color: #7cc3a0; margin-top: 2px; }
.auth-foot { font-size: 12.5px; color: #8b877e; }
.auth-main { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h2 { font-family: var(--font-serif); font-weight: 400; font-size: 34px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 24px; }
.auth-card .tabs { margin-bottom: 22px; }
.auth-card .form-stack { max-width: none; }
.auth-card form button:not([type=button]) { width: 100%; height: 40px; margin-top: 4px; }
.auth-card input { height: 40px; }
.error-text { color: var(--danger); font-size: 13px; min-height: 1.2em; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
  .dash-side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

@media (max-width: 980px) {
  main { padding: 32px 28px 56px; }
  .rings { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; }
  .ring-item:nth-child(odd) { border-left: 0; padding-left: 0; }
  .charts { grid-template-columns: 1fr; gap: 28px; }
  .split, .dash-side { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { padding: 32px 28px; }
  .auth-aside h1 { font-size: 40px; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  input, select { font-size: 16px; height: 42px; } /* keeps iOS from zooming into inputs */
  input.num-input { height: 34px; }
  .btn, form button:not([type=button]):not(.ghost):not(.icon):not(.chip):not(.link), button.ghost { height: 42px; }
  button.icon { width: 38px; height: 38px; }

  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; font-size: 21px; }
  .icon-link { color: var(--ink-2); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; }

  .layout { display: block; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20;
    height: auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    flex-direction: row;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-right: 0; border-top: 1px solid var(--line);
  }
  .sidebar .brand, .sidebar-foot, .nav a.nav-settings { display: none; }
  .nav { display: flex; width: 100%; }
  .nav a { flex: 1; flex-direction: column; justify-content: center; gap: 3px; height: 52px; padding: 0; font-size: 10.5px; font-weight: 500; color: var(--muted); }
  .nav a .ic { width: 22px; height: 22px; color: inherit; }
  .nav a.active { background: none; box-shadow: none; color: var(--ink); }
  .nav a.active .ic { color: var(--ink); stroke-width: 2; }

  main { padding: 22px 16px calc(150px + env(safe-area-inset-bottom)); }
  .display { font-size: 34px; }
  .page-head { margin-bottom: 20px; align-items: flex-start; flex-direction: column; }
  .page-head .tabs { width: 100%; border-bottom: 1px solid var(--line); }
  .date-nav { width: 100%; }
  .date-group { flex: 1; height: 42px; }
  .date-group input { flex: 1; width: auto; }
  .date-group button { width: 44px; }
  .panel { padding: 16px; border-radius: 12px; }
  .fab { display: grid; }
  .quick-add-panel { display: none; } /* the FAB does this job on mobile */

  .ring-item { gap: 10px; padding: 0 0 0 14px; }
  .ring-item:nth-child(odd) { padding-left: 0; }
  .ring-wrap { width: 50px; height: 50px; }
  .ring-value { font-size: 24px; }

  .form-row > input, .form-row > select, .form-row > .wide { flex: 1 1 100%; }
  .form-row > input[type="number"], .form-row > input[type="date"] { flex: 1 1 calc(50% - 4px); }
  .form-row > button { flex: 1 1 100%; }
  .fields-2 { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .figure-value { font-size: 38px; }

  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; border-bottom: 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .auth-aside { padding: 24px 20px; gap: 18px; }
  .auth-aside h1 { font-size: 32px; }
  .auth-points, .auth-foot { display: none; }
}

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