/* Kaitlin Ghost Writing - Pete's Overseas Love
   Coastal dusk palette: deep navy, champagne gold, seafoam, warm sand */

:root {
  --navy-950: #0a1628;
  --navy-900: #0f2137;
  --navy-800: #152a45;
  --navy-700: #1c3654;
  --sea-500: #3d8b9c;
  --sea-400: #5aafbf;
  --sea-300: #8fd0db;
  --gold-500: #c9a227;
  --gold-400: #e0bc4a;
  --gold-300: #f0d47a;
  --sand-100: #f7f1e6;
  --sand-200: #ebe2d1;
  --cream: #faf6ef;
  --rose: #c47b7b;
  --rose-soft: #e8b4b4;
  --success: #4a9b6e;
  --danger: #b84a4a;
  --text: #f7f1e6;
  --text-muted: #a8b8c8;
  --glass: rgba(15, 33, 55, 0.72);
  --glass-border: rgba(201, 162, 39, 0.28);
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Outfit", system-ui, sans-serif;
  --max: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text);
  background: var(--navy-950);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Ambient background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(61, 139, 156, 0.35), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(201, 162, 39, 0.18), transparent 50%),
    radial-gradient(ellipse 50% 60% at 50% 100%, rgba(15, 33, 55, 0.9), var(--navy-950)),
    linear-gradient(165deg, #0a1628 0%, #122844 40%, #0c1a2e 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
  margin: 0 0 0.4em;
}

a {
  color: var(--gold-400);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--gold-300);
}

button, .btn {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.4rem;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
}
button:active, .btn:active {
  transform: scale(0.98);
}
button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-500), var(--gold-400));
  color: var(--navy-950);
  box-shadow: 0 8px 24px rgba(201, 162, 39, 0.35);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 32px rgba(201, 162, 39, 0.5);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(247, 241, 230, 0.22);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--gold-400);
  color: var(--gold-300);
}

.btn-sea {
  background: linear-gradient(135deg, var(--sea-500), var(--sea-400));
  color: white;
}

.btn-danger {
  background: rgba(184, 74, 74, 0.2);
  color: var(--rose-soft);
  border: 1px solid rgba(184, 74, 74, 0.4);
}

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-400);
  margin: 0 0 0.75rem;
}

/* Boot */
.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
}
.boot-title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  background: linear-gradient(120deg, var(--sand-100), var(--gold-300));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.boot-sub {
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 2px solid rgba(201, 162, 39, 0.2);
  border-top-color: var(--gold-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Layout */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  background: rgba(10, 22, 40, 0.75);
  border-bottom: 1px solid rgba(201, 162, 39, 0.15);
}
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--sand-100);
  letter-spacing: 0.02em;
}
.brand-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(61, 139, 156, 0.15);
  border: 1px solid rgba(61, 139, 156, 0.35);
  font-size: 0.85rem;
}
.role-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--gold-500);
  color: var(--navy-950);
  font-weight: 600;
}
.role-badge.user {
  background: var(--sea-400);
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0;
}
@media (max-width: 900px) {
  .login-page {
    grid-template-columns: 1fr;
  }
  .login-hero {
    min-height: 38vh;
  }
}

.login-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2.5rem;
  background:
    linear-gradient(to top, rgba(10, 22, 40, 0.95) 0%, rgba(10, 22, 40, 0.4) 50%, transparent 100%),
    url('/assets/landing.png') center/cover no-repeat;
  min-height: 100vh;
}
.login-hero-content h1 {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  color: var(--cream);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
.login-hero-content p {
  color: var(--sand-200);
  max-width: 28ch;
  font-size: 1.05rem;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 2.5rem 1.5rem;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.25rem;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.login-card h2 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}
.login-card .lede {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
}

.field {
  margin-bottom: 1.1rem;
}
.field label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(168, 184, 200, 0.25);
  background: rgba(10, 22, 40, 0.65);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--gold-400);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}
.field textarea {
  min-height: 110px;
  resize: vertical;
}

.form-error {
  color: var(--rose-soft);
  font-size: 0.9rem;
  margin: 0 0 1rem;
  min-height: 1.2em;
}

