:root {
  /* warm paper palette */
  --bg: #F5F1EA;
  --bg-deep: #EDE7DB;
  --paper: #FBF8F2;
  --ink: #2B2620;
  --ink2: #5A4F42;
  --ink3: #766A5A; /* darkened from #8A7E6E to reach AA 4.5:1 on --paper */
  --ink-rgb: 43, 38, 32;
  --hair: rgba(43, 38, 32, 0.10);
  --hair-strong: rgba(43, 38, 32, 0.18);
  /* habit accents */
  --terracotta: #B86B4B;
  --sage: #7A8F6A;
  --plum: #8A5B6B;
  --ochre: #C89A3E;
  --danger: #B4513A;

  /* träning sub-accents — per workout choice */
  --workout-back:  #B86B4B; /* Rygg */
  --workout-chest: #5E7A8F; /* Bröst */
  --workout-leg:   #8A6B3E; /* Ben */

  /* semantic aliases */
  --surface: var(--paper);
  --surface-deep: var(--bg-deep);
  --on-surface: var(--ink);
  --on-surface-muted: var(--ink2);
  --on-surface-subtle: var(--ink3);
  --border: var(--hair);
  --border-strong: var(--hair-strong);

  /* radius */
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* motion */
  --ease-out: cubic-bezier(0.2, 0.9, 0.25, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.9, 0.3);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 160ms;
  --t-base: 220ms;
  --t-slow: 320ms;

  --serif: "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --sans: "IBM Plex Sans", -apple-system, system-ui, sans-serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1613;
    --bg-deep: #221D18;
    --paper: #23201B;
    --ink: #EFE8DB;
    --ink2: #BBB3A3;
    --ink3: #969080; /* brightened from #8A8273 to reach AA 4.5:1 on dark --paper */
    --ink-rgb: 239, 232, 219;
    --hair: rgba(239, 232, 219, 0.10);
    --hair-strong: rgba(239, 232, 219, 0.18);
    --terracotta: #D88060;
    --sage: #96B184;
    --plum: #A57283;
    --ochre: #DDB25A;
    --workout-back:  #D88060;
    --workout-chest: #7A99AE;
    --workout-leg:   #B08559;
    --danger: #E06F56;
  }
}

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

/* Visually hidden but readable by screen readers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
}

/* Tabular figures wherever numbers carry weight */
.ring, .metric .num, .streak-card .count, .streak-card .stats .val,
.per-habit .nums, .history .streak, .chart-card .trend,
.day-detail .line .val, .heatmap-legend {
  font-variant-numeric: tabular-nums;
}

/* Focus-visible: warm ink ring, never removed */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 4px;
}
.tabbar button:focus-visible,
.workout-grid button:focus-visible,
.yn .choice-row button:focus-visible {
  outline-offset: 3px;
}

/* Touch — remove the 300ms tap delay on mobile */
button, a, input, textarea, select { touch-action: manipulation; }

/* Reduced motion — collapse springs, still honor cause/effect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.17 0 0 0 0 0.15 0 0 0 0 0.12 0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  body { background-blend-mode: screen; }
}

button { font-family: inherit; color: inherit; }

main#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) calc(0px + var(--safe-right)) 0 calc(0px + var(--safe-left));
  min-height: 100dvh;
  position: relative;
}

/* ─── TOP BAR ─────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 24px 14px;
}

.topbar .mark {
  width: 20px; height: 20px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  position: relative;
}
.topbar .mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--ink);
  border-radius: 50%;
}

.topbar .screen-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--ink3);
  text-transform: uppercase;
}
.topbar .welcome {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink2);
  letter-spacing: 0.01em;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .welcome em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--ink);
  font-size: 16px;
  margin-left: 3px;
}
.topbar .welcome[hidden] { display: none; }

.topbar .icon-btn {
  background: transparent;
  border: none;
  padding: 11px; /* 22px icon + 22px pad = 44px touch target */
  margin: -11px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ink2);
  -webkit-tap-highlight-color: transparent;
  transition:
    color var(--t-base) var(--ease-out),
    transform var(--t-fast) var(--ease-spring);
}
.topbar .icon-btn:hover { color: var(--ink); }
.topbar .icon-btn:active { transform: scale(0.92); }
.topbar .icon-btn svg { display: block; }

