:root {
  color-scheme: light;
  --bg: #f6f3eb;
  --paper: #fffdf7;
  --ink: #1c1b18;
  --muted: #6f685e;
  --line: #d7cfbf;
  --accent: #2f6f73;
  --accent-dark: #24575a;
  --danger: #9a3f34;
  --shadow: 0 18px 45px rgba(37, 31, 22, 0.12);
  --topbar: rgba(246, 243, 235, 0.92);
  --input-bg: #fff;
  --button-ink: #fff;
  --reader-font-size: 1.22rem;
  --reader-line-height: 1.78;
  --reader-width: 920px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101820;
  --paper: #17212b;
  --ink: #f1eadf;
  --muted: #a99f91;
  --line: #32404b;
  --accent: #4c9a9f;
  --accent-dark: #62b3b7;
  --danger: #ff9b8e;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --topbar: rgba(16, 24, 32, 0.92);
  --input-bg: #121c25;
  --button-ink: #071316;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 44px);
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.english-title {
  color: var(--muted);
  font-weight: 750;
  text-transform: none;
}

h1 {
  margin: 0;
  max-width: 850px;
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
  line-height: 1.25;
}

.actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  background: var(--accent);
  color: var(--button-ink);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.theme-button {
  min-width: 72px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.theme-button:hover {
  background: var(--paper);
}

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

.settings-button:hover,
.settings-button[aria-expanded="true"] {
  background: var(--paper);
}

main {
  padding: clamp(18px, 4vw, 44px) 16px 70px;
}

.reader {
  width: min(var(--reader-width), 100%);
  margin: 0 auto;
}

.settings-panel {
  margin-bottom: 18px;
}

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

.url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 16px;
}

.reading-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.control-group span {
  padding: 0 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.control-group button {
  min-width: 46px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.control-group button:hover {
  background: var(--bg);
}

.reset-button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.reset-button:hover {
  background: var(--bg);
}

.settings-state {
  align-self: center;
  min-width: 86px;
  color: var(--muted);
  font-size: 0.9rem;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 13px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
}

.status {
  min-height: 24px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.status.error {
  color: var(--danger);
  font-weight: 700;
}

.content {
  padding: clamp(24px, 6vw, 58px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.content p {
  margin: 0 0 1.15em;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
}

.content p:last-child {
  margin-bottom: 0;
}

.bottom-nav {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.bottom-nav button {
  min-width: 74px;
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions,
  .url-row {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
