/* DriveTalk — koyu, sakin, araçta bir bakışta okunur arayüz. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #0a0c11;
  --bg-elev: #0e1117;
  --surface: #141821;
  --surface-2: #1a1f2a;
  --surface-3: #232937;
  --border: #242a37;
  --border-strong: #313949;
  --text: #f1f4f9;
  --text-2: #c2c9d6;
  --muted: #8790a2;
  --accent: #7c9cff;
  --accent-strong: #5a78f5;
  --accent-soft: rgba(124, 156, 255, .14);
  --listening: #34d399;
  --thinking: #fbbf24;
  --speaking: #7c9cff;
  --paused: #6b7385;
  --danger: #f87171;
  --good: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --face-top: #2a3142;
  --face-bottom: #1b2030;
  --radius: 18px;
  --radius-sm: 12px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f9;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #f2f4f8;
    --surface-3: #e7eaf1;
    --border: #e3e7ee;
    --border-strong: #d3d9e3;
    --text: #0f1420;
    --text-2: #384052;
    --muted: #6b7487;
    --accent: #4f6ef7;
    --accent-strong: #3b57e0;
    --accent-soft: rgba(79, 110, 247, .1);
    --listening: #059669;
    --thinking: #d97706;
    --speaking: #4f6ef7;
    --paused: #8a93a5;
    --danger: #dc2626;
    --good: #059669;
    --bad: #dc2626;
    --warn: #b45309;
    --face-top: #ffffff;
    --face-bottom: #e8ecf5;
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Üst çubuk ---------- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.header-right { display: flex; gap: 8px; align-items: center; }
.pill {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.pill.live { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.badge { font-size: 11px; font-weight: 800; letter-spacing: .04em; background: var(--warn); color: #111; border-radius: 6px; padding: 3px 7px; }

main { flex: 1; overflow-y: auto; padding: 16px 16px calc(100px + env(safe-area-inset-bottom)); }
body.in-session main { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.view { display: none; max-width: 600px; margin: 0 auto; }
.view.active { display: block; }

/* ---------- Alt menü ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; border: 0; background: none; color: var(--muted);
  font-size: 11.5px; font-weight: 600;
}
.tab-icon { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px; transition: background .2s; }
.tab-icon .icon { width: 22px; height: 22px; }
.tabs button.active { color: var(--text); }
.tabs button.active .tab-icon { background: var(--accent-soft); color: var(--accent); }
body.in-session .tabs { display: none; }

/* ---------- Ortak parçalar ---------- */
.page-title { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 4px 0 4px; font-weight: 750; }
.page-sub { color: var(--muted); margin: 0 0 18px; }
.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); margin: 22px 4px 8px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 10px 2px 0; }

input[type=text], input[type=password], input[type=number], select {
  width: 100%; height: 46px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--accent); }

.btn {
  height: 42px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 0 6px; }
.btn.danger { color: var(--danger); }

.btn-primary {
  width: 100%; height: 60px; margin: 6px 0 4px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff; font-size: 18px; font-weight: 700; letter-spacing: .01em;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .1s, box-shadow .2s, opacity .2s;
}
.btn-primary .icon { width: 22px; height: 22px; }
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .4; box-shadow: none; }
.start-meta { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.warning {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--warn); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin: 10px 0 0;
}

