:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --ink: #161616;
  --muted: #6b665d;
  --panel: #ffffff;
  --line: #ded8cd;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --warm: #d97706;
  --reader-bg: #101010;
  --reader-panel: #181818;
  --reader-ink: #f7f2e8;
  --reader-muted: #aaa39a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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

body.reader-immersive {
  overflow: hidden;
  background: var(--reader-bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 16px;
  font-weight: 700;
}

button:active {
  transform: translateY(1px);
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

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

.screen {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.editor-screen {
  display: grid;
  gap: 18px;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
}

.eyebrow,
#readerKicker {
  margin: 0 0 4px;
  color: var(--warm);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.1;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.field input[type="text"],
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}

.field textarea {
  min-height: 260px;
  resize: vertical;
  line-height: 1.7;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

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

.compact {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions button {
  flex: 1 1 160px;
}

.share-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  padding: 14px;
}

.share-box textarea {
  min-height: 92px;
  font-size: 14px;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.reader-screen {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  background: var(--reader-bg);
  color: var(--reader-ink);
}

.reader-screen.immersive {
  height: 100dvh;
  min-height: 100dvh;
  grid-template-rows: auto 1fr;
  gap: 0;
  padding: 0;
}

.reader-bar,
.reader-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: env(safe-area-inset-top) 0 0;
}

.reader-bar {
  justify-content: space-between;
}

.reader-screen.immersive .reader-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  background: linear-gradient(180deg, rgba(16, 16, 16, 0.92), rgba(16, 16, 16, 0));
}

.reader-bar h2 {
  max-width: 62vw;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.reader-bar button,
.reader-controls button {
  border-color: #363636;
  background: #202020;
  color: var(--reader-ink);
}

.reader-bar .primary,
.reader-controls .primary {
  border-color: var(--accent);
  background: var(--accent);
}

.reader-stage {
  min-height: 0;
  overflow: hidden;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  background: var(--reader-panel);
}

.reader-screen.immersive .reader-stage {
  min-height: 100dvh;
  border: 0;
  border-radius: 0;
}

.script-panel {
  height: 100%;
  overflow: hidden;
  padding: 44dvh 18px 48dvh;
}

.script-text {
  white-space: pre-wrap;
  text-align: center;
  font-size: 44px;
  line-height: 1.55;
  font-weight: 800;
}

.reader-controls {
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  flex-wrap: wrap;
}

.reader-screen.immersive .reader-controls {
  display: none;
}

.reader-controls label {
  flex: 1 1 150px;
  display: grid;
  gap: 4px;
  color: var(--reader-muted);
  font-size: 13px;
  font-weight: 700;
}

.reader-controls button {
  flex: 1 1 96px;
}

@media (max-width: 620px) {
  .screen {
    padding: 16px;
  }

  h1 {
    font-size: 34px;
  }

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

  .field textarea {
    min-height: 230px;
  }

  .reader-screen {
    padding: 10px;
  }

  .script-panel {
    padding-left: 12px;
    padding-right: 12px;
  }
}
