@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
  --ink:        #14162E;
  --ink-soft:   #21244A;
  --ink-softer: #2C3060;
  --paper:      #F7F3E9;
  --paper-dim:  #EDE7D6;
  --amber:      #F5A623;
  --amber-dim:  #C9860F;
  --coral:      #E8543E;
  --sage:       #4C9A7E;
  --line:       rgba(247,243,233,0.12);
  --line-soft:  rgba(20,22,46,0.10);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;

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

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
}
body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, textarea, select { font-family: inherit; }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
}
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); line-height: 1.08; }
h2 { font-size: clamp(1.3rem, 4.5vw, 1.6rem); line-height: 1.15; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 1em; color: rgba(247,243,233,0.78); max-width: 62ch; }

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── App shell ─────────────────────────────────────── */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 20px 14px;
  background: linear-gradient(180deg, var(--ink) 70%, rgba(20,22,46,0.85));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}
.brand .mark {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--ink-soft);
  display: grid; place-items: center;
  border: 1.5px solid var(--amber);
}
.brand .mark span { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.ion-counter {
  display: flex; align-items: center; gap: 6px;
  background: var(--ink-soft);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--amber);
}

.app-main {
  padding: 20px 0 96px;
  min-height: calc(100dvh - 130px);
}

/* ── Bottom tab nav (installed-app feel) ──────────────── */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  background: rgba(20,22,46,0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + var(--safe-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none;
  color: rgba(247,243,233,0.5);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--amber); }

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px;
}
.section-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--amber);
  margin: 28px 0 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.section-label .rule { flex: 1; height: 1px; background: var(--line); }
.section-lede { color: rgba(247,243,233,0.55); font-size: 0.85rem; margin: -6px 0 14px; }

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tool-card {
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 16px 14px;
  text-decoration: none;
  color: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 128px;
  transition: border-color .15s ease, transform .15s ease;
}
.tool-card:active { transform: scale(0.98); }
.tool-card .glyph {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.1rem;
}
.tool-card .name { font-weight: 600; font-size: 0.92rem; }
.tool-card .desc { font-size: 0.74rem; color: rgba(247,243,233,0.55); line-height: 1.35; }
.tool-card.locked { opacity: 0.55; }
.tool-card.locked .tag { color: var(--coral); }
.tool-card .tag {
  font-size: 0.63rem; font-weight: 600; color: var(--sage);
  text-transform: none;
}

/* Tint variants for glyph chips, grounded in content groups */
.tint-academic  { background: rgba(245,166,35,0.16); color: var(--amber); }
.tint-performance { background: rgba(232,84,62,0.16); color: var(--coral); }
.tint-holistic  { background: rgba(76,154,126,0.16); color: var(--sage); }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s ease, transform .1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--amber); color: var(--ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--paper); }
.btn-outline:hover { border-color: var(--amber); }
.btn-google { background: var(--paper); color: var(--ink); }
.btn-block + .btn-block { margin-top: 10px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ─────────────────────────────────────────── */
label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; color: rgba(247,243,233,0.8); }
textarea, input[type=text], input[type=email] {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  font-size: 0.95rem;
  resize: vertical;
}
textarea:focus, input:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ── Auth screens ──────────────────────────────────── */
.auth-hero {
  padding: 10vh 0 6vh;
  text-align: left;
}
.auth-hero .eyebrow-orbit {
  width: 46px; height: 46px;
  margin-bottom: 18px;
}
.divider {
  display: flex; align-items: center; gap: 12px;
  color: rgba(247,243,233,0.4);
  font-size: 0.78rem;
  margin: 18px 0;
}
.divider .rule { flex: 1; height: 1px; background: var(--line); }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-s);
  border: 1px solid rgba(232,84,62,0.4);
  background: rgba(232,84,62,0.12);
  color: #FFD3CB;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.alert.success {
  border-color: rgba(76,154,126,0.4);
  background: rgba(76,154,126,0.12);
  color: #CDEEE2;
}

/* ── Chat (Doubt-Buster) ───────────────────────────── */
.chat-log { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.bubble { padding: 12px 14px; border-radius: var(--radius-m); max-width: 88%; font-size: 0.92rem; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--amber); color: var(--ink); border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--ink-soft); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-input-row {
  position: sticky; bottom: 78px;
  display: flex; gap: 8px;
  background: var(--ink);
  padding-top: 8px;
}
.chat-input-row textarea { flex: 1; min-height: 44px; max-height: 120px; }
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 12px;
  background: var(--amber);
  color: var(--ink);
  border: none;
  display: grid; place-items: center;
  cursor: pointer;
}

/* ── Utility ───────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.muted { color: rgba(247,243,233,0.5); font-size: 0.82rem; }
.center { text-align: center; }
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--ink-softer);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--amber);
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(20,22,46,0.25);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.install-banner {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--ink-soft);
  border: 1px solid var(--amber);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  margin: 16px 0;
}
.install-banner.show { display: flex; }
.install-banner .txt { flex: 1; font-size: 0.82rem; }
.install-banner button { flex-shrink: 0; }

.flashcard {
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px;
  min-height: 120px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.05rem;
  cursor: pointer;
}
.flashcard .side-label {
  position: absolute;
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--amber);
  top: 12px; left: 14px;
}
.flashcard-wrap { position: relative; }
.deck-progress { text-align: center; font-size: 0.78rem; color: rgba(247,243,233,0.5); margin-top: 10px; }

/* ── Genesis Diagnostic ────────────────────────────── */
.gd-progress { display:flex; gap:6px; margin-bottom:18px; }
.gd-progress span { flex:1; height:4px; border-radius:2px; background:var(--line); }
.gd-progress span.done { background:var(--amber); }
.likert { display:flex; flex-direction:column; gap:8px; }
.likert p { margin:0; font-size:0.92rem; color:var(--paper); }
.likert input[type=range] {
  -webkit-appearance:none; appearance:none;
  width:100%; height:4px; border-radius:2px;
  background:var(--line); outline:none;
}
.likert input[type=range]::-webkit-slider-thumb {
  -webkit-appearance:none; appearance:none;
  width:20px; height:20px; border-radius:50%;
  background:var(--amber); cursor:pointer; border:none;
}
.likert input[type=range]::-moz-range-thumb {
  width:20px; height:20px; border-radius:50%;
  background:var(--amber); cursor:pointer; border:none;
}
.likert-labels { display:flex; justify-content:space-between; font-size:0.68rem; color:rgba(247,243,233,0.45); }
.pathway-card {
  background:linear-gradient(155deg, rgba(245,166,35,0.16), rgba(76,154,126,0.10));
  border:1px solid rgba(245,166,35,0.35);
}

/* ── Pulse-Check breathing ring ────────────────────── */
.breathe-ring {
  width: 140px; height: 140px;
  margin: 10px auto 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  background: radial-gradient(circle, rgba(245,166,35,0.06), transparent 70%);
}
.breathe-dot {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: var(--amber);
  transform: scale(0.8);
}

/* ── Focus-Forest tree ─────────────────────────────── */
.forest-wrap { display:flex; flex-direction:column; align-items:center; gap:10px; }
.tree-trunk { transform-origin: bottom center; transition: transform 0.6s ease; }
.tree-canopy { transform-origin: center; transition: transform 0.6s ease, opacity 0.6s ease; }
.tree-withered .tree-canopy { filter: grayscale(1) brightness(0.6); opacity: 0.5; }

@media (min-width: 640px) {
  .tool-grid { grid-template-columns: repeat(3, 1fr); }
}