:root {
  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --primary: #604CC3;
  --primary-hover: #4D3AA8;
  --primary-tint: #B771E5;
  --obsidian: #09080E;
  --ink-surface: #131212;
  --shape: #F5F5F5;

  --accent-danger: #C81E1E;
  --accent-danger-soft: rgba(200, 30, 30, 0.1);
  --accent-ok: #047857;
  --accent-ok-soft: rgba(4, 120, 87, 0.1);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-pill: 100px;
  --tabbar-height: 66px;
  --topbar-height: 62px;
}

html[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-elevated: #F5F5F5;
  --card: #FFFFFF;
  --card-2: #F5F5F5;
  --border: #ECECEC;
  --border-strong: #D6D5DC;
  --text: #09080E;
  --text-muted: #656565;
  --text-soft: #52525B;
  --shadow: none;
  --glass: rgba(255, 255, 255, 0.92);

  /* Mapped editorial accents with >= 4.5:1 WCAG AA contrast on light surfaces */
  --accent-idea: #604CC3;
  --accent-idea-text: #604CC3;
  --accent-idea-soft: rgba(96, 76, 195, 0.1);
  --accent-focus: #09080E;
  --accent-focus-text: #09080E;
  --accent-focus-soft: rgba(9, 8, 14, 0.07);
  --accent-night: #604CC3;
  --accent-night-text: #4D3AA8;
  --accent-night-soft: rgba(96, 76, 195, 0.09);

  --schulte-black-bg: #09080E;
  --schulte-black-text: #FFFFFF;
  --schulte-red-bg: #C81E1E;
  --schulte-red-text: #FFFFFF;
}

html[data-theme="dark"] {
  --bg: #09080E;
  --bg-elevated: #14131B;
  --card: #14131B;
  --card-2: #1C1A26;
  --border: #292736;
  --border-strong: #3E3A52;
  --text: #FFFFFF;
  --text-muted: #A9A7B8;
  --text-soft: #9E9CAF;
  --shadow: none;
  --glass: rgba(9, 8, 14, 0.9);

  --accent-idea: #9B87F5;
  --accent-idea-text: #D6B4FC;
  --accent-idea-soft: rgba(155, 135, 245, 0.16);
  --accent-focus: #B771E5;
  --accent-focus-text: #D6B4FC;
  --accent-focus-soft: rgba(183, 113, 229, 0.15);
  --accent-night: #9B87F5;
  --accent-night-text: #C4B5FD;
  --accent-night-soft: rgba(155, 135, 245, 0.16);
  --accent-ok: #34D399;
  --accent-danger: #F87171;

  --schulte-black-bg: #1C1A26;
  --schulte-black-text: #FFFFFF;
  --schulte-red-bg: #B91C1C;
  --schulte-red-text: #FFFFFF;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

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

input, textarea, select {
  font-size: 16px !important; /* Prevents iOS Safari auto-zoom */
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* =========================================================================
   TOPBAR (Slayed minimalist header)
   ========================================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  height: var(--topbar-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  background: none;
  border: none;
  padding: 6px 0;
  min-height: 44px;
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.04em;
  color: var(--text);
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

.nav-pill {
  background: none;
  border: 1px solid transparent;
  padding: 8px 15px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.nav-pill:hover {
  color: var(--text);
}

.nav-pill.active {
  background: var(--card-2);
  border-color: var(--border);
  color: var(--text);
}

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

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 36px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
}

.streak-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--card);
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--card-2);
}

/* =========================================================================
   MAIN LAYOUT & EDITORIAL TYPOGRAPHY
   ========================================================================= */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 18px calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 32px);
}

.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.stack-md { display: flex; flex-direction: column; gap: 18px; }
.stack-lg { display: flex; flex-direction: column; gap: 26px; }

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

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

/* Editorial Hero (Airy, borderless, crisp divider) */
.editorial-hero {
  padding: 8px 0 18px;
  border-bottom: 1px solid var(--border);
}

.editorial-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.editorial-index {
  color: var(--accent-idea-text);
  font-family: var(--font-mono);
  font-weight: 700;
}

.hero-headline {
  margin: 10px 0 10px;
  font-size: clamp(28px, 6.4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.06;
  color: var(--text);
}

.hero-sub {
  margin: 0;
  max-width: 580px;
  font-size: 15.5px;
  line-height: 1.48;
  color: var(--text-muted);
}

.autopilot-cta {
  margin-top: 18px;
  font-size: 16px;
  font-weight: 750;
  min-height: 52px;
  letter-spacing: -0.015em;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-subtle {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px;
}

/* Slayed Signature Dark Contrast Featured Card */
.featured-cycle-card {
  background: #09080E;
  color: #FFFFFF;
  border: 1px solid #262335;
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  position: relative;
  overflow: hidden;
  background-image: radial-gradient(circle at 92% 10%, rgba(96, 76, 195, 0.36), transparent 48%);
}

.featured-cycle-card .muted {
  color: #B4B2C4;
}

.featured-cycle-card .badge-featured {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #D6B4FC;
  background: rgba(183, 113, 229, 0.14);
  border: 1px solid rgba(183, 113, 229, 0.35);
  padding: 4px 11px;
  border-radius: var(--radius-pill);
}

.hero-card {
  background: var(--card-2);
  border: 1px solid var(--border);
}

.night-banner {
  background: var(--card-2);
  border: 1px solid var(--primary);
}

.h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
}

.h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.24;
}