/* ─── SCREEN ─────────────────────────────────────── */
.screen {
  padding: 4px 20px 128px;
}

/* Swipe-tab slide animations (respect reduced-motion) */
@keyframes screen-slide-right { from { transform: translate3d(22px, 0, 0); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes screen-slide-left  { from { transform: translate3d(-22px, 0, 0); opacity: 0.4; } to { transform: none; opacity: 1; } }
.screen.slide-from-right { animation: screen-slide-right 240ms cubic-bezier(0.2,0.9,0.25,1); }
.screen.slide-from-left  { animation: screen-slide-left  240ms cubic-bezier(0.2,0.9,0.25,1); }
@media (prefers-reduced-motion: reduce) {
  .screen.slide-from-right, .screen.slide-from-left { animation: none !important; }
}

.screen-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}
.screen-head .eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink3);
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 6px;
}
.screen-head .title {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.3px;
  margin: 0;
}
.screen-head .title em {
  font-style: italic;
  color: var(--ink2);
  font-weight: normal;
}

.page-title {
  font-family: var(--serif);
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.5px;
  margin: 0;
}
.page-title .alt {
  display: block;
  font-style: italic;
  color: var(--ink2);
}
.page-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink3);
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* ─── DAY NAV ───────────────────────────────────── */
.day-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 18px;
}
.day-nav .nav-btn {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--hair);
  color: var(--ink);
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--t-fast) var(--ease-spring),
    border-color var(--t-base) var(--ease-out),
    opacity var(--t-base) var(--ease-out);
}
.day-nav .nav-btn::before {
  content: "";
  position: absolute;
  inset: -4px;
}
.day-nav .nav-btn:active:not(:disabled) { transform: scale(0.92); }
.day-nav .nav-btn:disabled { opacity: 0.35; cursor: default; }
.day-nav .nav-btn svg { display: block; }
.day-nav .day-jump {
  margin-left: auto;
  background: transparent;
  border: 1px dashed var(--hair-strong);
  color: var(--ink2);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--t-fast) var(--ease-spring),
    color var(--t-base) var(--ease-out),
    border-color var(--t-base) var(--ease-out);
}
.day-nav .day-jump:active { transform: scale(0.96); }
.day-nav .day-jump:hover { color: var(--ink); border-color: var(--ink); }
.day-nav .day-jump[hidden] { display: none !important; }

/* ─── RING ─────────────────────────────────────── */
.ring {
  position: relative;
  flex-shrink: 0;
}
.ring svg { display: block; }
.ring .ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.ring .ring-label .denom { color: var(--ink3); font-size: 9px; }

/* ─── QUESTION BLOCKS ─────────────────────────── */
.q {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color var(--t-base) var(--ease-out);
  animation: rise var(--t-slow) var(--ease-out) both;
}
.q:nth-child(2) { animation-delay: 40ms; }
.q:nth-child(3) { animation-delay: 80ms; }
.q:nth-child(4) { animation-delay: 120ms; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.q.answered { border-color: color-mix(in srgb, var(--ink) 8%, transparent); }
.q-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.q-head .meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.q-head .label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--ink3);
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}
.q-head .question {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.15;
}
.q-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

/* workout 4-button grid */
.workout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}
.workout-grid button {
  padding: 14px 0 12px;
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--hair);
  cursor: pointer;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1;
  transition:
    transform var(--t-fast) var(--ease-spring),
    background var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out),
    border-color var(--t-base) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.workout-grid button:active { transform: scale(0.96); }
