/* Kompis learner app. Visual system taken from the Kompis Lovable design:
   warm cream background, navy ink, Kompis blue and yellow, warm companion orb,
   pastel situation tiles, Fraunces headings, Plus Jakarta Sans body. */
:root {
  --kompis-blue: oklch(0.52 0.17 255);
  --kompis-blue-soft: oklch(0.93 0.04 250);
  --kompis-yellow: oklch(0.87 0.16 90);
  --kompis-navy: oklch(0.25 0.06 260);
  --kompis-peach: oklch(0.9 0.08 65);
  --kompis-orange: oklch(0.75 0.16 50);
  --kompis-ember: oklch(0.65 0.18 40);
  --kompis-lilac: oklch(0.8 0.08 330);
  --scenario-coral: oklch(0.9 0.065 35);
  --scenario-lilac: oklch(0.91 0.045 305);
  --scenario-mint: oklch(0.91 0.045 145);
  --scenario-sun: oklch(0.94 0.065 92);
  --gradient-warm: linear-gradient(160deg, var(--kompis-orange), var(--kompis-ember));

  --bg: oklch(0.975 0.012 85);
  --card: oklch(0.995 0.005 85);
  --ink: var(--kompis-navy);
  --muted: oklch(0.945 0.015 85);
  --muted-ink: oklch(0.45 0.04 260);
  --border: oklch(0.9 0.02 85);
  --input: oklch(0.88 0.02 85);
  --primary: var(--kompis-blue);
  --primary-ink: oklch(0.99 0.005 85);
  --secondary: var(--kompis-blue-soft);
  --accent: var(--kompis-yellow);
  --danger: oklch(0.577 0.245 27.325);

  --radius-3xl: 1.75rem;
  --shadow-soft: 0 12px 40px -16px color-mix(in oklab, var(--kompis-navy) 25%, transparent);
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Plus Jakarta Sans", -apple-system, system-ui, sans-serif;
  --font-accent: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); overflow-x: hidden; }
body { font: 16px/1.5 var(--font-body); }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; flex: none; }
em { font-style: normal; display: block; font-size: .8em; color: var(--muted-ink); font-weight: 400; }
a { color: var(--primary); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: 0; margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: .9rem; }
.error.center { text-align: center; }
.ok { color: var(--primary); min-height: 1.2em; margin: 0; font-size: .9rem; }
.sub { color: var(--muted-ink); margin: 8px 0 0; font-size: .9rem; }
.eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted-ink); margin: 0; }

@keyframes caption-in { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.animate-caption { animation: caption-in .5s ease-out both; }

/* ── Companion ("bloom") ──────────────────── */
.companion { position: relative; width: 132px; height: 132px; }
.c-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid color-mix(in oklab, var(--ink) 10%, transparent); }
.c-core {
  position: absolute; inset: 9%; border-radius: 50%;
  background:
    radial-gradient(55% 55% at 72% 78%, var(--kompis-lilac), transparent 72%),
    radial-gradient(70% 70% at 32% 26%, var(--kompis-peach), transparent 78%),
    radial-gradient(95% 95% at 50% 58%, var(--kompis-orange), var(--kompis-ember));
  box-shadow:
    0 30px 70px -24px color-mix(in oklab, var(--kompis-ember) 55%, transparent),
    inset 0 -14px 34px color-mix(in oklab, var(--kompis-ember) 35%, transparent),
    inset 0 14px 30px color-mix(in oklab, var(--kompis-peach) 65%, transparent);
}
.c-dot { position: absolute; border-radius: 50%; box-shadow: var(--shadow-soft); }
.c-dot-1 { right: 2%; top: 30%; width: 5%; height: 5%; background: var(--accent); }
.c-dot-2 { bottom: 16%; left: 4%; width: 3.5%; height: 3.5%; background: color-mix(in oklab, var(--primary) 40%, transparent); }
.c-core, .c-ring, .c-dot { transition: opacity .4s, transform .4s; }
@keyframes bloom-breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes bloom-pulse { 0%,100% { transform: scale(1); } 30% { transform: scale(1.1); } 60% { transform: scale(.97); } }
@keyframes bloom-spin { to { transform: rotate(360deg); } }
@keyframes bloom-rise { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.companion.listening .c-core { animation: bloom-breathe 4.5s ease-in-out infinite; }
.companion.speaking .c-core { animation: bloom-pulse 1.3s ease-in-out infinite; }
.companion.thinking .c-ring { animation: bloom-spin 3s linear infinite; border-top-color: color-mix(in oklab, var(--kompis-ember) 60%, transparent); }
.companion.thinking .c-core { opacity: .75; }
.companion.calm .c-core { animation: bloom-breathe 6s ease-in-out infinite; }
.companion.calm .c-dot-1 { animation: bloom-rise 3s ease-in-out infinite; }
.companion.listening .c-dot, .companion.speaking .c-dot { animation: bloom-rise 5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .c-core, .c-ring, .c-dot, .animate-caption, .sheet-card { animation: none !important; }
}

/* ── Forms and buttons ────────────────────── */
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
input, select, textarea { font: inherit; font-weight: 400; min-height: 48px; padding: 12px 16px; border: 2px solid var(--input); border-radius: 1rem; background: var(--bg); color: var(--ink); width: 100%; min-width: 0; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: .9rem; }
.check input { width: 20px; min-height: 0; height: 20px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.choice { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.choice legend { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted-ink); margin-bottom: 8px; }
.choice legend em { text-transform: none; letter-spacing: 0; font-size: 11px; }
.choice label { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: inline-flex; gap: 6px; min-height: 44px; align-items: center; padding: 0 16px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow-soft); font-weight: 600; font-size: .9rem; cursor: pointer; }
.choice span em { display: inline; font-size: .78em; }
.choice input:checked + span { background: var(--primary); color: var(--primary-ink); }
.choice input:checked + span em { color: color-mix(in oklab, var(--primary-ink) 75%, transparent); }
.choice input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 48px; font-weight: 600; padding: 0 20px; border-radius: 999px; border: 0; background: var(--card); box-shadow: var(--shadow-soft); cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.big { min-height: 56px; font-size: 1.1rem; width: 100%; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--primary); }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); color: #fff; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .85rem; }

