:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f1f5f8;
  --reader: #fffaf0;
  --line: #e1e7ec;
  --line-strong: #cfd9df;
  --text: #182027;
  --muted: #667582;
  --accent: #146c5f;
  --accent-strong: #0b4e46;
  --accent-soft: #e7f3ef;
  --gold: #b4832f;
  --coral: #b65443;
  --ok: #1d7a4d;
  --warn: #a45d16;
  --shadow: 0 18px 44px rgba(31, 48, 63, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fbfcfd 0, var(--bg) 360px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

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

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card .button {
  width: 100%;
}

.login-card .field {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.login-card input {
  width: 100%;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--coral);
  font-size: 13px;
}

.mobile-back {
  display: none;
}

.mobile-shelf-header,
.mobile-search-panel {
  display: none;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 20px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #16242b;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h2,
.section-head h2,
.chapter-head h2,
.reader-toolbar h2 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.topbar p,
.field label,
.project-meta,
.chapter-meta,
.upload-copy,
#jobDetail,
.section-head p {
  color: var(--muted);
}

.user-panel,
.upload-zone,
.panel,
.controls,
.clone-panel,
.progress-panel,
.player-panel,
.reader-panel,
.chapter-panel,
.admin-workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.user-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.user-panel strong,
.user-panel span {
  display: block;
}

.user-panel span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-user-menu {
  display: none;
}

.upload-zone {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 2px 12px;
  align-items: center;
  padding: 15px;
  border-style: dashed;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone input {
  display: none;
}

.upload-icon {
  grid-row: span 2;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #16242b;
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.upload-title {
  font-weight: 800;
}

.upload-copy {
  font-size: 13px;
}

.panel {
  min-height: 280px;
  padding: 14px;
}

.panel h2 {
  margin-bottom: 12px;
  font-size: 14px;
}

.project-list {
  display: grid;
  gap: 8px;
}

.project-item {
  display: grid;
  grid-template-columns: 42px 1fr 30px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f7f9fa;
  cursor: pointer;
}

.project-item.active {
  border-color: #9bc5bd;
  background: #edf7f3;
}

.project-main,
.project-menu-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.project-main {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  padding: 2px;
  text-align: left;
}

.project-cover {
  position: relative;
  width: 42px;
  height: 56px;
  overflow: hidden;
  border-radius: 6px;
  background: linear-gradient(145deg, var(--accent), #22333a);
  box-shadow: inset -6px 0 0 rgba(255, 255, 255, 0.14);
}

.project-cover-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.project-cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 4px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.cover-progress {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(10, 15, 18, 0.56);
  backdrop-filter: blur(1px);
}

.cover-progress-ring {
  width: min(52%, 46px);
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle closest-side, rgba(13, 19, 22, 0.72) 70%, transparent 72%),
    conic-gradient(#fff1c7 0 82deg, rgba(255, 255, 255, 0.28) 82deg 360deg);
  animation: cover-spin 0.9s linear infinite;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 8px 24px rgba(0, 0, 0, 0.22);
}

.cover-progress-text {
  position: absolute;
  bottom: max(7px, 8%);
  left: 6px;
  right: 6px;
  color: #fff8df;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
}

@keyframes cover-spin {
  to {
    transform: rotate(360deg);
  }
}

.project-title {
  min-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.project-meta {
  margin-top: 4px;
  font-size: 12px;
}

.project-author {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-actions {
  position: relative;
  display: grid;
  place-items: center;
}

.project-menu-button {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
}

.project-menu-button:hover {
  background: #edf2f5;
  color: var(--text);
}

.project-menu {
  position: absolute;
  top: 32px;
  right: 0;
  z-index: 30;
  min-width: 142px;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.project-menu.hidden {
  display: none;
}

.project-menu button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-weight: 800;
}

.project-menu button:hover {
  background: #edf2f5;
}

.project-menu button.danger {
  color: var(--coral);
}

.project-menu button:disabled {
  color: var(--muted);
  cursor: wait;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 100;
  max-width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid rgba(20, 108, 95, 0.22);
  border-radius: 8px;
  background: rgba(244, 251, 248, 0.96);
  color: var(--accent-strong);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 800;
}

.toast.error {
  border-color: rgba(182, 84, 67, 0.25);
  background: rgba(255, 246, 244, 0.97);
  color: var(--coral);
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px clamp(18px, 3vw, 34px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 22px 0 4px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.topbar h2 {
  max-width: 900px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.12;
}

.topbar p {
  margin-top: 8px;
  font-size: 14px;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 380px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(31, 48, 63, 0.06);
}

.status-pill.ok {
  color: var(--ok);
  border-color: #bad7c8;
  background: #f2faf5;
}

.status-pill.warn {
  color: var(--warn);
  border-color: #e2c392;
  background: #fff8e9;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e5c486;
  border-radius: 8px;
  background: #fff8e9;
  color: #65440d;
}

.notice strong {
  display: block;
  margin-bottom: 3px;
}

.book-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2f5;
}

.tab-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 15px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 800;
}

.tab-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 6px 16px rgba(31, 48, 63, 0.08);
}

.tab-panel {
  display: none;
  gap: 14px;
}

.tab-panel.active {
  display: grid;
}

.tab-panel[data-panel="audio"].active {
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 1.05fr) minmax(260px, 1.5fr) minmax(170px, 1fr) minmax(150px, 0.8fr) minmax(120px, 0.7fr);
  gap: 14px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.generate-chapter-panel {
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

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

.span-2 {
  grid-column: span 2;
}

.field label {
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.user-form input,
.user-form select,
.reader-actions select,
.speed-control select {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.field input:focus,
.field select:focus,
.user-form input:focus,
.user-form select:focus,
.reader-actions select:focus,
.speed-control select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 95, 0.12);
}

.field input[type="range"] {
  padding: 0;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.provider-hint {
  display: block;
  min-height: 32px;
}

.inline-check {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-check input {
  min-height: 0;
  width: 16px;
  height: 16px;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  flex-wrap: wrap;
  padding-top: 2px;
}

.button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 800;
}

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

.button.secondary {
  background: #fff;
  color: var(--text);
}

.button.danger {
  border-color: #edc0b8;
  background: #fff5f2;
  color: var(--coral);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.clone-panel {
  display: grid;
  grid-template-columns: 240px auto 1fr;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.file-button {
  display: inline-grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.player-panel {
  position: sticky;
  top: 12px;
  z-index: 4;
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-color: #c9dcd7;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.player-info {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.player-info strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.player-book,
.reader-book {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.speed-control {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.player-panel audio {
  width: 100%;
}

.reader-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.reader-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.reader-toolbar h2 {
  margin: 2px 0 5px;
  font-size: 22px;
}

.reader-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.reader-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.reader-actions select {
  max-width: 280px;
}

.reader-audio-meta {
  width: fit-content;
  max-width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid #c9ddd9;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.reader-text {
  max-height: min(62vh, 780px);
  overflow: auto;
  padding: 28px clamp(18px, 4vw, 54px);
  border: 1px solid #eadfca;
  border-radius: 8px;
  background: var(--reader);
  color: #231f19;
  font-family: ui-serif, Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  font-size: 18px;
  line-height: 1.95;
  white-space: pre-wrap;
}

.progress-panel {
  padding: 16px;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebef;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 160ms ease;
}

.job-history {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.job-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  font-size: 13px;
}

.job-row.active {
  border-color: #91c8c1;
  background: #f0f8f7;
}

.job-status {
  font-weight: 900;
}

.job-note {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.queue-panel {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid #cfe3de;
  border-radius: 8px;
  background: #f5fbf9;
}

.queue-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.queue-head strong {
  color: var(--text);
  font-size: 14px;
}

.queue-list {
  display: grid;
  gap: 6px;
}

.queue-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
}

.queue-row.mine {
  border-color: #91c8c1;
  background: #eef8f6;
}

.queue-status {
  font-weight: 900;
}

.queue-title,
.queue-note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-note {
  color: var(--muted);
}

.selected-chapters {
  display: grid;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.selected-chapters strong {
  font-size: 13px;
}

.selected-chapter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  align-items: center;
}

.selected-chapter-list span,
.selected-chapter-list em {
  max-width: 260px;
  overflow: hidden;
  border: 1px solid #cfe3de;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef8f6;
  color: var(--accent-strong);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-chapter-list.empty {
  color: var(--muted);
  font-size: 13px;
}

.chapter-panel {
  min-height: 420px;
  overflow: hidden;
}

.chapter-head,
.section-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.section-head {
  padding: 0 0 14px;
  border-bottom: 0;
}

.chapter-head h2,
.section-head h2 {
  font-size: 18px;
}

.chapter-head span {
  color: var(--muted);
  font-size: 13px;
}

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

.chapter-row {
  display: grid;
  grid-template-columns: 34px 54px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 66px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.chapter-row:hover {
  background: #fbfcfd;
}

.chapter-row.playing {
  background: #eff8f5;
  box-shadow: inset 3px 0 0 var(--accent);
}

.chapter-row input {
  width: 18px;
  height: 18px;
}

.chapter-index {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.chapter-title {
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-meta {
  margin-top: 3px;
  font-size: 12px;
}

.chapter-audio-meta {
  width: fit-content;
  max-width: 100%;
  margin-top: 5px;
  padding: 3px 7px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-link {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 900;
}

.chapter-play,
.chapter-read {
  min-height: 32px;
  border: 1px solid #bad7c8;
  border-radius: 6px;
  padding: 0 10px;
  background: #f4fbf8;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 900;
}

.chapter-row.playing .chapter-play {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.admin-workspace {
  padding: 18px;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) 160px auto;
  gap: 10px;
  align-items: end;
}

.user-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  font-size: 13px;
}

.user-row strong {
  color: var(--muted);
}

.empty-state {
  padding: 52px 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: 1fr;
  }

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

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    background: #f7f8fb;
  }

  .login-screen {
    min-height: 100dvh;
    padding: 18px;
  }

  .login-card {
    width: 100%;
    padding: 22px;
    box-shadow: 0 14px 36px rgba(31, 48, 63, 0.08);
  }

  .shell {
    height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
  }

  .workspace,
  .sidebar {
    padding: 12px;
  }

  .sidebar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "mobileHeader mobileHeader"
      "mobileSearch mobileSearch"
      "library library";
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }

  .mobile-shelf-header {
    grid-area: mobileHeader;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding-right: 44px;
  }

  .mobile-main-tabs {
    display: flex;
    align-items: baseline;
    gap: 22px;
    min-width: 0;
  }

  .mobile-main-tabs strong {
    font-size: 24px;
    line-height: 1;
    color: #171717;
  }

  .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .mobile-add-book,
  .mobile-search {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #171717;
    font-size: 28px;
    line-height: 1;
    font-weight: 500;
  }

  .mobile-add-book input {
    display: none;
  }

  .mobile-search {
    font-size: 30px;
    transform: rotate(-20deg);
  }

  .mobile-search-panel {
    grid-area: mobileSearch;
    display: grid;
    grid-template-columns: 1fr 36px;
    gap: 8px;
    align-items: center;
  }

  .mobile-search-panel[hidden] {
    display: none;
  }

  .mobile-search-panel input {
    min-width: 0;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 16px;
    background: #f6f7f8;
    font-size: 15px;
    outline: none;
  }

  .mobile-search-panel input:focus {
    border-color: var(--accent);
    background: #fff;
  }

  .mobile-search-panel button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: #f2f2f2;
    color: #555;
    font-size: 20px;
  }

  .brand,
  .upload-zone {
    display: none;
  }

  .user-panel {
    grid-area: mobileHeader;
    justify-self: end;
    align-self: center;
    position: relative;
    z-index: 8;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    display: block;
  }

  .user-panel > div:not(.mobile-user-menu),
  .user-panel > #logoutBtn {
    display: none;
  }

  .mobile-user-menu {
    display: block;
  }

  .mobile-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: #f5f5f5;
    color: #171717;
    font-weight: 900;
    cursor: pointer;
  }

  .mobile-user-dropdown {
    position: absolute;
    top: 46px;
    right: 0;
    z-index: 20;
    width: 168px;
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .mobile-user-dropdown span {
    color: var(--muted);
    font-size: 12px;
  }

  .mobile-user-dropdown .button {
    width: 100%;
  }

  .upload-zone {
    grid-area: upload;
    width: 38px;
    height: 38px;
    min-height: 38px;
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 0;
    border-style: solid;
    border-radius: 999px;
  }

  .upload-icon {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    grid-row: auto;
  }

  .upload-title,
  .upload-copy {
    display: none;
  }

  .sidebar .panel {
    grid-area: library;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .sidebar .panel h2 {
    display: none;
  }

  .project-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(118px, 34vw);
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 2px 2px 4px;
    scrollbar-width: none;
  }

  .project-list::-webkit-scrollbar {
    display: none;
  }

  .project-item {
    height: 236px;
    min-height: 236px;
    grid-template-columns: 1fr 24px;
    grid-template-rows: 148px 1fr;
    align-content: start;
    gap: 8px 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .project-item::before {
    content: none;
  }

  .project-cover {
    grid-column: 1 / -1;
    width: 100%;
    height: 148px;
    margin-bottom: 0;
    border-radius: 6px;
    box-shadow: 0 8px 18px rgba(28, 32, 38, 0.14);
  }

  .project-item.active {
    background: var(--accent-soft);
  }

  .project-main {
    height: auto;
    align-content: start;
    grid-column: 1;
    padding: 0;
  }

  .project-title {
    min-height: 38px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 15px;
    line-height: 1.3;
  }

  .project-meta {
    font-size: 12px;
    color: #a5a5a5;
  }

  .project-author {
    margin-top: 2px;
    font-size: 12px;
    color: #999;
  }

  .project-actions {
    width: 24px;
    height: 24px;
    align-self: start;
    margin-top: 42px;
  }

  .project-menu-button {
    width: 24px;
    height: 24px;
    color: #aaa;
  }

  .project-menu {
    top: 28px;
    right: 0;
  }

  .workspace {
    min-height: 0;
    overflow: hidden;
    gap: 10px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 0;
  }

  .eyebrow,
  #bookMeta {
    display: none;
  }

  .topbar h2 {
    overflow: hidden;
    font-size: 22px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-pill {
    max-width: 100%;
    padding: 6px 9px;
    font-size: 11px;
  }

  .book-tabs {
    width: 100%;
    padding: 4px;
    gap: 4px;
  }

  .tab-button {
    flex: 1 0 auto;
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  .tab-panel.active {
    min-height: 0;
    overflow: hidden;
  }

  .tab-panel[data-panel="audio"].active {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    max-height: calc(100dvh - 174px);
    overflow-y: auto;
    padding-right: 2px;
  }

  .controls,
  .clone-panel,
  .user-form {
    grid-template-columns: 1fr;
  }

  .tab-panel[data-panel="audio"].active .controls {
    grid-template-columns: 1fr 1fr;
  }

  .tab-panel[data-panel="audio"].active .controls .field:first-child,
  .tab-panel[data-panel="audio"].active .controls .span-2,
  .tab-panel[data-panel="audio"].active .controls .actions {
    grid-column: 1 / -1;
  }

  .controls {
    padding: 12px;
    gap: 10px;
  }

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

  .player-info,
  .reader-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .reader-text {
    max-height: calc(100dvh - 360px);
    padding: 16px;
    font-size: 16px;
  }

  .chapter-panel {
    min-height: 0;
    height: 100%;
  }

  .chapter-head {
    min-height: 44px;
    padding: 0 12px;
  }

  .selected-chapters {
    padding: 9px 12px;
  }

  .selected-chapter-list {
    max-height: 72px;
    overflow: auto;
  }

  .selected-chapter-list span,
  .selected-chapter-list em {
    max-width: 100%;
  }

  .chapter-list {
    max-height: calc(100dvh - 354px);
  }

  .generate-chapter-panel .chapter-list {
    min-height: 240px;
    max-height: calc(100dvh - 442px);
    overflow: auto;
  }

  .generate-chapter-panel {
    min-height: 0;
    height: auto;
  }

  .chapter-row {
    grid-template-columns: 30px 44px minmax(0, 1fr);
    min-height: 58px;
    padding: 9px 12px;
  }

  .chapter-actions {
    grid-column: 3;
    flex-wrap: wrap;
  }

  .chapter-audio-meta {
    max-width: 180px;
  }

  .player-panel {
    position: static;
    padding: 10px 12px;
  }

  .progress-panel,
  .admin-workspace {
    max-height: calc(100dvh - 330px);
    overflow: auto;
    padding: 12px;
  }

  .queue-row {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .queue-note {
    grid-column: 2;
  }
}

@media (max-width: 680px) {
  .app-shell:not(.book-open) {
    grid-template-rows: 1fr;
  }

  .app-shell:not(.book-open) .workspace {
    display: none;
  }

  .app-shell.book-open {
    grid-template-rows: 1fr;
  }

  .app-shell.book-open .sidebar {
    display: none;
  }

  .app-shell.book-open .workspace {
    display: flex;
    height: 100dvh;
  }

  .app-shell.book-open .tab-panel.active {
    flex: 1;
    min-height: 0;
  }

  .app-shell.book-open .tab-panel[data-panel="audio"].active {
    display: grid;
    flex: 1 1 auto;
    overflow-y: auto;
  }

  .app-shell.book-open .tab-panel[data-panel="read"].active {
    grid-template-rows: auto 1fr;
  }

  .app-shell.book-open .chapter-panel {
    min-height: 0;
    height: 100%;
  }

  .app-shell.book-open .chapter-list {
    height: 100%;
    max-height: none;
  }

  .app-shell.book-open .tab-panel[data-panel="audio"].active .chapter-list {
    height: auto;
    max-height: calc(100dvh - 442px);
  }

  .app-shell:not(.book-open) .sidebar {
    height: 100dvh;
    grid-template-rows: auto auto 1fr;
    align-content: start;
    padding: 14px;
  }

  .app-shell:not(.book-open) .project-list {
    height: 100%;
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: initial;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: start;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0 10px;
  }

  .app-shell:not(.book-open) .project-item {
    height: 236px;
    min-height: 236px;
    grid-template-columns: 1fr 22px;
    border-radius: 8px;
  }

  .app-shell:not(.book-open) .project-cover {
    width: 100%;
    height: 148px;
  }

  .app-shell:not(.book-open) .project-title {
    min-height: 39px;
    font-size: 15px;
  }

  .app-shell:not(.book-open) .project-meta {
    display: none;
  }

  .mobile-back {
    min-height: 34px;
    width: fit-content;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 12px;
    background: #fff;
    color: var(--accent-strong);
    font-weight: 900;
  }

  .app-shell:not(.book-open) .mobile-back {
    display: none;
  }

  .app-shell.book-open .topbar {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .app-shell.book-open .topbar .status-pill {
    grid-column: 1 / -1;
  }

  .login-card {
    display: flex;
    flex-direction: column;
  }

  .login-card .brand {
    align-items: center;
  }
}