.login-card .btn-primary {
  width: 100%;
  margin-top: 0.5rem;
}

.login-hint {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(168, 184, 200, 0.15);
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.login-hint code {
  color: var(--sea-300);
  font-size: 0.85em;
}

/* Dashboard hero */
.dash-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 2rem;
  align-items: stretch;
  margin-bottom: 2.5rem;
}
@media (max-width: 800px) {
  .dash-hero {
    grid-template-columns: 1fr;
  }
}
.dash-copy {
  padding: 0.5rem 0;
}
.dash-copy h1 {
  font-size: clamp(2.2rem, 4.5vw, 3.2rem);
  background: linear-gradient(120deg, var(--cream), var(--gold-300));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.dash-copy .intro {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 42ch;
  margin: 0.75rem 0 1.5rem;
}
.dash-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.meta-chip {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(61, 139, 156, 0.12);
  border: 1px solid rgba(61, 139, 156, 0.3);
  font-size: 0.82rem;
  color: var(--sea-300);
}
.cover-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 260px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}
.cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  min-height: 260px;
}
.cover-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10, 22, 40, 0.55), transparent 50%);
  pointer-events: none;
}

/* Section */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.section-head h2 {
  font-size: 1.85rem;
}

/* Chapter grid */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.chapter-card {
  position: relative;
  padding: 1.5rem;
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(28, 54, 84, 0.55), rgba(15, 33, 55, 0.85));
  border: 1px solid rgba(201, 162, 39, 0.18);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-align: left;
  color: inherit;
  width: 100%;
  font-family: inherit;
}
.chapter-card:hover {
  transform: translateY(-4px);
  border-color: rgba(201, 162, 39, 0.45);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}
.chapter-card .num {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: rgba(201, 162, 39, 0.35);
  line-height: 1;
  margin-bottom: 0.5rem;
}
.chapter-card h3 {
  font-size: 1.45rem;
  margin-bottom: 0.35rem;
}
.chapter-card .sub {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.chapter-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.badge {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  background: rgba(247, 241, 230, 0.08);
  color: var(--text-muted);
}
.badge.audio {
  background: rgba(61, 139, 156, 0.2);
  color: var(--sea-300);
}
.badge.doc {
  background: rgba(201, 162, 39, 0.15);
  color: var(--gold-300);
}

/* Chapter detail */
.chapter-view {
  display: grid;
  gap: 1.5rem;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.back-link:hover {
  color: var(--gold-300);
}

.panel {
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.media-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.tab-btn {
  background: rgba(247, 241, 230, 0.06);
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
}
.tab-btn.active {
  background: rgba(201, 162, 39, 0.15);
  border-color: rgba(201, 162, 39, 0.4);
  color: var(--gold-300);
}

.pdf-frame {
  width: 100%;
  height: min(70vh, 720px);
  border: none;
  border-radius: var(--radius-sm);
  background: #111;
}

.audio-player-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(61, 139, 156, 0.15), rgba(15, 33, 55, 0.6));
  border: 1px solid rgba(61, 139, 156, 0.3);
}
.audio-player-wrap audio {
  width: 100%;
  height: 48px;
}
.audio-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* Feedback */
.reaction-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.reaction-btn {
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(247, 241, 230, 0.05);
  border: 1px solid rgba(168, 184, 200, 0.2);
  color: var(--text);
}
.reaction-btn.selected.like {
  border-color: var(--success);
  background: rgba(74, 155, 110, 0.2);
  color: #8fd4a8;
}
.reaction-btn.selected.dislike {
  border-color: var(--danger);
  background: rgba(184, 74, 74, 0.2);
  color: var(--rose-soft);
}

.feedback-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.25rem;
}
.feedback-item {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  background: rgba(10, 22, 40, 0.5);
  border: 1px solid rgba(168, 184, 200, 0.12);
}
.feedback-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.feedback-item .comment {
  margin: 0;
  white-space: pre-wrap;
}
.status-pill {
  font-size: 0.68rem;
  text-transform: none;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(201, 162, 39, 0.15);
  color: var(--gold-300);
  font-weight: 500;
}
.status-pill.not_started {
  background: rgba(168, 184, 200, 0.15);
  color: var(--text-muted);
}
.status-pill.pending {
  background: rgba(201, 162, 39, 0.18);
  color: var(--gold-300);
}
.status-pill.in_process {
  background: rgba(61, 139, 156, 0.22);
  color: var(--sea-300);
}
.status-pill.complete {
  background: rgba(74, 155, 110, 0.22);
  color: #8fd4a8;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
  margin-top: 0.75rem;
}
.status-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 160px;
}
.status-field-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.status-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(168, 184, 200, 0.3);
  background: rgba(10, 22, 40, 0.75);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.status-select:focus {
  outline: none;
  border-color: var(--gold-400);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}
