:root {
  --bg: #0e0c14;
  --surface: #17141f;
  --surface-2: #211c2c;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f7f3ec;
  --muted: #aaa3b9;
  --amber: #ffb547;
  --coral: #ff7a59;
  --magenta: #e2489a;
  --good: #57d6a8;
  --danger: #ff7b7b;
  --spark: linear-gradient(120deg, var(--amber), var(--coral) 55%, var(--magenta));
  /* Category identity (validated for the dark surface: CVD-safe adjacent pairs, 3:1 contrast). */
  --c-feeling: #d55181;
  --c-action: #c98500;
  --c-idea: #3987e5;
  --c-story: #199e70;
  --radius: 18px;
  --gutter: 16px;
  --tabbar: 64px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.app {
  max-width: 560px;
  margin: 0 auto;
}

.screen {
  display: none;
  min-height: 100dvh;
  padding: max(env(safe-area-inset-top), 12px) var(--gutter) calc(var(--tabbar) + max(env(safe-area-inset-bottom), 12px) + 16px);
  padding-left: max(env(safe-area-inset-left), var(--gutter));
  padding-right: max(env(safe-area-inset-right), var(--gutter));
}

.screen.active {
  display: block;
}

#onboarding,
#settings {
  padding-bottom: max(env(safe-area-inset-bottom), 24px);
}

/* ---------- shared */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  margin-bottom: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-title {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.01em;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe1a1, var(--coral) 55%, var(--magenta));
  box-shadow: 0 0 16px rgba(255, 122, 89, 0.6);
  display: inline-block;
}

.brand-mark.big {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  flex: none;
}

.icon-btn.small {
  width: 36px;
  height: 36px;
}

.icon-btn svg,
.chip-btn svg,
.tabbar svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}

.chip-btn svg {
  width: 20px;
  height: 20px;
}

.link-btn {
  border: 0;
  background: none;
  color: var(--amber);
  font-weight: 600;
  min-height: 40px;
  padding: 0 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 15px;
}

.btn.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.btn.primary {
  border: 0;
  background: var(--spark);
  color: #1b1020;
}

.btn.big {
  min-height: 60px;
  font-size: 19px;
  padding: 0 32px;
}

.btn.wide {
  width: 100%;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--danger);
}

.grad-btn {
  border: 1px solid rgba(255, 181, 71, 0.4);
  background: linear-gradient(120deg, rgba(255, 181, 71, 0.16), rgba(226, 72, 154, 0.16));
  min-height: 52px;
  font-size: 17px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

.center {
  text-align: center;
}

.fine {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.grad {
  background: var(--spark);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 28px;
}

.kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

.card-main {
  margin: 0 0 12px;
  font-size: 19px;
  line-height: 1.35;
  font-weight: 600;
}

.card-sub {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.streak {
  color: var(--amber);
  font-size: 13px;
  font-weight: 700;
}

.done-mark {
  color: var(--good);
  font-weight: 700;
}

.done-mark::before {
  content: "✓ ";
}

.done-mark.small {
  font-size: 13px;
}

.section-title {
  margin: 22px 0 10px;
  font-size: 16px;
  color: var(--muted);
  font-weight: 700;
}

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

.section-row .section-title {
  margin: 22px 0 10px;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(255, 181, 71, 0.2), rgba(226, 72, 154, 0.2));
  border: 1px solid rgba(255, 181, 71, 0.4);
  font-weight: 600;
}

.banner.subtle {
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
}

.empty.small {
  padding: 14px 0;
  text-align: left;
  font-size: 14px;
  list-style: none;
}

/* ---------- category identity: colour plus a label, never colour alone */

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.swatch.cat-feeling,
.bar.cat-feeling {
  background: var(--c-feeling);
  fill: var(--c-feeling);
}
.swatch.cat-action,
.bar.cat-action {
  background: var(--c-action);
  fill: var(--c-action);
}
.swatch.cat-idea,
.bar.cat-idea {
  background: var(--c-idea);
  fill: var(--c-idea);
}
.swatch.cat-story,
.bar.cat-story {
  background: var(--c-story);
  fill: var(--c-story);
}

.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  min-width: 74px;
}

.cat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 4px 0 14px;
}

.cat-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.cat-count.zero {
  color: var(--muted);
  opacity: 0.6;
}

/* ---------- onboarding */

.onboard {
  padding: 32px 0 16px;
}

.onboard h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 9vw, 42px);
  line-height: 1.1;
}

