/* Renkler yalnızca bu değişkenlerden gelir. data-theme'i assets/theme.js atar. */
:root {
  color-scheme: light;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-strong: #e2e8f0;
  --border: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0369a1;
  --accent-hover: #075985;
  --on-accent: #ffffff;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #b91c1c;
  --name-tint: #000000;
  --name-tint-amount: 10%;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.08), 0 4px 14px rgb(15 23 42 / 0.06);
  --radius: 14px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-strong: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --on-accent: #0f172a;
  --danger-bg: #450a0a;
  --danger-border: #7f1d1d;
  --danger-text: #fecaca;
  /* JSON'daki koyu renkler koyu zeminde de okunsun diye isimler açılır. */
  --name-tint: #ffffff;
  --name-tint-amount: 45%;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 14px rgb(0 0 0 / 0.3);
}

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

* {
  margin: 0;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

svg {
  fill: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Marka ve üst çubuk */
.brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand span {
  color: var(--accent);
}

.brand--large {
  font-size: 2.5rem;
  line-height: 1.1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 48rem;
  margin-inline: auto;
  padding: 14px 16px 6px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Düğmeler ve alanlar */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-strong);
}

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

.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

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

.btn--small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9375rem;
}

.btn--block {
  width: 100%;
  min-height: 46px;
}

.icon-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-strong);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Koyu temada güneş (açık temaya geç), açık temada ay görünür. */
.icon-sun,
:root[data-theme="dark"] .icon-moon {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.alert {
  padding: 10px 14px;
  border: 1px solid var(--danger-border);
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-weight: 500;
}

/* Giriş sayfası */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-theme {
  position: fixed;
  top: 14px;
  right: 16px;
}

.login-card {
  width: 100%;
  max-width: 24rem;
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-sub {
  margin: 6px 0 22px;
  color: var(--text-muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.login-card .alert {
  margin-bottom: 14px;
}

/* Ana sayfa */
.page {
  max-width: 48rem;
  margin-inline: auto;
  padding: 0 16px 24px;
}

/* Dinle düğmesi dialog kaydırılırken de erişilebilir kalır. */
.player-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-block: 8px;
  background: var(--bg);
}

.player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-picker {
  grid-column: 1 / -1;
}

.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 9.5rem;
  min-height: 56px;
  padding: 0 22px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.1875rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s;
}

.play-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.play-btn svg {
  width: 26px;
  height: 26px;
}

.icon-pause,
.play-btn.is-playing .icon-play {
  display: none;
}

.play-btn.is-playing .icon-pause {
  display: block;
}

.progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  min-width: 0;
}

.time {
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.seek {
  flex: 1 1 8rem;
  min-width: 0;
  height: 28px;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.seek:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.seek::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--surface-strong) var(--fill, 0%));
}

.seek::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  -webkit-appearance: none;
}

.seek::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.seek::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.seek::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

.page > .alert {
  margin-block: 4px 8px;
}

.practice {
  margin-top: 8px;
}

.modes {
  padding: 0;
  border: 0;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-strong);
}

.segmented label {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  cursor: pointer;
}

.segmented input,
.pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 8px 6px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.15);
}

.segmented input:focus-visible + span,
.pill input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.role-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.role-options,
.role-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Satır ve rol düğmeleri, --speaker'ı JS'ten alır. */
.line,
.pill {
  --speaker-name: var(--speaker);
  --speaker-name: color-mix(in srgb, var(--speaker), var(--name-tint) var(--name-tint-amount));
}

.pill {
  position: relative;
  cursor: pointer;
}

.pill span {
  display: block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--speaker-name);
  font-size: 0.9375rem;
  font-weight: 700;
}

.pill input:checked + span {
  border-color: var(--speaker);
  box-shadow: inset 0 0 0 1px var(--speaker);
}

/* Sohbet balonları */
.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding: 0;
  list-style: none;
}

.line {
  display: flex;
  /* Otomatik kaydırmada satır sabit oynatıcının ve İleri çubuğunun altında kalmasın. */
  scroll-margin-block: 11rem 6rem;
}

.line--right {
  justify-content: flex-end;
}

.bubble {
  max-width: min(84%, 32rem);
  padding: 8px 14px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  background: color-mix(in srgb, var(--speaker) 7%, var(--surface));
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.line--left .bubble {
  border-bottom-left-radius: 4px;
}

.line--right .bubble {
  border-bottom-right-radius: 4px;
}

.bubble[role="button"] {
  cursor: pointer;
}

.bubble[role="button"]:hover {
  border-color: var(--speaker);
}

.bubble-name {
  color: var(--speaker-name);
  font-size: 0.8125rem;
  font-weight: 700;
}

.bubble-text {
  overflow-wrap: anywhere;
  transition: filter 0.2s;
}

/* Bulanıklık satırın yerini korur; açılınca liste zıplamaz. */
.is-hidden .bubble-text {
  filter: blur(7px);
  user-select: none;
  -webkit-user-select: none;
}

.is-current .bubble {
  border-color: var(--accent);
  background: var(--surface-strong);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  box-shadow: 0 0 0 2px var(--accent);
}

.step-bar {
  position: sticky;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step-count {
  margin-right: auto;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.step-bar .btn--primary {
  min-width: 6.5rem;
}

.footer {
  padding: 8px 16px 24px;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}

@media (min-width: 720px) {
  .player {
    grid-template-columns: auto minmax(0, 1fr) 14rem;
  }

  .dialog-picker {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  .play-btn {
    min-width: 7.75rem;
    padding: 0 18px 0 12px;
  }

  .bubble {
    max-width: 90%;
  }

  /* Eşit genişlikte "Tümünü göster" iki satıra kırılıyor. */
  .segmented label {
    flex-basis: auto;
  }

  .role-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