/* ---------- Ana ekran ---------- */
.home { display: flex; flex-direction: column; align-items: stretch; min-height: calc(100dvh - 190px - env(safe-area-inset-bottom)); }
.home-char { align-self: center; position: relative; width: min(48vw, 190px); padding: 0; border: 0; background: none; margin: 8px 0 4px; }
.home-char .char-change {
  position: absolute; right: -6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2);
}
.home-title { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; }
.home-sub { text-align: center; color: var(--muted); margin: 0 0 20px; }
.picker {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; color: var(--text);
}
.picker:active { border-color: var(--border-strong); }
.picker-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex: none; }
.picker-text { flex: 1; min-width: 0; }
.picker-label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.picker-value { display: block; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker > .icon { color: var(--muted); }
.home-actions { margin-top: auto; padding-top: 12px; }
.link-btn { display: block; margin: 10px auto 0; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Alttan açılan paneller ---------- */
dialog.sheet {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: 600px; max-height: 88dvh; margin: 0 auto; padding: 0; border: 0;
  border-radius: 24px 24px 0 0; background: var(--bg-elev); color: var(--text);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .35);
}
dialog.sheet[open] { animation: sheet-up .4s cubic-bezier(.22, 1, .36, 1); }
dialog.sheet.closing { animation: sheet-down .22s ease-in forwards; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
dialog.sheet::backdrop { background: rgba(5, 7, 12, .6); }
dialog.sheet[open]::backdrop { animation: fade-in .3s ease-out; }
dialog.sheet.closing::backdrop { animation: fade-out .22s ease-in forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.sheet-body { padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { font-size: 19px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.sheet-close { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }

.char-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.char-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 12px 10px 14px; border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--surface); color: var(--text);
}
.char-card.selected { border-color: var(--accent); background: linear-gradient(170deg, var(--accent-soft), transparent 70%), var(--surface); }
.char-card .character { width: 100px; }
.char-card b { font-size: 16px; margin-top: 4px; }
.char-card small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.char-card .voice { color: var(--accent); font-size: 11.5px; font-weight: 700; margin-top: 4px; }

/* ---------- Kurulum seçenekleri ---------- */
.topic-group + .topic-group { margin-top: 14px; }
.group-label { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.chip-row {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-inline: 16px;
  margin: 0 -16px; padding: 2px 16px 4px; scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start; height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.input-icon { position: relative; margin-top: 16px; }
.input-icon .icon { position: absolute; left: 14px; top: 13px; color: var(--muted); }
.input-icon input { padding-left: 42px; }

.option + .option { margin-top: 14px; }
.option-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 2px 6px; }
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
}
.segmented button {
  height: 38px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font-weight: 650; font-size: 14px; transition: background .15s, color .15s;
}
.segmented button.active {
  background: var(--surface-3); color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25), inset 0 0 0 1px var(--border-strong);
}

.accordion { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 10px; }
.accordion summary {
  list-style: none; padding: 14px 16px; font-weight: 650; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after {
  content: ''; width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.accordion[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.accordion-body { padding: 0 16px 16px; color: var(--text-2); font-size: 14px; }
.accordion-body p { margin: 10px 0 0; }
.cmd-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cmd-list li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.cmd-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.cmd-list .say { font-weight: 650; color: var(--text); }
.cmd-list .does { color: var(--muted); text-align: right; }

/* ---------- Sohbet sahnesi ---------- */
#live {
  --state: var(--paused);
  display: flex; flex-direction: column; align-items: center;
  min-height: calc(100dvh - 90px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
#live[data-state=listening] { --state: var(--listening); }
#live[data-state=thinking], #live[data-state=summary] { --state: var(--thinking); }
#live[data-state=speaking] { --state: var(--speaking); }

.stage-top { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.state-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--state) 15%, transparent); color: var(--state);
  font-weight: 750; font-size: 15px; transition: color .3s, background .3s;
}
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--state); }
#live[data-state=listening] .state-dot { animation: ping 1.4s ease-out infinite; }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--state) 60%, transparent); }
  100% { box-shadow: 0 0 0 9px transparent; }
}
.timer { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; }

.stage-char { width: min(68vw, 270px); padding: 0; border: 0; background: none; margin: 10px 0 0; }
.state-hint { color: var(--muted); font-size: 14px; margin: 2px 0 0; text-align: center; min-height: 1.5em; }

/* ---------- Karakter ----------
   Durum, kapsayıcıdaki data-state ile gelir. Değişkenler (JS her karede günceller):
   --glow: aktif ses seviyesi, --mic: senin sesin, --sam: karakterin sesi, --open: ağız açıklığı (0–1). */
.character { --state: var(--accent); position: relative; }
#live .character { --state: inherit; }
.char { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 12px 22px rgba(0, 0, 0, .28)); }
.char-glow {
  fill: var(--state); opacity: calc(.08 + var(--glow, 0) * .2);
  transform-origin: 120px 140px; transform: scale(calc(.9 + var(--glow, 0) * .16));
  transition: fill .3s;
}
.char-all { animation: breathe 4.5s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translateY(-2.5px); } }