.lede {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.choice {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
  display: grid;
  gap: 10px;
}

.choice legend {
  font-weight: 700;
  margin-bottom: 10px;
}

.choice-card {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 2px 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.choice-card:has(input:checked) {
  border-color: var(--amber);
  background: linear-gradient(120deg, rgba(255, 181, 71, 0.1), rgba(226, 72, 154, 0.08));
}

.choice-card input {
  grid-row: span 2;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--amber);
}

.choice-title {
  font-weight: 700;
}

.choice-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.field {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
}

.field > span {
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
}

.field em {
  font-style: normal;
  opacity: 0.7;
}

.field.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

input[type="text"],
input[type="search"],
input[type="url"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 16px; /* 16px stops iOS zooming into the field */
}

input[type="time"],
input[type="date"] {
  width: auto;
}

select {
  width: auto;
  max-width: 52%;
}

textarea {
  resize: none;
  line-height: 1.5;
}

/* ---------- orb */

.orb {
  --level: 0;
  position: relative;
  width: min(52vw, 210px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  flex: none;
}

.orb-core,
.orb-ring {
  position: absolute;
  border-radius: 50%;
}

.orb-core {
  inset: 14%;
  background: radial-gradient(circle at 35% 30%, #ffe3a6 0%, var(--amber) 22%, var(--coral) 55%, var(--magenta) 100%);
  box-shadow:
    0 0 60px rgba(255, 122, 89, 0.45),
    inset 0 -10px 30px rgba(120, 20, 80, 0.45);
  transition:
    transform 90ms linear,
    filter 300ms ease;
}

.orb-ring {
  inset: 0;
  border: 2px solid rgba(255, 181, 71, 0.28);
}

.orb-mic {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 30%;
  height: 30%;
  fill: none;
  stroke: #2a1020;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.orb[data-state="listening"] .orb-ring {
  border-color: rgba(87, 214, 168, 0.75);
  box-shadow: 0 0 30px rgba(87, 214, 168, 0.45);
}

.orb[data-state="speaking"] .orb-core {
  animation: breathe 1.6s ease-in-out infinite;
}

.orb[data-state="thinking"] .orb-ring {
  border: 3px solid transparent;
  border-top-color: var(--amber);
  border-right-color: var(--coral);
  animation: spin 1.1s linear infinite;
}

.orb[data-state="idle"] .orb-core {
  transform: scale(0.85);
  filter: grayscale(0.7) brightness(0.7);
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.95);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- today */

.capture-hero {
  text-align: center;
  padding: 6px 0 18px;
}

.orb-start {
  display: block;
  margin: 6px auto 10px;
}

.orb-start .orb-core {
  animation: breathe 3.2s ease-in-out infinite;
}

.orb-start:active .orb-core {
  transform: scale(0.9);
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
}

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.seg button {
  min-height: 34px;
  min-width: 52px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}

.seg button[aria-checked="true"] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 181, 71, 0.45);
}

.seg.wide {
  display: flex;
  width: 100%;
}

.seg.wide button {
  flex: 1;
  min-width: 0;
  padding: 0 6px;
}

.target-card {
  border-color: rgba(255, 181, 71, 0.28);
}

.target-card s {
  color: var(--muted);
}

/* ---------- lists */

.entry-list,
.content-list,
.drill-list,
.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.entry-row,
.content-row,
.drill-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}

.entry-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.entry-title {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-snippet {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  flex: none;
}

.mood {
  letter-spacing: -2px;
  font-size: 11px;
}

.content-row {
  display: grid;
  gap: 4px;
}

.content-kind {
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.content-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  color: var(--muted);
}

.status-approved {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.3);
}

.status-scheduled {
  color: var(--amber);
  border-color: rgba(255, 181, 71, 0.5);
}

.status-published {
  color: var(--good);
  border-color: rgba(87, 214, 168, 0.5);
}

.filters {
  display: grid;
  gap: 10px;
  margin-bottom: 6px;
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  flex: none;
}

.chip[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface-2);
  border-color: rgba(255, 181, 71, 0.5);
}

/* ---------- coach */

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--spark);
  border-radius: 999px;
  transition: width 400ms ease;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.step.current {
  border-color: rgba(255, 181, 71, 0.45);
}

.step.done .check span {
  color: var(--muted);
  text-decoration: line-through;
}

.check {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  cursor: pointer;
}

.check input {
  width: 22px;
  height: 22px;
  accent-color: var(--good);
  flex: none;
}

.add-row {
  display: flex;
  gap: 8px;
  margin: 10px 0 16px;
}

.toggle-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 30px;
  flex: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background 150ms;
  pointer-events: none;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 150ms;
}

.switch input:checked + span {
  background: rgba(87, 214, 168, 0.35);
}

.switch input:checked + span::after {
  transform: translateX(20px);
  background: var(--good);
}

