:root {
  color-scheme: dark;
  --bg: #0a0d0f;
  --panel: #11171a;
  --panel-strong: #182126;
  --line: #273138;
  --text: #f3f0e8;
  --muted: #9ca8ad;
  --soft: #c6cbd0;
  --teal: #37d6c2;
  --amber: #e8a84f;
  --red: #d15e67;
  --green: #86c06a;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 5%, rgba(55, 214, 194, 0.12), transparent 28rem),
    linear-gradient(135deg, #0a0d0f 0%, #12171b 48%, #090b0e 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.loading-screen,
.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(960px, 100%);
}

.brand-mark {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 1px solid rgba(55, 214, 194, 0.35);
  background: rgba(55, 214, 194, 0.1);
  color: var(--teal);
  font-weight: 800;
  letter-spacing: 0;
}

.login-panel .brand-mark {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: clamp(2.4rem, 7vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.lede {
  max-width: 640px;
  color: var(--soft);
  font-size: 1.05rem;
  line-height: 1.65;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 34px 0 18px;
}

.account-card,
.book-card,
.series-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(17, 23, 26, 0.88);
  box-shadow: var(--shadow);
}

.account-card {
  min-height: 144px;
  padding: 22px;
  color: var(--text);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.account-card:hover,
.account-card.active {
  border-color: rgba(55, 214, 194, 0.55);
  background: rgba(24, 33, 38, 0.95);
  transform: translateY(-2px);
}

.account-avatar {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 50%;
  background: var(--amber);
  color: #14100a;
  font-weight: 900;
}

.account-card:nth-child(2) .account-avatar {
  background: var(--teal);
  color: #061615;
}

.account-name {
  display: block;
  margin-bottom: 6px;
  font-size: 1.2rem;
  font-weight: 800;
}

.account-hint,
.muted {
  color: var(--muted);
}

.login-form {
  display: flex;
  max-width: 520px;
  gap: 10px;
}

.login-form input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b0d;
  color: var(--text);
  outline: 0;
  padding: 14px 15px;
}

.login-form input:focus {
  border-color: var(--teal);
}

.primary-button,
.ghost-button,
.tool-button,
.timer-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 800;
}

.primary-button {
  background: var(--teal);
  color: #041311;
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
}

.tool-button {
  border: 1px solid var(--line);
}

.timer-button {
  border: 1px solid var(--line);
  background: #0c1114;
}

.timer-button.active {
  border-color: var(--amber);
  color: var(--amber);
}

.error {
  min-height: 22px;
  margin-top: 12px;
  color: #ff9aa1;
}

.library-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 13, 15, 0.88);
  padding: 16px clamp(18px, 4vw, 48px);
  backdrop-filter: blur(18px);
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  margin: 0;
  font-weight: 900;
}

.topbar-subtitle {
  color: var(--muted);
  font-size: 0.86rem;
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 42px clamp(18px, 4vw, 34px) 80px;
}

.series-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.65fr);
  gap: 24px;
  align-items: stretch;
}

.series-hero {
  min-height: 520px;
  padding: clamp(28px, 6vw, 56px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(145deg, rgba(55, 214, 194, 0.14), transparent 34%),
    linear-gradient(20deg, rgba(209, 94, 103, 0.1), transparent 42%),
    #101519;
}

.series-hero h1 {
  margin-bottom: 22px;
}

.series-meta,
.book-meta,
.chapter-meta,
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.pill {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--soft);
  font-size: 0.86rem;
}

.series-card {
  display: flex;
  min-height: 520px;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
}

.progress-track {
  overflow: hidden;
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: #07090b;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-box {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 900;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.book-card {
  display: flex;
  min-height: 280px;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
}

.book-number {
  color: var(--amber);
  font-weight: 900;
}

.book-title {
  margin: 8px 0;
  font-size: 1.25rem;
}

.book-description {
  display: -webkit-box;
  overflow: hidden;
  color: var(--soft);
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.book-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(300px, 0.55fr);
  gap: 22px;
}

.player-panel,
.chapters-panel {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(17, 23, 26, 0.9);
  box-shadow: var(--shadow);
}

.player-panel {
  padding: clamp(22px, 5vw, 40px);
}

.chapters-panel {
  overflow: hidden;
}

.now-playing {
  min-height: 260px;
  margin: 24px 0;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(145deg, rgba(232, 168, 79, 0.16), transparent 38%),
    linear-gradient(25deg, rgba(55, 214, 194, 0.12), transparent 45%),
    #0c1013;
}

.now-playing-title {
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.seek-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.control-row,
.timer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chapter-select {
  width: 100%;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b0d;
  color: var(--text);
  padding: 13px;
}

.chapter-list {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.chapter-button {
  display: grid;
  width: 100%;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: transparent;
  color: var(--text);
  padding: 14px 16px;
  text-align: left;
}

.chapter-button:hover,
.chapter-button.active {
  background: rgba(55, 214, 194, 0.08);
}

.chapter-time {
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 800;
}

.chapter-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .series-stage,
  .player-layout {
    grid-template-columns: 1fr;
  }

  .series-hero,
  .series-card {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .account-grid,
  .login-form,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .account-grid,
  .login-form {
    display: grid;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

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

  .seek-row {
    grid-template-columns: 1fr;
  }
}