.char-head { transform-origin: 120px 196px; transition: transform .45s ease; }
.character[data-state=listening] .char-head { transform: rotate(-5deg); }
.character[data-state=thinking] .char-head, .character[data-state=summary] .char-head { transform: rotate(4deg); }
.character[data-state=speaking] .char-head { transform: rotate(calc(var(--sam, 0) * 3deg)) translateY(calc(var(--sam, 0) * -2px)); transition: transform .12s; }
.character[data-state=paused] .char-head { transform: rotate(-3deg) translateY(5px); }

.brow { fill: var(--hair); transform-box: fill-box; transform-origin: center; transition: transform .3s ease; }
.character[data-state=listening] .brow { transform: translateY(-5px); }
.character[data-state=thinking] .brow-l, .character[data-state=summary] .brow-l { transform: translateY(-8px) rotate(-10deg); }
.character[data-state=thinking] .brow-r, .character[data-state=summary] .brow-r { transform: translateY(1px) rotate(8deg); }
.character[data-state=speaking] .brow { transform: translateY(calc(var(--sam, 0) * -8px)); transition: transform .1s; }
.character[data-state=paused] .brow { transform: translateY(3px); }

.char-eyes { fill: var(--eye); transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.eye-shine { fill: #fff; opacity: .9; }
.char-robot .char-eyes { filter: drop-shadow(0 0 4px var(--eye)); }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.char-look { transition: transform .4s ease; }
.character[data-state=listening] .char-look { transform: translate(-3px, 0); }
.character[data-state=thinking] .char-look, .character[data-state=summary] .char-look { transform: translate(5px, -7px); }
.character[data-state=paused] .char-eyes { animation: none; transform: scaleY(.1); }
.char-cheeks { fill: var(--cheek); opacity: .45; }
.char-robot .char-cheeks { opacity: .25; }

.char-smile { opacity: calc(1 - var(--open, 0) * 6); }
.char-mouth {
  transform-box: fill-box; transform-origin: center;
  transform: scaleY(calc(.06 + var(--open, 0) * .94)); opacity: calc(var(--open, 0) * 6);
}
.char-robot .tongue, .char-owl .tongue, .char-owl .char-smile { display: none; }
.char-glasses { fill: rgba(255, 255, 255, .12); stroke: #2b2730; stroke-width: 4; stroke-linecap: round; }
.char-glasses path { fill: none; }

.hand { transition: transform .45s cubic-bezier(.3, 1.35, .5, 1); }
.hand-l { transform: translate(74px, 240px); }
.hand-r { transform: translate(166px, 240px); }
.character[data-state=listening] .hand-l { transform: translate(44px, 128px) rotate(-28deg) scale(calc(1.04 + var(--mic, 0) * .12)); }
.character[data-state=thinking] .hand-r, .character[data-state=summary] .hand-r { transform: translate(142px, 194px) rotate(18deg); }
.character[data-state=speaking] .hand-l { transform: translate(70px, calc(232px - var(--sam, 0) * 32px)) rotate(calc(var(--sam, 0) * -26deg)); transition: transform .12s; }
.character[data-state=speaking] .hand-r { transform: translate(170px, calc(236px - var(--sam, 0) * 20px)) rotate(calc(var(--sam, 0) * 18deg)); transition: transform .12s; }
.character[data-state=idle] .hand-r { animation: wave 7s ease-in-out infinite; }
@keyframes wave {
  0%, 60%, 100% { transform: translate(166px, 240px) rotate(0deg); }
  66% { transform: translate(186px, 148px) rotate(0deg); }
  70% { transform: translate(186px, 148px) rotate(22deg); }
  74% { transform: translate(186px, 148px) rotate(-14deg); }
  78% { transform: translate(186px, 148px) rotate(22deg); }
  82% { transform: translate(186px, 148px) rotate(-6deg); }
  88% { transform: translate(166px, 240px) rotate(0deg); }
}

.blink-light { animation: antenna 1.8s ease-in-out infinite; }
.blink-light.late { animation-delay: .9s; }
@keyframes antenna { 50% { opacity: .35; } }

.char-think, .char-zzz { opacity: 0; transition: opacity .3s; }
.character[data-state=thinking] .char-think, .character[data-state=summary] .char-think { opacity: 1; }
.char-think circle { fill: var(--text); animation: think 1.2s ease-in-out infinite; }
.char-think circle:nth-child(2) { animation-delay: .2s; }
.char-think circle:nth-child(3) { animation-delay: .4s; }
@keyframes think { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.character[data-state=paused] .char-zzz { opacity: 1; }
.char-zzz text { fill: var(--muted); font: 800 20px var(--font); }
.char-zzz text:nth-child(2) { font-size: 24px; }
.char-zzz text:nth-child(3) { font-size: 28px; }

@media (prefers-reduced-motion: reduce) {
  .char-all, .char-eyes, .blink-light, .char-think circle, .character[data-state=idle] .hand-r { animation: none; }
}

/* ---------- Ekran kenarı ses göstergesi ----------
   Her kenarda tek parça bir çubuk; aşağıdan yukarı --level kadar dolar (JS her karede günceller).
   Rengi sesin şiddetiyle değişir: senin sesin camgöbeği → yeşil → sarı → kırmızı,
   karakterin sesi mavi → mor → pembe. */
.edge-meter { position: fixed; top: 0; bottom: 0; width: 10px; z-index: 5; pointer-events: none; display: none; }
body.in-session .edge-meter { display: block; }
.edge-meter.left { left: 0; }
.edge-meter.right { right: 0; }
.edge-meter::before { content: ''; position: absolute; inset: 0; background: var(--surface-3); opacity: .3; }
.edge-meter span {
  --hue: calc(195 - var(--level, 0) * 195);
  --meter-color: hsl(var(--hue) 92% 56%);
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--level, 0) * 100%);
  background: linear-gradient(to top, var(--meter-color), hsl(var(--hue) 100% 74%));
  box-shadow: 0 0 calc(8px + var(--level, 0) * 22px) var(--meter-color);
}
body[data-state=speaking] .edge-meter span { --hue: calc(235 + var(--level, 0) * 95); }
.edge-meter.left span, .edge-meter.left::before { border-radius: 0 6px 6px 0; }
.edge-meter.right span, .edge-meter.right::before { border-radius: 6px 0 0 6px; }

.dialog { width: 100%; display: flex; flex-direction: column; gap: 10px; margin: 14px 0 6px; }
.bubble { margin: 0; padding: 12px 14px 13px; border-radius: 18px; overflow-wrap: anywhere; }
.bubble:empty { display: none; }
.bubble::before { display: block; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; margin-bottom: 3px; }
.bubble.sam {
  align-self: stretch; background: var(--surface); border: 1px solid var(--border);
  border-top-left-radius: 6px; font-size: 19px; line-height: 1.45;
}
.bubble.sam::before { content: attr(data-name); color: var(--speaking); }
.bubble.you {
  align-self: flex-end; max-width: 92%;
  background: color-mix(in srgb, var(--listening) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--listening) 28%, transparent);
  border-top-right-radius: 6px; font-size: 17px;
}
.bubble.you::before { content: 'Sen'; color: var(--listening); }
.tip-line {
  margin: 4px 0 0; padding: 8px 12px; border-radius: 12px; font-size: 14px; font-weight: 600;
  background: color-mix(in srgb, var(--warn) 13%, transparent); color: var(--warn);
}
.tip-line:empty { display: none; }
.noise-line {
  width: 100%; margin: 8px 0 0; padding: 8px 12px 8px 34px; border-radius: 12px; font-size: 13.5px; font-weight: 600; position: relative;
  background: color-mix(in srgb, var(--listening) 12%, transparent); color: var(--listening);
  border: 1px solid color-mix(in srgb, var(--listening) 28%, transparent);
}
.noise-line::before {
  content: ''; position: absolute; left: 12px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  background: currentColor; -webkit-mask: var(--wave-icon) center / contain no-repeat; mask: var(--wave-icon) center / contain no-repeat;
  --wave-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M3 12h2M7 8v8M11 5v14M15 9v6M19 11v2'/%3E%3C/svg%3E");
}
.noise-line.enter { animation: bubble-in .4s cubic-bezier(.34, 1.56, .64, 1); }
.error { color: var(--bad); font-size: 14px; text-align: center; margin: 8px 0 0; }
.error:empty { display: none; }

.type-form { display: flex; gap: 8px; width: 100%; margin-top: 10px; }
.type-form .btn { flex: none; }

.controls { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; padding-top: 16px; }
.btn-control {
  height: 64px; border-radius: 20px; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); font-size: 17px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-control .icon { width: 24px; height: 24px; }
.btn-control:active { transform: scale(.98); }
.btn-control:disabled { opacity: .45; }
.btn-control.danger {
  background: color-mix(in srgb, var(--danger) 13%, var(--surface-2));
  border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger);
}
#pauseBtn .icon-play, #pauseBtn.is-paused .icon-pause { display: none; }
#pauseBtn.is-paused .icon-play { display: block; }
#pauseBtn.is-paused { color: var(--listening); border-color: color-mix(in srgb, var(--listening) 40%, transparent); }