/* ── Auth ─────────────────────────────────── */
.auth { max-width: 28rem; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 20px 40px; }
.auth-hero { text-align: center; display: grid; justify-items: center; margin-bottom: 24px; }
.hero-logo { width: 44px; height: 44px; margin: 4px 0 18px; }
.hero-companion { width: 170px; height: 170px; }
.hero-title { font-size: 1.9rem; line-height: 1.08; margin-top: 26px; text-wrap: balance; }
.auth-lead { font-size: .92rem; color: var(--muted-ink); margin: 14px 0 0; max-width: 22rem; text-wrap: balance; }
.auth-hero .en { font-size: .8rem; color: var(--muted-ink); margin: 2px 0 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--muted); padding: 6px; border-radius: 999px; margin-bottom: 22px; }
.seg-btn { border: 0; background: transparent; min-height: 40px; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--muted-ink); cursor: pointer; }
.seg-btn.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-soft); }
.privacy-note { text-align: center; color: var(--muted-ink); font-size: .8rem; margin-top: 22px; }

/* ── Talk screen ──────────────────────────── */
.talk { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 28rem; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 20px calc(290px + env(safe-area-inset-bottom)); }
.talk-head { width: 100%; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; min-height: 48px; }
.logo-bubble { width: 44px; height: 44px; }
.chip { justify-self: center; border: 0; background: color-mix(in oklab, var(--accent) 50%, transparent); color: var(--ink); font-weight: 500; font-size: .78rem; padding: 5px 16px; border-radius: 999px; cursor: pointer; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage { display: grid; justify-items: center; gap: 8px; margin-top: 14px; }
.status-row { display: flex; align-items: center; gap: 12px; min-height: 36px; }
.status { margin: 0; color: var(--muted-ink); font-size: .9rem; }
.replay { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow-soft); display: grid; place-items: center; cursor: pointer; }
.replay svg { width: 16px; height: 16px; }
.words { width: 100%; display: flex; flex-direction: column; align-items: center; margin-top: 8px; }
.line { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; line-height: 1.35; margin: 0; max-width: 24rem; text-wrap: balance; transition: opacity .3s; }
.talk.thinking .line { opacity: .4; }
.meaning { margin: 8px 0 0; font-size: .9rem; color: var(--muted-ink); max-width: 22rem; text-wrap: balance; }
.you-line { margin: 10px 0 0; font-size: .78rem; color: var(--muted-ink); max-width: 20rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.you-line b { font-weight: 600; letter-spacing: .14em; }
.words .error { margin-top: 10px; }

.dock { position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom)); padding: 16px 20px 0; background: linear-gradient(transparent, var(--bg) 18%); z-index: 10; text-align: center; }
.dock > * { max-width: 24rem; margin-left: auto; margin-right: auto; }
.dock-main { display: flex; justify-content: center; align-items: flex-start; gap: 36px; }
.round-btn { margin-top: 12px; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer; }
.rb-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow-soft); }
.round-btn.accent .rb-icon { background: color-mix(in oklab, var(--accent) 50%, transparent); box-shadow: none; }
.rb-icon svg { width: 20px; height: 20px; }
.rb-label { font-size: 11px; font-weight: 500; color: var(--muted-ink); }
.round-btn:disabled { opacity: .4; }
.mic { position: relative; width: 80px; height: 80px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: var(--primary-ink); background: var(--gradient-warm); box-shadow: var(--shadow-soft), 0 0 0 8px color-mix(in oklab, var(--accent) 25%, transparent); transition: transform .15s; }
.mic:active { transform: scale(.95); }
.mic svg { width: 32px; height: 32px; }
.mic .stop-icon { display: none; width: 28px; height: 28px; }
.mic.on { box-shadow: var(--shadow-soft), 0 0 0 8px color-mix(in oklab, var(--primary) 40%, transparent); animation: mic-pulse 1.6s ease-in-out infinite; }
@keyframes mic-pulse { 50% { opacity: .85; } }
.mic.on .mic-icon { display: none; }
.mic.on .stop-icon { display: block; }
.mic:disabled { opacity: .4; cursor: default; }
.mic-hint { margin: 8px auto 0; font-size: .75rem; color: var(--muted-ink); }
.dock-extra { display: flex; justify-content: center; gap: 6px; margin-top: 8px; white-space: nowrap; }
.mini-btn { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; border: 0; background: transparent; color: var(--muted-ink); font-weight: 600; font-size: .78rem; padding: 0 10px; border-radius: 999px; cursor: pointer; }
.mini-btn svg { width: 15px; height: 15px; }
.mini-btn:hover, .mini-btn[aria-pressed="true"] { background: var(--muted); color: var(--ink); }