.workout-grid button.selected { color: var(--paper); }
.workout-grid button.selected.back {
  background: var(--workout-back);
  border-color: var(--workout-back);
}
.workout-grid button.selected.chest {
  background: var(--workout-chest);
  border-color: var(--workout-chest);
}
.workout-grid button.selected.leg {
  background: var(--workout-leg);
  border-color: var(--workout-leg);
}
.workout-grid button.selected.none {
  background: var(--ink2);
  border-color: var(--ink2);
}
.workout-grid button.none { font-style: italic; }

/* yes/no row */
.yn {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition:
    transform var(--t-fast) var(--ease-spring),
    background var(--t-base) var(--ease-out),
    border-color var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  color: var(--ink);
}
.yn:active { transform: scale(0.985); }
.yn .meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.yn .label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--ink3);
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}
.yn .question {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.15;
}
.yn .check {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--accent, var(--ink3));
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  color: var(--accent, var(--ink3));
}
.yn .check svg { display: block; }

.yn.yes {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}
.yn.yes .label { color: color-mix(in srgb, var(--paper) 72%, transparent); }
.yn.yes .check {
  border-color: color-mix(in srgb, var(--paper) 80%, transparent);
  background: color-mix(in srgb, var(--paper) 15%, transparent);
  color: var(--paper);
}

.yn.no {
  background: var(--ink2);
  border-color: var(--ink2);
  color: var(--paper);
}
.yn.no .label { color: color-mix(in srgb, var(--paper) 72%, transparent); }
.yn.no .check {
  border-color: color-mix(in srgb, var(--paper) 80%, transparent);
  background: transparent;
  color: var(--paper);
}

.yn .choice-row {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.yn .choice-row button {
  width: 56px;
  padding: 10px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--hair);
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  font-style: italic;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--t-fast) var(--ease-spring),
    background var(--t-base) var(--ease-out),
    border-color var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out);
}
.yn .choice-row button:active { transform: scale(0.96); }
.yn.yes .choice-row button,
.yn.no .choice-row button {
  border-color: color-mix(in srgb, var(--paper) 35%, transparent);
  color: color-mix(in srgb, var(--paper) 60%, transparent);
}
.yn.yes .choice-row button[data-value="true"] {
  background: color-mix(in srgb, var(--paper) 18%, transparent);
  color: var(--paper);
  border-color: color-mix(in srgb, var(--paper) 70%, transparent);
}
.yn.no .choice-row button[data-value="false"] {
  background: color-mix(in srgb, var(--paper) 18%, transparent);
  color: var(--paper);
  border-color: color-mix(in srgb, var(--paper) 70%, transparent);
}

/* summary CTA */
.cta {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  text-align: center;
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  transition:
    background var(--t-slow) var(--ease-out),
    color var(--t-slow) var(--ease-out),
    border-color var(--t-slow) var(--ease-out);
  border: 1px dashed var(--hair-strong);
  color: var(--ink3);
  background: transparent;
}
.cta.done {
  background: var(--ink);
  color: var(--bg);
  border: none;
}

/* history strip — last 7 days */
.history {
  margin-top: 22px;
}
.history .eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink3);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.history .box {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.history .row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 0.5px solid var(--hair);
}
.history .row:last-child { border-bottom: none; }
.history .row .dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.history .row .name {
  flex: 1;
  font-family: var(--serif);
  font-size: 16px;
}
.history .row .cells {
  display: flex;
  gap: 3px;
}
.history .row .cells .c {
  width: 12px; height: 12px; border-radius: 3px;
  background: var(--bg-deep);
}
.history .row .streak {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink3);
  width: 32px;
  text-align: right;
}

/* ─── CALENDAR SCREEN ──────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
}

/* Empty state card (first-run, no data yet) */
.card.empty-state {
  padding: 26px 20px 28px;
  text-align: left;
}
.card.empty-state .eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink3);
  margin-bottom: 14px;
}
.card.empty-state .empty-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: 10px;
}
.card.empty-state .empty-body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink2);
  max-width: 34ch;
}