.h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--text-muted);
  font-size: 14.5px;
}

.small-note {
  color: var(--text-soft);
  font-size: 13px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
}

.kicker-focus { background: var(--accent-focus-soft); color: var(--accent-focus-text); }
.kicker-idea { background: var(--accent-idea-soft); color: var(--accent-idea-text); }
.kicker-night { background: var(--accent-night-soft); color: var(--accent-night-text); }

/* =========================================================================
   PILL BUTTONS (Slayed Signature 100px radius)
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--card);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  transition: transform 0.08s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-white-cta {
  background: #FFFFFF;
  color: #09080E;
  border-color: #FFFFFF;
  font-weight: 750;
}

.btn-white-cta:hover:not(:disabled) {
  background: #EDEAF9;
}

.btn-focus {
  background: var(--obsidian);
  color: #FFFFFF;
  border-color: var(--obsidian);
  font-weight: 700;
}

html[data-theme="dark"] .btn-focus {
  background: #FFFFFF;
  color: #09080E;
  border-color: #FFFFFF;
}

.btn-night {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  font-weight: 700;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--card-2);
}

.featured-cycle-card .btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  border-color: #B771E5;
}

.btn-sm {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  font-size: 13.5px;
}

.btn-block {
  width: 100%;
}

/* =========================================================================
   FORMS & INPUTS (Slayed .contact-input style)
   ========================================================================= */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-label {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text);
}

.input, .textarea, .select {
  width: 100%;
  min-height: 48px;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96, 76, 195, 0.16);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

/* =========================================================================
   PRESET CARDS & CYCLE PILLS
   ========================================================================= */
.section-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.preset-card {
  text-align: left;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 96px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.preset-card:hover {
  border-color: var(--primary);
}

.preset-card.night-card {
  border-color: rgba(96, 76, 195, 0.45);
}

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

.preset-index {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-idea-text);
}

.preset-name {
  font-weight: 750;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--card);
  border: 1px solid var(--border);
}

.badge-amber {
  background: var(--accent-idea-soft);
  color: var(--accent-idea-text);
  border-color: rgba(96, 76, 195, 0.28);
}

.badge-teal {
  background: var(--accent-focus-soft);
  color: var(--accent-focus-text);
  border-color: var(--border-strong);
}

.badge-night {
  background: var(--accent-night-soft);
  color: var(--accent-night-text);
  border-color: rgba(96, 76, 195, 0.3);
}

/* Day Cycle Switcher inside Dark Featured Card */
.cycle-pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cycle-pill {
  min-height: 54px;
  padding: 9px 10px;
  border-radius: 14px;
  border: 1px solid #2A2738;
  background: #14131B;
  color: #FFFFFF;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cycle-pill.active {
  border-color: #B771E5;
  background: rgba(96, 76, 195, 0.34);
}

.cycle-pill-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #B771E5;
}

.cycle-pill.active .cycle-pill-num {
  color: #D6B4FC;
}

.cycle-pill-title {
  font-size: 13.5px;
  font-weight: 750;
  color: #FFFFFF;
}

.cycle-pill-sub {
  font-size: 11.5px;
  color: #B4B2C4;
  overflow-wrap: anywhere;
}

/* =========================================================================
   CHIPS & CHECK-IN SCALE
   ========================================================================= */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 44px;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--card);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.chip.amber.active {
  background: var(--obsidian);
  border-color: var(--obsidian);
  color: #FFFFFF;
}

html[data-theme="dark"] .chip.amber.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.scale-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.scale-btn {
  min-height: 54px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--card-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 750;
  font-size: 16px;
}

.scale-btn small {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.scale-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.scale-btn.selected small {
  color: rgba(255, 255, 255, 0.85);
}

/* =========================================================================
   SESSION PROGRESS & EXERCISES
   ========================================================================= */
.session-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--card-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-tint));
  border-radius: var(--radius-pill);
  transition: width 0.25s ease;
}

/* Breathing Orb */
.breath-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px 10px;
  gap: 16px;
}

.breath-orb {
  width: 172px;
  height: 172px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(183, 113, 229, 0.35), rgba(96, 76, 195, 0.14));
  border: 2px solid var(--primary);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  font-weight: 750;
  font-size: 16px;
  color: var(--text);
  transition: transform 1.2s ease-in-out;
}

.breath-orb.inhale { transform: scale(1.16); }
.breath-orb.topup { transform: scale(1.24); border-color: var(--primary-tint); }
.breath-orb.exhale { transform: scale(0.86); opacity: 0.86; }

