:root {
  color-scheme: dark;
  --bg: #141013;
  --bg-soft: #1d171b;
  --panel: #21191e;
  --panel-strong: #2a2026;
  --border: #4a3841;
  --border-strong: #70505d;
  --text: #f3e9df;
  --text-muted: #b8a9a3;
  --accent: #c7475a;
  --accent-soft: #3a222a;
  --gold: #c39a64;
  --focus: #e28a79;
  --shadow: 0 14px 40px rgb(0 0 0 / 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    "Segoe UI",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;
  line-height: 1.55;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: rgb(20 16 19 / 0.96);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 45%, rgb(199 71 90 / 0.34) 46% 54%, transparent 55%),
    var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.brand p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.search {
  position: relative;
  width: min(360px, 46vw);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--text-muted);
  border-radius: 50%;
  transform: translateY(-58%);
  pointer-events: none;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 1.5px;
  right: -5px;
  bottom: -3px;
  background: var(--text-muted);
  transform: rotate(45deg);
  transform-origin: left center;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}

.search input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(199 71 90 / 0.2);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 18px 14px;
  overflow: auto;
  min-width: 0;
}

.sidebar-title {
  margin: 0 8px 10px;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.chapter-group {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.chapter-group h3 {
  margin: 0 8px 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.scene-button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.scene-button:hover {
  background: var(--panel);
  border-color: var(--border);
}

.scene-button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #fff;
}

.content {
  min-width: 0;
  padding: 24px clamp(16px, 4vw, 42px) 56px;
}

.content-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.content-head h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.content-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.line-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.line {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  text-align: left;
}

button.line {
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

button.line:hover {
  border-color: var(--border-strong);
  background: var(--panel-strong);
}

button.line:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(199 71 90 / 0.24);
}

button.line.is-playing {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.speaker {
  flex: 0 0 auto;
  min-width: 64px;
  max-width: 120px;
  padding: 2px 8px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold);
  font-size: 0.78rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}

.read-only .text {
  color: var(--text-muted);
}

.play-indicator {
  flex: 0 0 14px;
  width: 0;
  height: 0;
  margin-top: 8px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid var(--text-muted);
}

.is-playing .play-indicator {
  border-top: 3px solid var(--text);
  border-bottom: 3px solid var(--text);
  border-left: 12px solid var(--text);
  border-right: 12px solid var(--text);
  margin-top: 9px;
  height: 8px;
}

.empty-state,
.search-group-heading {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
}

.search-group-heading {
  border-style: solid;
  border-color: var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    position: static;
  }

  .search {
    width: 100%;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    padding: 10px 12px;
  }

  .sidebar-title {
    display: none;
  }

  .chapter-nav {
    display: flex;
    gap: 8px;
    width: max-content;
    min-width: 100%;
  }

  .chapter-group {
    display: flex;
    gap: 8px;
    margin: 0;
  }

  .chapter-group h3 {
    display: none;
  }

  .scene-button {
    width: auto;
    white-space: nowrap;
  }

  .content {
    padding-top: 18px;
  }

  .content-head {
    flex-direction: column;
    gap: 6px;
  }

  .content-head p {
    white-space: normal;
  }

  .line {
    gap: 9px;
    padding: 11px 12px;
  }

  .speaker {
    min-width: 54px;
  }
}
