:root {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #EFECE4;
  --text: #1B1F33;
  --muted: #6B6F80;
  --line: #E2DED3;
  --navy: #1E2A5A;
  --navy-2: #2C3B78;
  --coral: #FF7A59;
  --coral-ink: #C2482A;
  --mint: #2FBF83;
  --mint-soft: #DDF6EA;
  --coral-soft: #FFE6DE;
  --warn: #B7791F;
  --on-navy: #FFFFFF;
  --shadow: 0 1px 2px rgba(27, 31, 51, .06), 0 6px 20px rgba(27, 31, 51, .06);
  --radius: 18px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12152A;
    --surface: #1B1F3A;
    --surface-2: #242A4A;
    --text: #ECEEF7;
    --muted: #9AA0BC;
    --line: #2E3456;
    --navy: #8FA2F0;
    --navy-2: #A9B7F5;
    --coral-ink: #FF9C82;
    --mint-soft: #173A30;
    --coral-soft: #3D2522;
    --on-navy: #12152A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
a { color: var(--navy); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 800; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- üst çubuk ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 800; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.course { color: var(--muted); font-size: .875rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.install {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 8px 14px;
  background: var(--coral); color: #fff; font: inherit; font-weight: 700; font-size: .875rem; cursor: pointer;
}
.install svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- görünüm ---------- */
.view { max-width: 960px; margin: 0 auto; padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
.view.bare { padding-bottom: 32px; }

/* ---------- alt sekmeler ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 12px; text-decoration: none; color: var(--muted); font-size: .75rem; font-weight: 700;
}
.tabbar a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--navy); background: var(--surface-2); }

/* ---------- bileşenler ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 14px; border: 1px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--navy); color: var(--on-navy);
}
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn.coral { background: var(--coral); color: #fff; }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.danger { background: transparent; color: var(--coral-ink); border-color: var(--line); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.chip.level { background: var(--mint-soft); color: #1B8A5C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.level { color: #6FE0AE; } }
.chip.coral { background: var(--coral-soft); color: var(--coral-ink); }

label { display: block; font-weight: 700; font-size: .875rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--navy) 35%, transparent); outline-offset: 1px; }
.field + .field { margin-top: 12px; }
.form-error { color: var(--coral-ink); font-weight: 700; min-height: 1.5em; margin-top: 8px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .8125rem; font-weight: 600; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  text-decoration: none; color: inherit;
}
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: .8125rem; }
.item.link:hover { border-color: var(--navy); }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* ---------- giriş ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 400px; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 12px; }
.login h1 { text-align: center; }
.login p.lead { text-align: center; color: var(--muted); }

/* ---------- öğrenci ana sayfa ---------- */
.hero {
  background: var(--navy); color: #fff; border-radius: 24px; padding: 22px;
  display: grid; gap: 14px; position: relative; overflow: hidden;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: #26306A; } }
.hero h1 { color: #fff; }
.hero p { color: rgba(255, 255, 255, .8); margin: 0; }
.hero .btn { background: var(--coral); color: #fff; justify-self: start; min-height: 52px; padding: 12px 22px; font-size: 1.05rem; }
.hero .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.hero .meta .chip { background: rgba(255, 255, 255, .14); color: #fff; }

.scenario { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; text-align: left; font: inherit; }
.scenario:hover { border-color: var(--navy); }
.scenario .title { font-weight: 800; }
.scenario .desc { color: var(--muted); font-size: .875rem; }

/* ---------- konuşma ekranı ---------- */
.talk { display: grid; grid-template-rows: auto 1fr auto; gap: 16px; min-height: calc(100dvh - 90px); }
.talk-head { display: flex; align-items: center; gap: 12px; }
.talk-head .grow { flex: 1; min-width: 0; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--muted); }
.timer.warn { color: var(--coral-ink); }

.orb-wrap { display: grid; place-items: center; padding: 8px 0; }
.orb {
  width: 168px; height: 168px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--navy-2), var(--navy));
  display: grid; place-items: center; position: relative;
  box-shadow: 0 10px 40px color-mix(in srgb, var(--navy) 35%, transparent);
  transition: transform .15s;
}
.orb:active { transform: scale(.97); }
.orb img { width: 92px; height: 92px; border-radius: 22px; }
.orb::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 4px solid var(--mint); opacity: 0; transform: scale(calc(1 + var(--lvl, 0) * .25));
  transition: transform .08s linear, opacity .2s;
}
.orb.listening::after { opacity: .9; }
.orb.speaking::after { border-color: var(--coral); opacity: .9; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .orb.speaking::after { animation: none; } }
.talk-state { text-align: center; font-weight: 800; margin-top: 14px; }
.talk-hint { text-align: center; color: var(--muted); font-size: .875rem; }
.headphones { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-weight: 600; color: var(--muted); }
.headphones input { width: 20px; height: 20px; min-height: 0; accent-color: var(--navy); }

.captions { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 38dvh; padding: 4px 2px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px; line-height: 1.4; }
.bubble.tutor { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.student { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 6px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bubble.student { background: #2C3B78; } }

/* ---------- geri bildirim ---------- */
.scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.score { text-align: center; padding: 12px 6px; border-radius: 14px; background: var(--surface-2); }
.score b { display: block; font-size: 1.4rem; font-weight: 800; }
.score span { font-size: .75rem; color: var(--muted); font-weight: 700; }
.fix { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.fix .was { text-decoration: line-through; color: var(--coral-ink); }
.fix .now { color: var(--text); font-weight: 700; }
.fix .why { color: var(--muted); font-size: .875rem; margin-top: 4px; }
.vocab { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.vocab .card { padding: 12px 14px; }
.vocab .word { font-weight: 800; }
.vocab .ex { color: var(--muted); font-size: .875rem; font-style: italic; }
ul.plain { margin: 0; padding-left: 1.2rem; }
.transcript { display: flex; flex-direction: column; gap: 6px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; background: var(--mint); border-radius: 6px 6px 0 0; min-height: 4px; position: relative; }
.bars div span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: .6875rem; color: var(--muted); font-weight: 700; }

/* ---------- tablo ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

.code { font: 800 1.8rem/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .18em; text-align: center; padding: 14px; border-radius: 14px; background: var(--surface-2); }

/* ---------- alt pencere ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(10, 12, 28, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 22px; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; max-width: calc(100% - 32px); }

.ios-steps { display: grid; gap: 10px; margin: 12px 0 16px; padding: 0; list-style: none; counter-reset: s; }
.ios-steps li { display: flex; gap: 10px; align-items: center; }
.ios-steps li::before { counter-increment: s; content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; }
.ios-steps svg { width: 20px; height: 20px; vertical-align: -4px; fill: none; stroke: var(--navy); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 900px) {
  .tabbar { top: 64px; bottom: auto; left: 0; right: auto; width: 96px; height: calc(100dvh - 64px); flex-direction: column; justify-content: flex-start; gap: 6px; padding: 16px 8px; border-top: 0; border-right: 1px solid var(--line); }
  .view { padding-left: 120px; padding-bottom: 40px; max-width: 1080px; }
  .view.bare { padding-left: 16px; max-width: 720px; }
  .toast { bottom: 24px; }
}