.btn-sm {
  padding: 0.5rem 0.95rem;
  font-size: 0.82rem;
}
.feedback-item.editing {
  border-color: rgba(201, 162, 39, 0.4);
  background: rgba(28, 54, 84, 0.45);
}
.edit-reactions {
  margin-top: 0.5rem;
}

/* Admin */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 800px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.drop-zone {
  border: 1.5px dashed rgba(201, 162, 39, 0.35);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  cursor: copy;
}
.drop-zone:hover {
  border-color: var(--gold-400);
  background: rgba(201, 162, 39, 0.05);
}
.drop-zone.drag-over {
  border-color: var(--gold-300);
  background: rgba(201, 162, 39, 0.14);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2);
  transform: scale(1.01);
  color: var(--sand-100);
}
.drop-zone.uploading {
  opacity: 0.65;
  pointer-events: none;
}
.drop-zone strong {
  display: block;
  color: var(--sand-100);
  margin-bottom: 0.25rem;
}
.drop-zone span {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}
.drop-zone input[type="file"] {
  width: 100%;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.replace-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.chapter-replace-card {
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius-sm);
  background: rgba(10, 22, 40, 0.45);
  border: 1px solid rgba(168, 184, 200, 0.14);
}
.replace-hint {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}
.replace-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.replace-zone-any {
  grid-column: 1 / -1;
  border-style: solid;
  border-color: rgba(61, 139, 156, 0.4);
  background: rgba(61, 139, 156, 0.08);
}
.replace-zone {
  margin-bottom: 0;
}
@media (max-width: 700px) {
  .replace-zones {
    grid-template-columns: 1fr;
  }
  .replace-zone-any {
    grid-column: auto;
  }
}
.how-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.how-list li {
  margin-bottom: 0.5rem;
}
.how-list strong {
  color: var(--sand-100);
}

.add-chapter-panel {
  border-color: rgba(61, 139, 156, 0.45);
  background: linear-gradient(145deg, rgba(61, 139, 156, 0.12), rgba(15, 33, 55, 0.85));
}
.add-chapter-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 800px) {
  .add-chapter-grid {
    grid-template-columns: 1fr;
  }
}
.add-files-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 700px) {
  .add-files-row {
    grid-template-columns: 1fr;
  }
}
.chapter-edit-details {
  margin: 0 0 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(168, 184, 200, 0.15);
  background: rgba(10, 22, 40, 0.35);
  padding: 0.35rem 0.75rem 0.5rem;
}
.chapter-edit-details summary {
  cursor: pointer;
  color: var(--sea-300);
  font-size: 0.88rem;
  padding: 0.35rem 0;
  list-style: none;
}
.chapter-edit-details summary::-webkit-details-marker {
  display: none;
}
.chapter-edit-details[open] summary {
  margin-bottom: 0.5rem;
  color: var(--gold-300);
}
.chapter-edit-form .field {
  margin-bottom: 0.65rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--navy-800);
  border: 1px solid var(--gold-500);
  color: var(--cream);
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.error {
  border-color: var(--danger);
}
@keyframes slideIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ——— Responsive / iPhone + desktop ——— */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: rgba(247, 241, 230, 0.06);
  border: 1px solid rgba(168, 184, 200, 0.22);
  border-radius: 12px;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--sand-100);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Prevent iOS zoom on form focus (needs >= 16px) */
.field input,
.field textarea,
.field select,
.status-select {
  font-size: 16px;
}

