:root {
  color-scheme: light;
  --ink: #111315;
  --muted: #70757d;
  --soft: #f5f6f8;
  --paper: #fbfbfd;
  --panel: #ffffff;
  --line: #e1e4e8;
  --blue: #0a84ff;
  --green: #1f8a70;
  --red: #c74747;
  --shadow: 0 18px 50px rgb(20 24 29 / 10%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.25;
}

input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgb(10 132 255 / 12%);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
}

.library-pane,
.review-pane {
  min-height: 0;
  padding: 22px;
  background: rgb(255 255 255 / 82%);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(20px);
}

.review-pane {
  border-right: 0;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  margin-bottom: 28px;
}

.brand p,
.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.source-card {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.section-title,
.topbar,
.controls-row,
.mark-head,
.mark-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.source-list,
.episode-list,
.mark-list,
.path-list {
  display: grid;
  gap: 10px;
}

.source-item,
.episode-item,
.mark-item,
.empty-state,
.now-card,
.path-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.source-item {
  width: 100%;
  padding: 12px;
  text-align: left;
}

.source-item strong,
.episode-main strong,
.mark-item strong {
  display: block;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.source-item span,
.episode-main span,
.episode-main p,
.mark-item span,
.path-list span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.source-item.active {
  border-color: rgb(10 132 255 / 45%);
  background: rgb(236 246 255);
}

.import-form {
  display: grid;
  gap: 9px;
}

.primary-button,
.icon-button,
.text-button,
.speed-group button,
.mark-button,
.quick-note button,
.mark-actions button,
.jump-button,
.resolve-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.icon-button {
  width: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.player-pane {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.topbar {
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  background: rgb(251 251 253 / 86%);
  backdrop-filter: blur(18px);
}

.topbar h2 {
  max-width: 820px;
  font-size: 22px;
}

.hero-import {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(340px, 1fr);
  align-items: end;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.hero-import h2 {
  margin-bottom: 7px;
  font-size: 19px;
}

.hero-import p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.hero-import-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
}

.hero-import-form input {
  min-height: 46px;
  font-size: 14px;
}

.hero-import-form button {
  min-height: 46px;
}

.import-status {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.import-status[data-type="loading"] {
  color: var(--blue);
}

.import-status[data-type="success"] {
  color: var(--green);
}

.import-status[data-type="error"] {
  color: var(--red);
}

.session-stats,
.review-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.session-stats span,
.review-summary span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.session-stats strong,
.review-summary strong {
  color: var(--ink);
}

.player-surface {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
}

.episode-list-wrap,
.listen-stage {
  min-height: 0;
  min-width: 0;
}

.episode-list {
  max-height: calc(100vh - 132px);
  margin-top: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.episode-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: stretch;
  overflow: hidden;
}

.episode-item.active {
  border-color: rgb(31 138 112 / 52%);
  box-shadow: inset 3px 0 0 var(--green);
}

.episode-item.muted {
  background: #f8f9fa;
}

.episode-main {
  min-width: 0;
  padding: 13px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.episode-main p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.episode-item a {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--line);
  color: var(--muted);
}

.listen-stage {
  display: grid;
  grid-template-rows: auto auto;
  gap: 18px;
  align-content: start;
}

.now-card,
.path-panel {
  min-width: 0;
  padding: 18px;
  box-shadow: var(--shadow);
}

.waveform {
  height: 148px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: center;
  gap: 8px;
  padding: 14px 8px 20px;
}

.waveform span {
  width: 100%;
  border-radius: 8px;
  background: linear-gradient(180deg, #111315, #727780);
}

.waveform span:nth-child(1) { height: 24%; }
.waveform span:nth-child(2) { height: 56%; }
.waveform span:nth-child(3) { height: 38%; }
.waveform span:nth-child(4) { height: 76%; }
.waveform span:nth-child(5) { height: 48%; }
.waveform span:nth-child(6) { height: 86%; }
.waveform span:nth-child(7) { height: 64%; }
.waveform span:nth-child(8) { height: 34%; }
.waveform span:nth-child(9) { height: 72%; }
.waveform span:nth-child(10) { height: 46%; }
.waveform span:nth-child(11) { height: 58%; }
.waveform span:nth-child(12) { height: 28%; }

audio {
  width: 100%;
  margin-bottom: 16px;
}

.speed-group {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.speed-group button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.speed-group button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.mark-button {
  min-width: 118px;
  padding: 0 14px;
  background: var(--blue);
  color: #fff;
}

.mark-button.saved {
  background: var(--green);
}

.quick-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 9px;
  margin-top: 12px;
}

.quick-note button {
  background: var(--ink);
  color: #fff;
}

.path-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: path;
}

.path-list li {
  counter-increment: path;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  column-gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.path-list li::before {
  content: counter(path);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.path-list strong,
.path-list span {
  grid-column: 2;
}

.path-list strong {
  align-self: end;
}

.path-list li.active::before {
  background: var(--green);
  color: #fff;
}

.review-summary {
  margin: 14px 0;
}

.empty-state {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.mark-item {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.mark-item.resolved {
  opacity: 0.62;
}

.sentence-box {
  padding: 12px;
  border-radius: 8px;
  background: rgb(10 132 255 / 7%);
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.55;
}

.sentence-box.empty-sentence {
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.word-chip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted rgb(10 132 255 / 65%);
  cursor: help;
}

.word-chip:hover {
  color: var(--blue);
}

.jump-button {
  min-width: 62px;
  padding: 0 10px;
  background: rgb(10 132 255 / 11%);
  color: var(--blue);
}

.resolve-button {
  min-width: 72px;
  padding: 0 10px;
  background: var(--soft);
  color: var(--muted);
}

.mark-item.resolved .resolve-button {
  background: rgb(31 138 112 / 12%);
  color: var(--green);
}

.mark-actions {
  justify-content: flex-start;
}

.mark-actions button {
  min-height: 32px;
  padding: 0 10px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.site-footer {
  padding: 16px 28px 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--blue);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .review-pane {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 860px) {
  .app-shell,
  .player-surface {
    grid-template-columns: 1fr;
  }

  .library-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .player-pane {
    min-height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-import {
    grid-template-columns: 1fr;
  }

  .hero-import-form {
    grid-template-columns: 1fr;
  }

  .episode-list {
    max-height: none;
  }

  .controls-row {
    align-items: stretch;
    flex-direction: column;
  }

  .mark-button {
    width: 100%;
  }
}
