:root {
  color-scheme: dark;
  --bg: #101215;
  --panel: #171b20;
  --panel-2: #20262d;
  --text: #f3f0e7;
  --muted: #98a3ad;
  --line: #2d343d;
  --amber: #d4a34e;
  --amber-2: #f0c86b;
  --green: #62c982;
  --red: #d46a5f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(212, 163, 78, 0.08), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  color: var(--text);
  background: var(--panel-2);
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

button.primary,
.novel-tile > button {
  background: var(--amber);
  color: #17120a;
  font-weight: 750;
}

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

button.text-button {
  background: transparent;
  color: var(--amber-2);
}

.app-shell {
  width: min(100vw, 430px);
  min-height: 100vh;
  margin: 0 auto;
  background: #111418;
  position: relative;
  overflow-x: hidden;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.4);
}

.top-bar {
  height: 64px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(17, 20, 24, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.top-bar button {
  min-height: 40px;
  padding: 0;
}

.top-bar div {
  min-width: 0;
}

.top-bar strong,
.top-bar span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-bar span {
  color: var(--muted);
  font-size: 12px;
}

.library-screen,
.settings-screen,
.downloads-screen,
.locked-screen,
.audio-screen,
.reader-screen {
  padding: 16px;
}

.library-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.library-toolbar span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.segmented,
.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  background: #0c0f12;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.segmented button,
.mode-switch button {
  min-height: 36px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active,
.mode-switch button.active {
  background: var(--amber);
  color: #17120a;
  font-weight: 750;
}

.library-list {
  display: grid;
  gap: 12px;
}

.novel-tile {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.novel-tile img {
  width: 76px;
  height: 106px;
  object-fit: cover;
  border-radius: 6px;
}

.novel-tile h2 {
  margin: 0 0 6px;
  font-size: 17px;
  line-height: 1.25;
}

.novel-tile p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.novel-tile > button {
  grid-column: 2;
}

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

.library-grid .novel-tile {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

.library-grid .novel-tile img {
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
}

.library-grid .novel-tile h2 {
  margin-top: 8px;
  font-size: 14px;
}

.library-grid .novel-tile p {
  display: none;
}

.library-grid .novel-tile > button {
  width: 100%;
  margin-top: 8px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badges span,
.success {
  color: var(--green);
}

.badges span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
}

.vn-screen {
  min-height: calc(100vh - 64px);
  position: relative;
  overflow: hidden;
}

.vn-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vn-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.72));
}

.chapter-chip {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  padding: 10px 12px;
  background: rgba(17, 20, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dialogue {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 18px;
  min-height: 180px;
  padding: 14px;
  border: 1px solid rgba(212, 163, 78, 0.42);
  border-radius: 8px;
  background: rgba(15, 17, 20, var(--box-opacity));
  backdrop-filter: blur(10px);
}

.dialogue-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.speaker {
  color: var(--amber-2);
  font-weight: 800;
}

.dialogue p {
  margin: 0;
  padding-bottom: 56px;
  line-height: 1.55;
  font-size: 17px;
}

.dialogue-actions {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.dialogue-step {
  width: 54px;
  min-height: 44px;
  border: 0;
  border-radius: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--amber-2);
  background: transparent;
  pointer-events: auto;
}

.dialogue-step:disabled {
  opacity: 0.28;
}

.side-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.52);
}

.side-panel {
  width: min(76vw, 326px);
  height: 100%;
  background: #11161b;
  border-right: 1px solid var(--line);
  padding: 14px;
  overflow-y: auto;
}

.side-header {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 40px;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.side-header img {
  width: 52px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
}

.side-header span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  max-height: 34px;
  overflow: hidden;
}

.side-settings {
  width: 40px;
  min-height: 40px;
  padding: 0;
  justify-self: end;
}

.mode-switch {
  grid-template-columns: 1fr;
  margin-bottom: 12px;
}

.side-actions {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.chapter-list {
  display: grid;
  gap: 7px;
}

.chapter-row {
  display: block;
  min-height: 56px;
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
}

.chapter-row.active {
  border-color: var(--amber);
  background: rgba(212, 163, 78, 0.1);
}

.chapter-row span,
.chapter-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-row small {
  color: var(--muted);
  margin-top: 3px;
}

.reader-screen {
  font-size: var(--reader-font);
  line-height: 1.75;
}

.reader-screen h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 18px 0;
}

.reader-screen p {
  margin: 0 0 18px;
}

.reader-status {
  display: flex;
  justify-content: space-between;
  color: var(--green);
  font-size: 13px;
}

.audio-screen {
  text-align: center;
}

.audio-cover {
  width: min(72vw, 260px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  margin: 20px auto;
}

.audio-screen h1 {
  font-size: 21px;
  line-height: 1.25;
}

.audio-screen h2 {
  color: var(--muted);
  font-size: 15px;
}

.missing-audio {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: left;
}

.audio-controls {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: 12px;
  margin: 18px 0;
}

.audio-options,
.storage-row,
.download-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  border-top: 1px solid var(--line);
}

.settings-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.settings-section h2 {
  margin: 4px 0 8px;
  font-size: 13px;
  color: var(--amber-2);
  text-transform: uppercase;
}

.settings-row {
  min-height: 50px;
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(90px, 1.3fr) auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.settings-row select,
.settings-row .small {
  width: 100%;
}

.settings-value {
  justify-self: end;
  color: var(--muted);
  font-weight: 650;
  text-align: right;
}

.settings-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(240, 200, 107, 0.45);
  border-radius: 8px;
  color: var(--amber-2);
  background: rgba(240, 200, 107, 0.08);
}

.downloads-screen h1,
.locked-screen h1 {
  font-size: 22px;
}

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

.download-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.download-row div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

progress {
  width: 100%;
  height: 10px;
  accent-color: var(--amber);
}

.locked-screen {
  min-height: calc(100vh - 64px);
  display: grid;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.lock-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border: 1px solid var(--amber);
  border-radius: 50%;
  color: var(--amber-2);
  font-size: 34px;
}

.centered {
  justify-content: center;
}

@media (min-width: 820px) {
  .app-shell {
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
  }
}