@media (max-width: 720px) {
  .header-inner {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .brand-name {
    font-size: 1.15rem;
  }
  .brand-tag {
    font-size: 0.62rem;
    max-width: 42vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-toggle {
    display: flex;
    margin-left: auto;
  }
  .nav-actions {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding-top: 0.35rem;
  }
  .nav-actions.open {
    display: flex;
  }
  .nav-actions .btn,
  .nav-actions .user-pill {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  .user-pill {
    justify-content: center;
  }

  main {
    padding: 1.15rem 1rem 3.5rem;
    padding-bottom: calc(3.5rem + env(safe-area-inset-bottom));
  }

  .login-page {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }
  .login-hero {
    min-height: 32vh;
    min-height: 32dvh;
    padding: 1.5rem 1.25rem;
  }
  .login-hero-content h1 {
    font-size: clamp(2rem, 9vw, 2.6rem);
  }
  .login-panel {
    padding: 1.25rem 1rem 2rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
  .login-card {
    padding: 1.4rem 1.15rem;
    max-width: none;
  }

  .dash-hero {
    grid-template-columns: 1fr;
    gap: 1.15rem;
    margin-bottom: 1.5rem;
  }
  .cover-frame,
  .cover-frame img {
    min-height: 180px;
    max-height: 220px;
  }
  .dash-copy h1 {
    font-size: clamp(1.85rem, 8vw, 2.4rem);
  }
  .dash-copy .intro {
    font-size: 0.98rem;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  .chapter-card {
    padding: 1.15rem;
    min-height: 44px;
  }

  .panel {
    padding: 1.1rem;
  }
  .panel-title {
    font-size: 1.25rem;
  }
  .pdf-frame {
    height: min(62vh, 520px);
    height: min(62dvh, 520px);
  }
  .media-tabs {
    width: 100%;
  }
  .tab-btn {
    flex: 1;
    min-height: 44px;
    text-align: center;
  }
  .reaction-row {
    flex-direction: column;
  }
  .reaction-btn {
    min-width: 0;
    width: 100%;
    min-height: 48px;
  }
  .btn-primary,
  .btn-sea,
  .btn-ghost {
    min-height: 44px;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
  .add-chapter-grid,
  .add-files-row,
  .replace-zones {
    grid-template-columns: 1fr;
  }
  .replace-zone-any {
    grid-column: auto;
  }
  .status-row {
    flex-direction: column;
    align-items: stretch;
  }
  .status-field {
    min-width: 0;
  }
  .inline-actions {
    flex-direction: column;
  }
  .inline-actions button,
  .inline-actions .btn {
    width: 100%;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    max-width: none;
  }

  .site-header {
    padding-top: env(safe-area-inset-top);
  }
}

/* Small phones */
@media (max-width: 380px) {
  .brand-tag {
    display: none;
  }
  main {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}

/* Larger tablets / desktops keep multi-column layouts */
@media (min-width: 721px) {
  .nav-toggle {
    display: none !important;
  }
  .nav-actions {
    display: flex !important;
  }
}

/* Prefer landscape phones still usable */
@media (max-height: 500px) and (orientation: landscape) {
  .login-hero {
    min-height: 100%;
  }
  .pdf-frame {
    height: 55vh;
  }
}

/* Touch devices: slightly larger hit targets */
@media (hover: none) and (pointer: coarse) {
  button,
  .btn,
  .chapter-card,
  .tab-btn,
  .reaction-btn {
    min-height: 44px;
  }
  .drop-zone {
    padding: 1.35rem 1rem;
  }
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state h3 {
  color: var(--sand-100);
}

.hidden {
  display: none !important;
}

.stats-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.stats-row span strong {
  color: var(--gold-300);
  font-weight: 500;
}

.footer-note {
  margin-top: 3rem;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(168, 184, 200, 0.55);
}

.inline-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}
.inline-actions button {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  border-radius: 999px;
  background: rgba(247, 241, 230, 0.08);
  color: var(--text-muted);
  border: 1px solid rgba(168, 184, 200, 0.2);
}
.inline-actions button:hover {
  border-color: var(--gold-400);
  color: var(--gold-300);
}

.download-link {
  display: inline-flex;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}