/* ---------- Geçmiş ---------- */
.session-card {
  width: 100%; text-align: left; display: block; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; transition: border-color .15s;
}
.session-card:active { border-color: var(--border-strong); }
.session-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 650; font-size: 16px; }
.session-date { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.stat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stat-chip { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.mode-tag { font-size: 11px; font-weight: 750; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 7px; flex: none; }
.empty-state { text-align: center; color: var(--muted); padding: 56px 20px; }
.empty-state .icon { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 10px; }
.empty-state b { display: block; color: var(--text-2); font-size: 16px; margin-bottom: 4px; }

.detail-head { display: flex; align-items: center; gap: 4px; margin: -4px 0 6px -6px; }
.detail-title { font-size: 21px; font-weight: 750; letter-spacing: -.01em; margin: 0; }
.detail-sub { color: var(--muted); font-size: 13px; margin: 2px 0 14px; }
.summary-card {
  background: linear-gradient(160deg, var(--accent-soft), transparent 70%), var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: var(--radius); padding: 16px;
}
.summary-card p { margin: 0; font-size: 15.5px; line-height: 1.55; }
.focus-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.focus-chips span { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; color: var(--text-2); }

.issue {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warn);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
}
.issue.sev-3 { border-left-color: var(--danger); }
.issue.sev-1 { border-left-color: var(--paused); }
.issue .from { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.issue .to { color: var(--good); font-weight: 700; }
.issue .arrow { color: var(--muted); margin: 0 6px; }
.issue .why { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

.phrase-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.phrase-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; }
.phrase-list .ok { color: var(--good); font-weight: 800; }
.phrase-list .no { color: var(--bad); font-weight: 800; }

.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; padding: 9px 12px; border-radius: 16px; font-size: 14.5px; }
.msg.sam { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 5px; }
.msg.you {
  align-self: flex-end; background: color-mix(in srgb, var(--accent) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-right-radius: 5px;
}
.msg-natural { align-self: flex-end; max-width: 88%; font-size: 13px; color: var(--good); margin: -3px 4px 2px; }
.msg-lookup { align-self: flex-start; font-size: 12px; color: var(--muted); margin: 6px 4px -2px; }
.vocab-example { color: var(--muted); font-size: 13px; font-style: italic; }

/* ---------- İlerleme ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.tile-label { color: var(--text-2); font-size: 13.5px; font-weight: 600; margin-top: 2px; }
.tile-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.bars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; height: 150px; }
.bar-col { display: flex; flex-direction: column; height: 100%; padding: 0; background: none; border: 0; min-width: 0; }
.bar-track { flex: 1; display: flex; align-items: flex-end; border-bottom: 1px solid var(--border-strong); }
.bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-col.active .bar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
.bar-label { color: var(--muted); font-size: 11px; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-readout { color: var(--text); font-size: 14px; font-weight: 600; margin: 10px 0 0; min-height: 1.4em; }

.hbars { display: grid; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 112px 1fr 30px; align-items: center; gap: 10px; font-size: 14px; }
.hbar-label { color: var(--text-2); }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.hbar { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-value { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.vocab-form { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
@media (min-width: 480px) { .vocab-form { grid-template-columns: 1.3fr 1fr auto; } }
.vocab-list { list-style: none; margin: 0; padding: 0; }
.vocab-list li {
  display: flex; gap: 10px; align-items: flex-start; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
}
.vocab-list li.empty-item { display: block; color: var(--muted); text-align: center; }
.vocab-text { flex: 1; min-width: 0; }
.vocab-meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.box-dots { display: inline-flex; gap: 3px; }
.box-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); }
.box-dots i.on { background: var(--accent); }
.vocab-remove { border: 0; background: none; color: var(--muted); padding: 2px 6px; font-size: 20px; line-height: 1; }

/* ---------- Ayarlar ---------- */
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.setting { display: block; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 650; font-size: 14.5px; margin-bottom: 8px; }
.setting-label output { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.setting-desc { display: block; color: var(--muted); font-size: 13px; margin-top: 6px; font-weight: 400; }
.setting .inline { display: flex; gap: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.toggle-row .setting-label { margin: 0; display: block; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0;
  width: 48px; height: 28px; border-radius: 999px; position: relative; cursor: pointer;
  background: var(--surface-3); border: 1px solid var(--border-strong); transition: background .2s, border-color .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .2s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .4; cursor: default; }
.toggle-row:has(.switch:disabled) { cursor: default; }
.test-meter { flex: 1; align-self: center; height: 12px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.test-meter span {
  display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--good), var(--accent));
  transform-origin: left; transform: scaleX(var(--level, 0)); transition: transform .08s linear;
}
.settings-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.focus-list { margin: 0; padding-left: 18px; color: var(--text-2); }
.saved { color: var(--good); min-height: 1.4em; text-align: center; font-weight: 600; margin: 12px 0 0; }

/* ---------- Hareket ve dokunma hissi ----------
   Basınca yaylanan düğmeler, dokunma dalgası (juice.js), sırayla beliren listeler ve geçişler.
   Hepsi transform/opacity ile çalışır; "hareketi azalt" açıksa kapanır. */
:root {
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-12px); } }

/* Basınca küçülüp yayla geri gelme */
.btn, .btn-primary, .btn-control, .picker, .chip, .char-card, .segmented button, .session-card, .sheet-close, .home-char, .stage-char, .link-btn {
  transition: transform .45s var(--spring), background-color .2s, border-color .2s, color .2s, box-shadow .25s, opacity .2s;
}
:is(.btn, .btn-control, .picker, .chip, .char-card, .segmented button, .session-card, .sheet-close, .link-btn):active:not(:disabled) {
  transform: scale(.95); transition-duration: .1s;
}
.btn-primary:active:not(:disabled) { transform: scale(.94); transition-duration: .1s; }
.home-char:active, .stage-char:active { transform: scale(.94); transition-duration: .12s; }
@media (hover: hover) {
  .picker:hover, .char-card:hover, .session-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
  .btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
}

/* Dokunma dalgası */
.btn, .btn-primary, .btn-control, .picker, .chip, .char-card, .segmented button, .session-card, .sheet-close { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .2; transform: scale(0);
  animation: ripple .6s var(--ease-out) forwards;
}
.btn-primary .ripple { background: #fff; opacity: .4; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* Seçici kartlar: ikon döner, ok sağa kayar */
.picker-icon, .picker > .icon { transition: transform .45s var(--spring); }
.picker:active .picker-icon { transform: scale(.86) rotate(-10deg); transition-duration: .12s; }
.picker:active > .icon { transform: translateX(4px); transition-duration: .12s; }

/* Başla: akan renk, parlama, nefes alan hale, zıplayan mikrofon ve ses çubukları */
.start-btn {
  isolation: isolate; height: 66px; gap: 12px; font-size: 19px;
  background: linear-gradient(115deg, var(--accent-strong) 0%, var(--accent) 30%, #a48bff 50%, var(--accent) 70%, var(--accent-strong) 100%) 0 50% / 300% 100%;
  animation: start-flow 7s ease-in-out infinite, start-halo 2.6s ease-out infinite;
}
.start-btn::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .4) 47%, rgba(255, 255, 255, .1) 55%, transparent 68%);
  transform: translateX(-110%); animation: start-shine 4.5s ease-in-out 1.2s infinite;
}
@keyframes start-flow { 50% { background-position: 100% 50%; } }
@keyframes start-halo {
  0% { box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 38%, transparent), 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  70%, 100% { box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 38%, transparent), 0 0 0 16px transparent; }
}
@keyframes start-shine { 0%, 50% { transform: translateX(-110%); } 85%, 100% { transform: translateX(110%); } }
.start-icon { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .2); }
.start-icon::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; border: 2px solid rgba(255, 255, 255, .65);
  animation: mic-ring 2.2s ease-out infinite;
}
.start-icon .icon { animation: mic-bob 2.2s ease-in-out infinite; }
@keyframes mic-ring { to { transform: scale(1.7); opacity: 0; } }
@keyframes mic-bob { 12% { transform: translateY(-2px) rotate(-10deg); } 26% { transform: rotate(8deg); } 40% { transform: none; } }
.start-eq { display: inline-flex; align-items: center; gap: 3px; height: 20px; }
.start-eq i { width: 4px; height: 100%; border-radius: 2px; background: rgba(255, 255, 255, .85); animation: eq 1s ease-in-out infinite; }
.start-eq i:nth-child(2) { animation-delay: -.35s; }
.start-eq i:nth-child(3) { animation-delay: -.7s; }
.start-eq i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
.start-btn:disabled, .start-btn:disabled::after, .start-btn:disabled .start-icon::before, .start-btn:disabled .icon, .start-btn:disabled .start-eq i { animation: none; }
.start-btn:disabled .start-icon::before { opacity: 0; }
.start-btn:disabled .start-eq i { transform: scaleY(.3); }