.live-toggle { justify-self: end; border: 0; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--muted); color: var(--muted-ink); font-weight: 700; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.live-toggle::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .5; }
.live-toggle[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
.live-toggle[aria-pressed="true"]::before { opacity: 1; background: var(--accent); }
.talk.in-call .mic { background: var(--primary); animation: none; }

.paywall { text-align: center; }
.pw-companion { width: 110px; height: 110px; margin: -8px auto 6px; }
.pw-title { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; margin: 6px 0 8px; }
.pw-text { color: var(--muted-ink); font-size: .92rem; margin: 6px auto; max-width: 22rem; }
.pw-price { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; margin: 14px 0; }
.pw-small { font-size: .78rem; color: var(--muted-ink); margin: 8px 0 0; }
.pw-org { margin-top: 14px; text-align: left; }
.pw-org summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--primary); text-align: center; }
.pw-org form { margin-top: 10px; }
.plan { margin-top: 26px; }
.plan-text { margin: 6px 0 12px; }

/* ── Pages ────────────────────────────────── */
.page { max-width: 28rem; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 20px calc(110px + env(safe-area-inset-bottom)); }
.page h2, .page-title { font-size: 1.6rem; line-height: 1.1; margin-top: 4px; text-wrap: balance; }
.filters { display: flex; gap: 4px; overflow-x: auto; margin: 20px -4px 0; padding: 0 4px 4px; }
.filter { flex: none; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: none; color: var(--muted-ink); font-size: .78rem; font-weight: 600; cursor: pointer; }
.filter.active { background: var(--ink); color: var(--bg); }
.tiles { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { width: 100%; aspect-ratio: 1.02; min-height: 144px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; border: 0; border-radius: var(--radius-3xl); padding: 16px; cursor: pointer; color: var(--ink); transition: transform .1s; }
.tile:active { transform: scale(.98); }
.tile.selected { outline: 2px solid var(--primary); outline-offset: 2px; }
.tile .t-icon { width: 40px; height: 40px; border-radius: 50%; background: color-mix(in oklab, var(--bg) 65%, transparent); display: grid; place-items: center; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.tile .t-icon svg { width: 22px; height: 22px; }
.tile b { display: block; font-size: 1rem; font-weight: 700; line-height: 1.2; }
.tile small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; font-size: 11px; line-height: 1.35; color: color-mix(in oklab, var(--ink) 65%, transparent); }
.tile.coral { background: var(--scenario-coral); }
.tile.lilac { background: var(--scenario-lilac); }
.tile.mint { background: var(--scenario-mint); }
.tile.sun { background: var(--scenario-sun); }
.tile.free { background: var(--secondary); border: 2px dashed color-mix(in oklab, var(--primary) 35%, transparent); }
.tile.free .t-icon { background: var(--primary); color: var(--primary-ink); }

.card-plain { background: var(--card); border-radius: var(--radius-3xl); padding: 18px; box-shadow: var(--shadow-soft); margin-top: 18px; }
.section { margin-top: 26px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; gap: 10px; }
.section-head h3 { font-size: 1.15rem; }

.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius-3xl); padding: 14px 18px; font-weight: 600; box-shadow: var(--shadow-soft); margin-top: 18px; }
.toggle-row input { appearance: none; width: 48px; min-height: 0; height: 28px; border-radius: 999px; background: var(--input); position: relative; cursor: pointer; padding: 0; border: 0; flex: none; transition: background .2s; }
.toggle-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-row input:checked { background: var(--primary); }
.toggle-row input:checked::after { transform: translateX(20px); }
.memory-list { list-style: none; padding: 0; display: grid; gap: 10px; margin: 16px 0; }
.memory-list li { display: flex; gap: 4px; align-items: center; background: var(--card); border-radius: 1.25rem; padding: 4px 6px 4px 4px; box-shadow: var(--shadow-soft); }
.memory-list input { border: 0; background: transparent; min-height: 44px; }
.memory-list .muted { box-shadow: none; background: none; color: var(--muted-ink); padding: 8px 0; }