/* Heatmap SVG keyboard focus ring */
svg[role="grid"]:focus { outline: none; }
svg[role="grid"]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 4px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  gap: 10px;
}
.card-head .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--ink3);
}
.card-head .value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink3);
}

.heatmap-wrap {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.heatmap-wrap::-webkit-scrollbar { display: none; }
.dow-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
  flex-shrink: 0;
}
.dow-col span {
  font-size: 9px;
  color: var(--ink3);
  font-family: var(--mono);
  height: 13px;
  line-height: 13px;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 10px;
  color: var(--ink3);
  font-family: var(--mono);
  letter-spacing: 1.5px;
}
.heatmap-legend .sq {
  width: 11px; height: 11px; border-radius: 2px;
}

.day-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 12px;
}
.day-detail-head .eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--ink3);
}
.day-detail-head .date {
  font-family: var(--serif);
  font-size: 22px;
  margin-top: 2px;
  line-height: 1.1;
}
.day-detail .line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--hair);
}
.day-detail .line .dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.day-detail .line .name {
  flex: 1;
  font-family: var(--serif);
  font-size: 17px;
}
.day-detail .line .val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink3);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.day-detail .line.missed .val { color: var(--ink3); opacity: 0.55; }

/* ─── PROGRESS SCREEN ─────────────────────────── */
.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.metric {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.metric .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--ink3);
  font-family: var(--mono);
}
.metric .num {
  font-family: var(--serif);
  font-size: 48px;
  line-height: 1;
  margin-top: 4px;
}
.metric .num .unit {
  font-family: var(--sans);
  font-size: 22px;
  color: var(--ink3);
}

.chart-card .chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.chart-card .chart-head .t {
  font-family: var(--serif);
  font-size: 20px;
}
.chart-card .chart-head .trend {
  font-family: var(--mono);
  font-size: 11px;
}
.chart-card .chart-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink3);
  letter-spacing: 1px;
}
.chart-card svg { display: block; width: 100%; height: auto; }

.per-habit .t {
  font-family: var(--serif);
  font-size: 20px;
  margin-bottom: 12px;
}
.per-habit .row {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--hair);
}
.per-habit .row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.per-habit .row .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.per-habit .row .name {
  font-family: var(--serif);
  font-size: 19px;
}
.per-habit .row .nums {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink3);
}
.per-habit .row .nums .v7 { font-weight: 600; }
.per-habit .row .nums .sep {
  margin: 0 6px;
  opacity: 0.4;
}
.per-habit .bar {
  height: 6px;
  background: var(--hair);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.per-habit .bar .b30,
.per-habit .bar .b7 {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 3px;
}
.per-habit .bar .b30 { opacity: 0.35; }

/* ─── STREAKS SCREEN ─────────────────────────── */
.streak-card {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 12px;
}
.streak-card .head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}
.streak-card .name {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.1;
}
.streak-card .tier {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink3);
  letter-spacing: 1.5px;
  margin-top: 2px;
  text-transform: uppercase;
}
.streak-card .count {
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1;
  text-align: right;
}
.streak-card .days-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink3);
  letter-spacing: 1.5px;
  text-align: right;
}
.streak-card .progress {
  position: relative;
  height: 4px;
  background: var(--hair);
  border-radius: 2px;
  margin-bottom: 6px;
}
.streak-card .progress .fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 2px;
}
.streak-card .progress-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink3);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.streak-card .stats {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--hair);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.stat .label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink3);
  letter-spacing: 1.5px;
  margin-bottom: 2px;
  text-transform: uppercase;
}
.stat .val {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
}
.stat .val .suffix {
  font-size: 13px;
  color: var(--ink3);
  margin-left: 1px;
}