/* Başla'ya basınca ekrana yayılan renk dalgası */
.launch-burst {
  position: fixed; z-index: 60; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent-strong));
  animation: launch .65s var(--ease-out) forwards;
}
@keyframes launch { 0% { transform: scale(.2); opacity: .95; } 55% { opacity: .5; } 100% { transform: scale(45); opacity: 0; } }

/* Ekranlar ve ana ekran sırayla belirir */
.view.active { animation: fade-in .3s ease-out; }
.home > * { animation: rise .55s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 60ms); }
.character.swap-in { animation: swap-in .65s var(--spring); }
@keyframes swap-in { 0% { opacity: 0; transform: scale(.5) rotate(-10deg); } 60% { opacity: 1; transform: scale(1.06) rotate(3deg); } }
.home-char .char-change { animation: nudge 7s ease-in-out 3s infinite; }
@keyframes nudge { 0%, 88%, 100% { transform: none; } 91% { transform: rotate(-7deg) scale(1.06); } 94% { transform: rotate(6deg) scale(1.06); } 97% { transform: rotate(-3deg); } }

/* Paneller: kartlar ve konular sırayla gelir */
.char-grid .char-card { animation: rise .45s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 45ms + 80ms); }
.char-card.selected { box-shadow: 0 0 0 4px var(--accent-soft); }
.chip-wrap .chip { animation: pop-in .4s var(--spring) backwards; animation-delay: calc(var(--i, 0) * 22ms + 60ms); }
.segmented button.picked { animation: seg-pop .45s var(--spring); }
@keyframes seg-pop { 0% { transform: scale(.88); } 60% { transform: scale(1.04); } }