/* Gorbov-Schulte Grid */
.schulte-target-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card-2);
  border: 1px solid var(--border);
}

.target-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 17px;
}

.target-pill.black {
  background: var(--schulte-black-bg);
  color: var(--schulte-black-text);
}

.target-pill.red {
  background: var(--schulte-red-bg);
  color: var(--schulte-red-text);
}

.schulte-grid {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.schulte-cell {
  aspect-ratio: 1 / 1;
  min-height: 48px;
  border-radius: 13px;
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-mono);
  border: 1px solid transparent;
  display: grid;
  place-items: center;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.schulte-cell.black {
  background: var(--schulte-black-bg);
  color: var(--schulte-black-text);
}

.schulte-cell.red {
  background: var(--schulte-red-bg);
  color: var(--schulte-red-text);
}

.schulte-cell.done {
  opacity: 0.18;
  transform: scale(0.94);
}

.schulte-cell.wrong {
  animation: shake 0.24s ease;
  box-shadow: 0 0 0 3px var(--primary);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Stroop Switch */
.stroop-rule-banner {
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
}

.stroop-rule-banner.ink {
  background: var(--accent-idea-soft);
  color: var(--accent-idea-text);
  border: 1px solid var(--primary);
}

.stroop-rule-banner.word {
  background: var(--accent-focus-soft);
  color: var(--accent-focus-text);
  border: 1px solid var(--border-strong);
}

.stroop-stimulus {
  min-height: 112px;
  display: grid;
  place-items: center;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.04em;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  user-select: none;
  transition: border-color 0.12s ease;
}

.stroop-stimulus.flash-ok { border-color: var(--accent-ok); }
.stroop-stimulus.flash-err { border-color: var(--accent-danger); }

.stroop-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stroop-opt-btn {
  min-height: 54px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--card);
  font-size: 15.5px;
  font-weight: 750;
}

.stroop-opt-btn:hover {
  border-color: var(--primary);
}

/* RAT & Idea Lists */
.rat-triad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.rat-word {
  padding: 15px 6px;
  border-radius: 13px;
  background: var(--card-2);
  border: 1px solid var(--border);
  text-align: center;
  font-weight: 750;
  font-size: clamp(13px, 3.6vw, 16px);
  overflow-wrap: anywhere;
}

.idea-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.idea-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--card-2);
  border: 1px solid var(--border);
}

.idea-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-idea-text);
  padding-top: 2px;
}

.idea-body {
  flex: 1;
  font-size: 15px;
  word-break: break-word;
}

/* AI Sparring Card */
.sparring-card {
  border-radius: var(--radius-md);
  border: 1.5px solid var(--primary);
  background: var(--card-2);
  padding: 16px;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.score-box {
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  text-align: center;
}

.score-val {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent-idea-text);
}

.score-lbl {
  font-size: 12px;
  color: var(--text-muted);
}

/* KPI & Charts */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kpi-card {
  padding: 15px;
  border-radius: var(--radius-md);
  background: var(--card-2);
  border: 1px solid var(--border);
}

.kpi-val {
  font-size: clamp(17px, 4.6vw, 22px);
  font-weight: 800;
  font-family: var(--font-mono);
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.kpi-lbl {
  font-size: 12.5px;
  color: var(--text-muted);
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
}

/* Accordion */
details.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  padding: 10px 16px;
}

details.accordion summary {
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}

details.accordion summary::-webkit-details-marker {
  display: none;
}

details.accordion[open] summary {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Mobile Tabbar */
.mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.tab-item {
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 650;
  min-height: 48px;
}

.tab-svg {
  width: 20px;
  height: 20px;
}

.tab-item.active {
  color: var(--accent-idea-text);
}

/* Toast */
.toast-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 14px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  background: var(--obsidian);
  color: #FFFFFF;
  border: 1px solid #2A2738;
  border-radius: var(--radius-pill);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.mono { font-family: var(--font-mono); }

/* Voice Mic Button */
.mic-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--card);
  font-size: 17px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.mic-btn.recording {
  border-color: var(--accent-danger);
  background: var(--accent-danger-soft);
  animation: micPulse 1.1s infinite ease-in-out;
}

@keyframes micPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* Quick Business Math */
.math-expr {
  min-height: 112px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: clamp(24px, 6.5vw, 34px);
  font-weight: 800;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  transition: border-color 0.12s ease;
}

.math-expr.flash-ok { border-color: var(--accent-ok); }
.math-expr.flash-err { border-color: var(--accent-danger); }

.math-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.math-opt-btn {
  min-height: 60px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--card);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
}

.math-opt-btn:hover {
  border-color: var(--primary);
}

@media (min-width: 720px) {
  .desktop-nav {
    display: inline-flex;
  }
  .mobile-tabbar {
    display: none;
  }
  .app-main {
    padding: 28px 20px 56px;
  }
  .preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .toast-root {
    bottom: 24px;
  }
}