/* ─── TAB BAR ─────────────────────────────────── */
.tabbar {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 528px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-xl);
  padding: 10px 8px;
  display: flex;
  justify-content: space-around;
  border: 1px solid var(--hair);
  box-shadow: 0 4px 20px rgba(var(--ink-rgb), 0.06);
  z-index: 20;
}
.tabbar button {
  background: transparent;
  border: none;
  padding: 7px 12px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--t-fast) var(--ease-spring),
    background var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out);
}
.tabbar button:active { transform: scale(0.94); }
.tabbar button.active {
  background: var(--ink);
  color: var(--bg);
}
.tabbar button svg { display: block; width: 18px; height: 18px; }
.tabbar button .lbl {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ─── LOGIN ─────────────────────────────────── */
.login {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: min(22vh, 180px) 24px 24px;
  z-index: 40;
}
.login form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}
.login-icon {
  width: 72px; height: 72px;
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
}
.login h1 {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.login .tagline {
  margin: 2px 0 18px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink3);
  letter-spacing: 0.1px;
}
.login input,
.login select {
  background: var(--paper);
  border: 1px solid var(--hair-strong);
  color: var(--ink);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 16px;
  width: 100%;
  font-family: var(--sans);
  transition: border-color var(--t-base) var(--ease-out);
}
.login input:focus,
.login select:focus { outline: none; border-color: var(--ink); }
.login input:focus-visible,
.login select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.login button {
  background: var(--ink);
  border: none;
  color: var(--paper);
  padding: 13px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: var(--sans);
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  letter-spacing: 0.2px;
  transition: transform var(--t-fast) var(--ease-spring);
}
.login button:active { transform: scale(0.97); }
.error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin: 0;
  font-family: var(--mono);
  letter-spacing: 0.5px;
}

/* Ring progress — respects reduced-motion via global override */
.ring-progress {
  transition: stroke-dashoffset var(--t-slow) var(--ease-out);
}

/* ─── Streak celebration modal ──────────────────── */
.celebrate-scrim {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg-deep, #1a1613) 55%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 200ms cubic-bezier(0.2, 0.9, 0.25, 1);
  z-index: 1000;
}
.celebrate-scrim.is-visible { opacity: 1; }
.celebrate-scrim.is-leaving { opacity: 0; }

.celebrate-sheet {
  width: 100%;
  max-width: 340px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-xl, 20px);
  padding: 26px 24px 22px;
  text-align: left;
  box-shadow: 0 18px 60px rgba(0,0,0,0.22);
  transform: translateY(14px) scale(0.96);
  opacity: 0;
  transition: transform 320ms cubic-bezier(0.22, 1.3, 0.36, 1), opacity 220ms ease-out;
}
.celebrate-scrim.is-visible .celebrate-sheet {
  transform: none;
  opacity: 1;
}
.celebrate-scrim.is-leaving .celebrate-sheet {
  transform: translateY(8px) scale(0.98);
  opacity: 0;
}
.celebrate-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink3);
  margin-bottom: 10px;
}
.celebrate-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.02;
  color: var(--ink);
  margin: 0 0 14px;
}
.celebrate-title em {
  font-style: italic;
  color: var(--terracotta);
}
.celebrate-body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink2);
  margin-bottom: 20px;
  max-width: 28ch;
}
.celebrate-close {
  appearance: none;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 12px 22px;
  border-radius: 999px;
  min-height: 44px;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-spring);
}
.celebrate-close:active { transform: scale(0.96); }
.celebrate-close:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .celebrate-scrim, .celebrate-sheet { transition: opacity 100ms linear !important; }
  .celebrate-sheet { transform: none !important; }
}

.sync-status {
  margin-left: 10px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink3);
  letter-spacing: 0.6px;
}
.sync-status.error {
  color: var(--danger);
}

button:disabled,
.login button:disabled {
  cursor: wait;
  opacity: 0.62;
}