/* Alt menü: seçilen sekmenin hapı yayla açılır, ikon zıplar */
.tab-icon { position: relative; isolation: isolate; transition: transform .45s var(--spring); }
.tab-icon::before {
  content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--accent-soft);
  transform: scaleX(.3); opacity: 0; transition: transform .45s var(--spring), opacity .2s;
}
.tabs button.active .tab-icon { background: transparent; }
.tabs button.active .tab-icon::before { transform: none; opacity: 1; }
.tabs button.active .tab-icon .icon { animation: icon-hop .5s var(--spring); }
.tabs button:active .tab-icon { transform: scale(.86); transition-duration: .1s; }
@keyframes icon-hop { 35% { transform: translateY(-4px) scale(1.12); } }

/* Anahtarlar: düğme yayla kayar, basınca uzar */
.switch::after { transition: transform .4s var(--spring), width .2s var(--ease-out); }
.switch:active:not(:disabled)::after { width: 26px; }
.switch:checked:active:not(:disabled)::after { transform: translateX(14px); }
.saved:not(:empty) { animation: pop-in .35s var(--spring); }

/* Sohbet sahnesi */
#live .stage-top { animation: drop-in .45s var(--ease-out) backwards; }
#live .stage-char { animation: pop-in .6s var(--spring) .05s backwards; }
#live .controls { animation: rise .5s var(--ease-out) .15s backwards; }
.state-pill.bump { animation: bump .45s var(--spring); }
@keyframes bump { 40% { transform: scale(1.08); } }
.bubble.enter { animation: bubble-in .4s var(--spring); }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(.96); } }
#pauseBtn .icon { animation: icon-pop .4s var(--spring); }
@keyframes icon-pop { from { opacity: 0; transform: scale(.4) rotate(-30deg); } }
#pauseBtn.is-paused { animation: soft-pulse 2s ease-in-out infinite; }
@keyframes soft-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--listening) 20%, transparent); } }

/* Geçmiş ve ilerleme: kartlar sırayla, çubuklar büyüyerek gelir */
.session-card { animation: rise .45s var(--ease-out) backwards; animation-delay: calc(min(var(--i, 0), 10) * 50ms); }
.tiles .tile { animation: rise .45s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 60ms); }
.bar { transform-origin: bottom; animation: grow-y .7s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 50ms + 150ms); }
.hbar { transform-origin: left; animation: grow-x .7s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 60ms + 200ms); }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes grow-x { from { transform: scaleX(0); } }

/* Üst çubuktaki logo: gözler kırpar, anten ışığı yanıp söner (oturumda daha hızlı) */
.logo-eyes { transform-box: fill-box; transform-origin: center; animation: blink 6s infinite; }
.logo-bulb { animation: antenna 2.4s ease-in-out infinite; }
body.in-session .logo-bulb { animation-duration: .9s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