.conv { background: var(--card); border-radius: 1.25rem; padding: 12px 16px; margin-top: 10px; box-shadow: var(--shadow-soft); }
.conv summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.t-you, .t-kompis { margin: 10px 0; font-size: .92rem; }
.t-you { color: var(--muted-ink); }
.t-you::before { content: "DU · "; font-weight: 600; letter-spacing: .14em; font-size: .72rem; }
.t-kompis { font-family: var(--font-display); font-weight: 600; }
.t-kompis::before { content: "KOMPIS · "; font-family: var(--font-body); font-weight: 600; letter-spacing: .14em; font-size: .72rem; color: var(--primary); }
.danger-zone { margin-top: 26px; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; }

/* ── Tab bar (pill) ───────────────────────── */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 2px; background: var(--muted); padding: 8px; border-radius: 999px; z-index: 20; width: min(22rem, calc(100% - 40px)); }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; border-radius: 999px; padding: 6px 4px; font-size: .75rem; font-weight: 500; color: var(--muted-ink); cursor: pointer; }
.tab-btn svg { width: 16px; height: 16px; }
.tab-btn.active { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-soft); }

/* ── Bottom sheets ────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: color-mix(in oklab, var(--ink) 20%, transparent); backdrop-filter: blur(2px); }
.sheet-card { position: relative; width: 100%; max-width: 28rem; max-height: 85dvh; overflow-y: auto; background: var(--card); border-radius: 2rem 2rem 0 0; padding: 12px 24px max(24px, env(safe-area-inset-bottom)); box-shadow: var(--shadow-soft); animation: sheet-up .3s cubic-bezier(.2,.8,.2,1) both; }
.sheet-card::before { content: ""; display: block; width: 40px; height: 6px; border-radius: 999px; background: var(--muted); margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h3 { font-size: 1.1rem; font-family: var(--font-body); font-weight: 700; }
.icon-btn { border: 0; background: none; border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--muted); }
.icon-btn svg { width: 20px; height: 20px; }
.transcript .empty { color: var(--muted-ink); }
.phrase { display: block; width: 100%; text-align: left; border: 0; background: var(--muted); border-radius: 1.25rem; padding: 14px 16px; margin-bottom: 10px; cursor: pointer; }
.phrase b { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; }
.phrase span { display: block; margin-top: 4px; color: var(--muted-ink); font-size: .85rem; }
.type-row { display: flex; align-items: flex-end; gap: 8px; }
.type-row input { border-radius: 1.5rem; font-size: 1.1rem; min-height: 56px; }
.send { width: 56px; height: 56px; flex: none; border: 0; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; cursor: pointer; }