.switch input:focus-visible + span {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

.drill-row {
  align-items: center;
}

/* ---------- recording overlay */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: max(env(safe-area-inset-top), 20px) var(--gutter) max(env(safe-area-inset-bottom), 20px);
  background: var(--bg);
  text-align: center;
}

.ring-timer {
  position: relative;
  width: min(66vw, 260px);
  aspect-ratio: 1;
}

.ring-timer svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 8;
}

.ring-fg {
  fill: none;
  stroke: var(--amber);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 100ms linear;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
}

.ring-time {
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.level {
  width: 90px;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.level span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--good);
  transition: width 80ms linear;
}

.overlay[data-mode="type"] .level,
.overlay[data-mode="device"] .level {
  visibility: hidden;
}

.live-words {
  min-height: 3em;
  max-width: 32ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.type-box {
  max-width: 480px;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.overlay .fine {
  max-width: 36ch;
  margin: 0;
}

/* ---------- sheet */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  max-width: 560px;
  margin: 0 auto;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: 8px var(--gutter) max(env(safe-area-inset-bottom), 20px);
  animation: rise 180ms ease-out;
}

@keyframes rise {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
}

.sheet-grip {
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  margin: 2px auto 14px;
}

.sheet-title {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.25;
}

.sheet-label {
  margin: 18px 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.sheet-actions .btn.primary {
  margin-left: auto;
}

.transcript {
  background: var(--bg);
  margin-bottom: 8px;
}

.themes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
}

.audio-slot audio {
  width: 100%;
  height: 40px;
  margin: 4px 0;
}

.cat-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cat-chip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  text-align: left;
}

.cat-chip .swatch {
  margin-top: 5px;
}

.cat-chip span {
  display: grid;
  gap: 2px;
}

.cat-chip small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.cat-chip[aria-checked="true"] {
  border-color: var(--text);
  background: var(--surface-2);
}

.cat-chip[aria-checked="true"] strong::after {
  content: " ✓";
}

.mood-row {
  display: flex;
  gap: 6px;
}

.mood-row button {
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 2px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.mood-row button[aria-checked="true"] {
  color: var(--text);
  border-color: var(--amber);
  background: var(--surface-2);
}

.drill-prompt {
  font-size: 19px;
  line-height: 1.45;
  font-weight: 600;
  margin: 0 0 10px;
}

.drill-timer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}

.drill-time {
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 2.2ch;
}

/* ---------- insights */

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.tile {
  display: grid;
  gap: 2px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.tile-value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tile-label {
  color: var(--muted);
  font-size: 13px;
}

.tile-sub {
  color: var(--amber);
  font-size: 12px;
  font-weight: 600;
}

.chart {
  position: relative;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart .axis-zero {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--muted);
  font-size: 10px;
}

.chart .mood-line {
  fill: none;
  stroke: var(--amber);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .mood-dot {
  fill: var(--amber);
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .crosshair {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1;
}

.chart .hit {
  fill: transparent;
}

.chart-tip {
  position: absolute;
  top: -6px;
  transform: translate(-50%, -100%);
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-view {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.table-view summary {
  cursor: pointer;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.table-view table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table-view th,
.table-view td {
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.rank-list li {
  display: grid;
  grid-template-columns: minmax(70px, 34%) 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.rank-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.rank-bar span {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--amber);
}

.rank-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.pipeline > div {
  display: grid;
  justify-items: center;
  gap: 4px;
}

/* ---------- settings */

.set-card {
  display: grid;
  gap: 4px;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 4px 0;
}

.set-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.set-text small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.set-row input[type="url"],
.set-row input[type="password"] {
  max-width: 52%;
}

/* ---------- car mode */

.car {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(env(safe-area-inset-top), 16px) var(--gutter) max(env(safe-area-inset-bottom), 24px);
  background: #07060b;
  text-align: center;
}

.car-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.car-orb {
  width: min(62vw, 280px);
}

.car-status {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
}

.car-line {
  margin: 0;
  max-width: 30ch;
  min-height: 4.5em;
  font-size: 20px;
  line-height: 1.4;
  color: var(--muted);
}

.car-hint {
  margin: 0;
  max-width: 34ch;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- tab bar and toast */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 6px max(env(safe-area-inset-left), 8px) max(env(safe-area-inset-bottom), 8px);
  background: rgba(14, 12, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.tabbar button {
  flex: 1;
  max-width: 112px;
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.tabbar button[aria-current="page"] {
  color: var(--amber);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + max(env(safe-area-inset-bottom), 8px) + 14px);
  transform: translateX(-50%);
  z-index: 60;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 15px;
  line-height: 1.4;
}

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