/* ============================================================
   WorksheetCraft — Shared Stylesheet
   Used by all pages. Page-specific styles can be added inline
   or in additional <link> tags.
   ============================================================ */

:root {
  --blue: #2563eb;
  --blue-deep: #1d4ed8;
  --blue-soft: #eff6ff;
  --blue-line: #dbeafe;
  --yellow: #fbbf24;
  --yellow-soft: #fef3c7;
  --coral: #fb7185;
  --mint: #5eead4;
  --green: #22c55e;
  --green-soft: #dcfce7;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-soft); color: var(--ink); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ===== NAV ===== */
nav {
  background: white;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; max-width: 1600px; margin: 0 auto;
  gap: 16px;
}
.logo {
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 20px;
  letter-spacing: -0.02em; display: flex; align-items: center; gap: 12px;
  color: var(--ink); text-decoration: none;
  flex-shrink: 0;
}
.logo-mark {
  width: 34px; height: 34px; background: var(--blue); color: white;
  border-radius: 9px; display: grid; place-items: center;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 18px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
  position: relative;
}
.logo-mark::after {
  content: ""; position: absolute; bottom: -3px; right: -3px;
  width: 12px; height: 12px; background: var(--yellow); border-radius: 50%;
  border: 2px solid white;
}

.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  flex: 1;
}
.breadcrumb a { color: var(--muted); text-decoration: none; transition: color 0.2s; }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb .sep { opacity: 0.5; }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

.nav-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* Worksheet-type tabs — primary navigation between worksheet types
   (Word Scramble, Missing Letters, etc.). Lives at the top of the
   left .panel, replacing the old panel-header title. */
.ws-type-tabs {
  margin: -28px -28px 22px; /* pull edge-to-edge inside the panel */
  padding: 0 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.ws-type-tabs-inner {
  display: flex; gap: 2px;
}
.ws-type-tab {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 14px 6px;
  font-size: 13px; font-weight: 700;
  color: var(--muted); text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
  min-width: 0;
}
.ws-type-tab:hover:not(.is-soon) { color: var(--ink); background: rgba(255,255,255,0.6); }
.ws-type-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  background: white;
}
.ws-type-tab.is-soon {
  color: var(--muted);
  cursor: not-allowed;
}
.ws-type-tab .ws-type-glyph { font-size: 16px; line-height: 1; }
.ws-type-tab .ws-type-soon {
  font-size: 8px; font-weight: 700;
  padding: 1px 5px; border-radius: 999px;
  background: var(--yellow-soft); color: #92400e;
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-left: 2px;
}

@media (max-width: 720px) {
  .breadcrumb { display: none; }
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; border: none;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn-primary {
  background: var(--blue); color: white;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { background: var(--blue-deep); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35); }
.btn-ghost { background: white; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-success {
  background: var(--green); color: white;
  box-shadow: 0 4px 10px rgba(34, 197, 94, 0.3);
}
.btn-success:hover { background: #16a34a; transform: translateY(-1px); }

/* ===== STUDIO LAYOUT ===== */
.studio {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: calc(100vh - 65px);
}
@media (max-width: 960px) {
  .studio { grid-template-columns: 1fr; }
}

/* ===== LEFT PANEL ===== */
.panel {
  background: white;
  border-right: 1px solid var(--line);
  padding: 28px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 65px);
  position: sticky;
  top: 65px;
}
@media (max-width: 960px) {
  .panel { max-height: none; position: relative; top: 0; border-right: none; border-bottom: 1px solid var(--line); }
}

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.panel-title {
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 22px;
  letter-spacing: -0.01em;
}
.badge {
  background: var(--blue-soft); color: var(--blue);
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-group { margin-bottom: 22px; }
.control-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
}
.control-label .count {
  background: var(--bg-soft); color: var(--ink);
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0;
  text-transform: none;
}
.control-input {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1.5px solid var(--line);
  background: white; font-family: inherit; font-size: 14px; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.control-input:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}
textarea.control-input {
  resize: vertical; min-height: 140px; line-height: 1.6;
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  letter-spacing: 0.05em;
}

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 8px 14px; border-radius: 999px;
  background: white; border: 1.5px solid var(--line);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; color: var(--ink-soft);
  font-family: inherit;
}
.pill:hover { border-color: var(--blue); color: var(--blue); }
.pill.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ===== Words entry: tabs + per-mode body ===== */
.entry-tabs {
  display: flex; gap: 4px;
  padding: 4px; margin-bottom: 12px;
  background: var(--bg-soft);
  border-radius: 12px;
}
.entry-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 8px; border-radius: 8px;
  background: transparent; border: none;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--muted); cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.entry-tab:hover:not(.is-disabled) { color: var(--ink); }
.entry-tab.active {
  background: white; color: var(--blue);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.entry-tab.is-disabled { color: var(--muted); cursor: not-allowed; opacity: 0.7; }
.entry-tab .tab-glyph { font-size: 13px; line-height: 1; }
.entry-tab .tab-soon {
  font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
  background: var(--yellow-soft); color: #92400e;
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-left: 2px;
}

.entry-body { margin-bottom: 12px; animation: entry-fade 0.18s ease; }
.entry-body[hidden] { display: none; }

@keyframes entry-fade {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.entry-hint {
  font-size: 12px; color: var(--muted);
  margin: 0 0 10px;
}
.entry-placeholder {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.entry-placeholder .placeholder-glyph { font-size: 24px; line-height: 1; }
.entry-placeholder strong { display: block; font-size: 13px; color: var(--ink); margin-bottom: 4px; }
.entry-placeholder p { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }
.entry-placeholder em { font-style: normal; font-weight: 700; color: var(--ink-soft); }

/* (Random tab now has an empty body — the right preview pane is the
    feedback. Older `.random-card` / `.random-scope` styles removed.) */

/* ===== Topic chips (Topics tab inside the Studio) ===== */
.topic-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.topic-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px;
  background: white; border: 1.5px solid var(--line);
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--ink-soft); font-family: inherit;
  transition: transform 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
}
.topic-chip:hover { border-color: var(--blue); color: var(--blue); transform: translateY(-1px); }
.topic-chip.active { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-deep); }
.topic-chip .chip-label { line-height: 1; }

/* Shared sub-label above the textarea (for word count) */
.control-sub-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
  margin: 0 2px 8px;
}
.control-sub-label .count {
  background: var(--bg-soft); color: var(--ink);
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}

/* ===== Settings group (Difficulty / Grade / Theme / Layout / Options) ===== */
.settings-group {
  margin-top: 8px; padding-top: 18px;
  border-top: 1px solid var(--line);
}
.settings-heading {
  font-size: 11px; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 14px;
}
.control-group.compact { margin-bottom: 16px; }
.control-group.compact:last-child { margin-bottom: 0; }
.control-group.compact .control-label { margin-bottom: 6px; }

.theme-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.theme-card {
  aspect-ratio: 1; border-radius: 12px;
  border: 2px solid var(--line); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
  background: white; font-family: inherit;
}
.theme-card:hover {
  border-color: var(--blue); transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.12);
}
.theme-card.active {
  border-color: var(--blue); background: var(--blue-soft);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}
.theme-card .glyph { font-size: 30px; line-height: 1; }
.theme-card .label { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.theme-card.active .label { color: var(--blue-deep); }

.checkbox-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--bg-soft);
  cursor: pointer;
  transition: background 0.15s;
}
.checkbox-row:hover { background: var(--blue-soft); }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--blue); cursor: pointer; }
.checkbox-row label { font-size: 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer; flex: 1; }

.panel-footer {
  margin-top: 24px; padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid; gap: 8px;
  position: sticky; bottom: 0;
  background: linear-gradient(to top, white 80%, rgba(255,255,255,0));
  padding-bottom: 4px;
}
.panel-footer .btn {
  width: 100%; justify-content: center;
  padding: 13px 16px; font-size: 14px;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.panel-footer .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(37, 99, 235, 0.32); }
.panel-footer .btn-primary:active { transform: translateY(0); box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25); }

/* ===== RIGHT PREVIEW ===== */
.preview-area {
  padding: 32px;
  background: var(--bg-soft);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(37,99,235,0.08) 1px, transparent 0);
  background-size: 24px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 65px);
}
@media (max-width: 960px) { .preview-area { max-height: none; padding: 20px; } }

.preview-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
  background: white;
  padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line);
}
.preview-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); font-weight: 600;
}
.status-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; animation: pulse 2s ease-in-out infinite; }
.preview-toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.zoom-group { display: flex; gap: 4px; align-items: center; padding-right: 4px; margin-right: 4px; border-right: 1px solid var(--line); }
.preview-toolbar-actions .btn-sm {
  padding: 8px 14px; font-size: 13px; border-radius: 9px;
}
.preview-toolbar-actions .btn-sm span:first-child { font-size: 14px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: white;
  display: grid; place-items: center;
  cursor: pointer; font-size: 16px;
  transition: all 0.15s;
  font-family: inherit;
}
.icon-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

/* ===== WORKSHEET PAPER ===== */
.paper-wrap {
  display: flex; justify-content: center;
  padding: 20px 0 60px;
}
.paper {
  background: white;
  width: 100%; max-width: 794px;
  min-height: 1000px;
  padding: 60px 56px;
  border-radius: 4px;
  box-shadow:
    0 1px 2px rgba(15,23,42,0.08),
    0 8px 24px -4px rgba(15,23,42,0.12),
    0 30px 60px -20px rgba(15,23,42,0.18);
  position: relative;
  transition: transform 0.2s ease;
}

.paper.theme-space { background: linear-gradient(180deg, #fff 0%, #f0f5ff 100%); }
.paper.theme-space .ws-title { color: #1d4ed8; }
.paper.theme-space .ws-header { border-color: #1d4ed8; }
.paper.theme-space .ws-num { color: #1d4ed8; }
.paper.theme-space::before {
  content: "★ ✦ ✧"; position: absolute; top: 30px; right: 50px;
  color: rgba(29, 78, 216, 0.2); font-size: 18px; letter-spacing: 8px;
}

.paper.theme-nature { background: linear-gradient(180deg, #fff 0%, #f0fdf4 100%); }
.paper.theme-nature .ws-title { color: #166534; }
.paper.theme-nature .ws-header { border-color: #166534; }
.paper.theme-nature .ws-num { color: #166534; }
.paper.theme-nature::before {
  content: "🌿"; position: absolute; top: 30px; right: 50px;
  font-size: 24px; opacity: 0.6;
}

.paper.theme-ocean { background: linear-gradient(180deg, #fff 0%, #ecfeff 100%); }
.paper.theme-ocean .ws-title { color: #0e7490; }
.paper.theme-ocean .ws-header { border-color: #0e7490; }
.paper.theme-ocean .ws-num { color: #0e7490; }
.paper.theme-ocean::before {
  content: "🌊"; position: absolute; top: 30px; right: 50px;
  font-size: 24px; opacity: 0.6;
}

.paper.theme-animals { background: linear-gradient(180deg, #fff 0%, #fff7ed 100%); }
.paper.theme-animals .ws-title { color: #c2410c; }
.paper.theme-animals .ws-header { border-color: #c2410c; }
.paper.theme-animals .ws-num { color: #c2410c; }
.paper.theme-animals::before {
  content: "🐾"; position: absolute; top: 30px; right: 50px;
  font-size: 24px; opacity: 0.7;
}

.paper.theme-fun .ws-title { color: var(--coral); }
.paper.theme-fun .ws-header { border-color: var(--coral); }
.paper.theme-fun .ws-num { color: var(--coral); }
.paper.theme-fun::before {
  content: "🎨"; position: absolute; top: 30px; right: 50px;
  font-size: 24px; opacity: 0.7;
}

.paper.theme-plain .ws-title { color: var(--ink); }
.paper.theme-plain .ws-header { border-color: var(--ink); }
.paper.theme-plain .ws-num { color: var(--ink); }

.ws-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding-bottom: 22px;
  border-bottom: 2px dashed var(--blue);
  margin-bottom: 28px;
}
.ws-title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 30px; letter-spacing: -0.02em; line-height: 1.1;
  margin-bottom: 28px;
}
.ws-name-row {
  display: flex; gap: 32px; flex-wrap: wrap;
  font-size: 13px; color: var(--ink-soft); font-weight: 500;
}
.ws-name-row .field {
  display: flex; gap: 8px; align-items: baseline;
}
.ws-name-row .blank {
  border-bottom: 1.5px solid var(--ink);
  display: inline-block; min-width: 170px; height: 18px;
}
.ws-name-row .blank.short { min-width: 110px; }
.ws-meta {
  text-align: right; font-size: 11px; color: var(--muted);
  font-weight: 600; line-height: 1.5;
}
.ws-meta .badge-mini {
  display: inline-block; background: var(--blue-soft); color: var(--blue);
  padding: 2px 8px; border-radius: 999px; font-size: 10px;
  letter-spacing: 0.05em; text-transform: uppercase;
}

.ws-instructions {
  font-size: 13px; color: var(--ink-soft); margin-bottom: 22px;
  padding: 12px 16px; background: var(--bg-soft); border-radius: 10px;
  border-left: 3px solid var(--blue);
  line-height: 1.5;
}

.ws-list {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px 36px;
}
.ws-list.single-col { grid-template-columns: 1fr; }
.ws-row {
  display: grid; grid-template-columns: 28px 1fr 1.2fr;
  gap: 10px; align-items: center;
  padding: 8px 0;
  border-bottom: 1px dotted var(--line);
}
.ws-num {
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 17px;
}
.ws-word {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600; letter-spacing: 0.12em;
  font-size: 14px; color: var(--ink);
}
.ws-blank {
  border-bottom: 1.5px solid var(--ink);
  height: 20px;
}

/* Missing Letters rows: no trailing answer line — students write
   directly on the wider blank slots inside the word itself. */
.ws-row.missing-row {
  grid-template-columns: 28px 1fr;
}
.ws-word.missing-word {
  display: inline-flex; align-items: center; gap: 6px;
  letter-spacing: 0; /* spacing handled by gap between children */
  font-size: 16px;
}
.ws-word.missing-word .ws-char {
  display: inline-block; min-width: 14px; text-align: center;
}
.ws-word.missing-word .blank-slot {
  display: inline-block;
  width: 28px; height: 18px;
  border-bottom: 2px solid var(--ink);
  vertical-align: bottom;
}

.ws-answer-key {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 2px dashed var(--line);
}
.ws-answer-key h3 {
  font-family: 'Fraunces', serif; font-size: 16px; font-weight: 700;
  color: var(--muted); margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.ws-answer-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px 24px;
  font-size: 12px; color: var(--ink-soft);
}
.ws-answer-grid .answer-item { display: flex; gap: 8px; }
.ws-answer-grid .answer-num { font-weight: 700; color: var(--muted); min-width: 18px; }

.ws-footer {
  position: absolute; bottom: 30px; left: 56px; right: 56px;
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted);
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.ws-footer .brand { font-family: 'Fraunces', serif; font-weight: 700; color: var(--blue); }

.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 {
  font-family: 'Fraunces', serif; font-size: 20px;
  color: var(--ink-soft); margin-bottom: 8px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--ink); color: white;
  padding: 14px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  display: flex; align-items: center; gap: 10px;
  transform: translateY(100px); opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast .check {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--green); color: white;
  display: grid; place-items: center; font-size: 12px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.6; }
}

/* ===== PRINT MODE ===== */
@media print {
  nav, .panel, .preview-toolbar, .ws-footer .brand-link, .toast { display: none !important; }
  body, .preview-area { background: white !important; }
  .preview-area { padding: 0 !important; max-height: none !important; overflow: visible !important; }
  .paper-wrap { padding: 0 !important; }
  .paper {
    box-shadow: none !important;
    max-width: 100% !important;
    min-height: auto !important;
    padding: 30px 40px !important;
    transform: none !important;
  }
  .studio { display: block !important; }
}

/* =============================================================
   TOPIC PAGES — /topics/ index + /topics/?slug=… detail
   ============================================================= */
.topic-wrap {
  max-width: 1100px; margin: 0 auto;
  padding: 48px 24px 64px;
}

/* Header shared by index and detail views */
.topic-header { text-align: center; margin-bottom: 48px; }
.topic-header h1 {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: clamp(32px, 5vw, 44px);
  color: var(--ink); line-height: 1.15;
  margin: 14px 0 12px; letter-spacing: -0.02em;
}
.topic-sub {
  font-size: 16px; color: var(--ink-soft); line-height: 1.6;
  max-width: 620px; margin: 0 auto 20px;
}
.topic-header-cta { margin-top: 24px; }

/* Breadcrumb on detail pages */
.topic-breadcrumb {
  font-size: 13px; color: var(--muted);
  margin-bottom: 24px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.topic-breadcrumb a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.topic-breadcrumb a:hover { color: var(--blue); }
.topic-breadcrumb .sep { opacity: 0.5; }
.topic-breadcrumb .current { color: var(--ink); font-weight: 600; }

/* Section wrapper used multiple times on detail pages */
.topic-section { margin-bottom: 56px; }
.topic-section-title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 26px; color: var(--ink);
  margin-bottom: 20px; letter-spacing: -0.01em;
}

/* ---- Topic index grid (all topics) ---- */
.topic-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.topic-card {
  display: flex; flex-direction: column;
  padding: 22px;
  background: white; border: 1.5px solid var(--line);
  border-radius: 14px;
  text-decoration: none; color: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.topic-card:hover {
  border-color: var(--blue); transform: translateY(-2px);
  box-shadow: 0 12px 24px -8px rgba(37, 99, 235, 0.18);
}
.topic-card-title {
  font-family: 'Fraunces', serif; font-size: 19px; font-weight: 700;
  color: var(--ink); margin-bottom: 6px;
}
.topic-card-meta { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.topic-card-meta .topic-card-sep { opacity: 0.45; margin: 0 4px; }
.topic-card-cta { font-size: 13px; font-weight: 700; color: var(--blue); margin-top: auto; }

/* ---- Word list cards (detail page) ---- */
.word-list-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.word-list-card {
  background: white; border: 1.5px solid var(--line);
  border-radius: 14px; padding: 22px;
  display: flex; flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.word-list-card:hover {
  border-color: var(--blue-line);
  box-shadow: 0 8px 18px -6px rgba(37, 99, 235, 0.1);
}
.word-list-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.word-list-title {
  font-family: 'Fraunces', serif; font-size: 18px; font-weight: 700;
  color: var(--ink); line-height: 1.25;
  flex: 1; min-width: 0;
}
.word-list-meta { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.meta-pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: var(--bg-soft); color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.meta-pill.meta-grade { background: var(--blue-soft); color: var(--blue-deep); }

.word-list-preview {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-bottom: 18px; padding: 12px;
  background: var(--bg-soft); border-radius: 10px;
}
.word-chip {
  display: inline-block; padding: 3px 9px; border-radius: 6px;
  background: white; border: 1px solid var(--line);
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  font-weight: 600; color: var(--ink);
  letter-spacing: 0.05em;
}
.word-chip.muted { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-family: 'Plus Jakarta Sans', sans-serif; letter-spacing: 0; }

.word-list-actions {
  display: flex; gap: 8px; margin-top: auto;
  flex-wrap: wrap;
}
.word-list-actions .btn-sm { padding: 9px 14px; font-size: 13px; flex: 1; justify-content: center; min-width: 120px; }

/* ---- How-to-use steps ---- */
.topic-steps {
  background: white; border: 1.5px solid var(--line);
  border-radius: 14px; padding: 24px 32px;
  list-style: decimal; list-style-position: outside;
  counter-reset: step;
}
.topic-steps li {
  font-size: 15px; line-height: 1.7; color: var(--ink-soft);
  margin-bottom: 12px; padding-left: 8px;
}
.topic-steps li::marker { color: var(--blue); font-weight: 700; }
.topic-steps li:last-child { margin-bottom: 0; }

/* ---- Teaching tips ---- */
.tip-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.tip-card {
  background: white; border: 1.5px solid var(--line);
  border-radius: 12px; padding: 22px;
}
.tip-glyph { font-size: 28px; margin-bottom: 12px; line-height: 1; }
.tip-card h3 {
  font-family: 'Fraunces', serif; font-size: 17px; font-weight: 700;
  color: var(--ink); margin-bottom: 6px;
}
.tip-card p { font-size: 14px; color: var(--ink-soft); line-height: 1.55; }

/* ---- Related topics ---- */
.related-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.related-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px;
  background: white; border: 1.5px solid var(--line);
  border-radius: 10px;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.related-card:hover { border-color: var(--blue); transform: translateY(-1px); }
.related-name { font-weight: 700; color: var(--ink); font-size: 14px; }
.related-count { font-size: 12px; color: var(--muted); }
.all-topics-link {
  text-align: center; margin-top: 24px; font-size: 14px;
}
.all-topics-link a { color: var(--blue); text-decoration: none; font-weight: 700; }
.all-topics-link a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Final CTA block on topic pages ---- */
.topic-final-cta {
  text-align: center; margin-top: 64px; padding: 40px 24px;
  background: var(--blue-soft); border-radius: 16px;
}
.topic-final-cta h2 {
  font-family: 'Fraunces', serif; font-size: 26px; font-weight: 700;
  color: var(--ink); margin-bottom: 8px;
}
.topic-final-cta p { color: var(--ink-soft); margin-bottom: 22px; font-size: 15px; }

/* =============================================================
   SITE FOOT — slim legal links bar shown on every page that uses
   includes/footer.php (studios, admin). Required by AdSense so
   Privacy Policy is reachable from every page.
   ============================================================= */
.site-foot {
  background: white;
  border-top: 1px solid var(--line);
  padding: 14px 24px;
}
.site-foot-inner {
  max-width: 1600px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
}
.site-foot-brand { font-weight: 600; }
.site-foot-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-foot-links a { color: var(--ink-soft); text-decoration: none; font-weight: 500; transition: color 0.15s; }
.site-foot-links a:hover { color: var(--blue); }
.site-foot-links .dot { color: var(--line); }

/* Print: hide the site-foot too (along with nav and toolbar) */
@media print {
  .site-foot { display: none !important; }
}

/* =============================================================
   LANDING PAGE — index.php
   ============================================================= */
body.landing-page {
  background: white; color: var(--ink);
}

.landing-nav {
  background: white;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}
.landing-nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; max-width: 1200px; margin: 0 auto;
  gap: 16px;
}
.landing-nav-actions { display: flex; gap: 12px; align-items: center; }
.landing-nav-links { display: flex; gap: 22px; align-items: center; }
.landing-nav-links .nav-link {
  font-size: 14px; font-weight: 600;
  color: var(--ink-soft); text-decoration: none;
  transition: color 0.15s;
}
.landing-nav-links .nav-link:hover { color: var(--blue); }
@media (max-width: 720px) {
  .landing-nav-links { display: none; }
}

.section-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 0 24px;
}
.section-head { text-align: center; max-width: 760px; margin: 0 auto 48px; }
.section-eyebrow {
  display: inline-block;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--blue);
  padding: 6px 14px; border-radius: 999px;
  background: var(--blue-soft);
  margin-bottom: 14px;
}
.section-title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: clamp(28px, 4vw, 40px);
  color: var(--ink); line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.section-sub {
  font-size: 16px; color: var(--ink-soft); line-height: 1.6;
  max-width: 620px; margin: 0 auto;
}

/* ---- Hero ---- */
.hero {
  position: relative;
  padding: 80px 24px 60px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(37, 99, 235, 0.08), transparent 70%),
    radial-gradient(ellipse 60% 50% at 90% 30%, rgba(251, 191, 36, 0.10), transparent 60%),
    white;
  overflow: hidden;
}
.hero-bg {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(37, 99, 235, 0.08) 1px, transparent 0);
  background-size: 28px 28px;
  opacity: 0.5; pointer-events: none;
}
.hero-inner {
  position: relative;
  max-width: 1100px; margin: 0 auto;
  text-align: center;
}
.hero-inner.hero-grid {
  max-width: 1200px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 56px;
  align-items: center;
  text-align: left;
}
.hero-grid .hero-eyebrow,
.hero-grid .hero-title,
.hero-grid .hero-sub { text-align: left; }
.hero-grid .hero-title { margin-left: 0; }
.hero-grid .hero-ctas { justify-content: flex-start; }
.hero-grid .hero-trust { justify-content: flex-start; }
.hero-grid .hero-paper-stack { margin: 0; max-width: 100%; }
@media (max-width: 880px) {
  .hero-inner.hero-grid {
    grid-template-columns: 1fr;
    gap: 32px;
    text-align: center;
  }
  .hero-grid .hero-eyebrow,
  .hero-grid .hero-title,
  .hero-grid .hero-sub { text-align: center; }
  .hero-grid .hero-ctas,
  .hero-grid .hero-trust { justify-content: center; }
}
.hero-eyebrow {
  display: inline-block;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--blue);
  padding: 6px 14px; border-radius: 999px;
  background: white; border: 1.5px solid var(--blue-line);
  margin-bottom: 24px;
}
.hero-title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1.08; letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 18px;
}
/* Hero accent: single-color blue. The rainbow gradient was eye-candy
   that competed with the rest of the page; a calm solid color lets the
   headline read first and the animated demo to the right do the work
   of catching the eye. */
.hero-accent {
  color: var(--blue);
}
.hero-sub {
  font-size: clamp(15px, 1.7vw, 18px);
  line-height: 1.6; color: var(--ink-soft);
  max-width: 580px; margin: 0 auto 32px;
}
.hero-ctas {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 36px;
}
.btn-xl { padding: 14px 24px; font-size: 15px; border-radius: 12px; }
.hero-trust {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}
.trust-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px;
  background: white; border: 1px solid var(--line);
  color: var(--ink-soft);
}
/* Stat-emphasis variant — used for the live "N words · M topics" pill
   on the hero so the library size feels substantial at first glance. */
.trust-pill-stat {
  background: var(--blue-soft);
  border-color: var(--blue-line);
  color: var(--blue-deep);
  font-weight: 700;
}

/* Floating worksheet preview decoration */
.hero-paper-stack {
  position: relative; max-width: 540px;
  margin: 56px auto 0;
}
.hero-paper {
  position: relative;
  background: white; border: 1.5px solid var(--line);
  border-radius: 16px; padding: 22px 22px;
  box-shadow: 0 24px 50px -10px rgba(15, 23, 42, 0.18),
              0 8px 16px -4px rgba(15, 23, 42, 0.08);
  font-family: 'JetBrains Mono', monospace;
}
.hero-paper-back {
  position: absolute; top: -16px; left: -22px;
  width: 75%;
  transform: rotate(-4deg);
  opacity: 0.85;
}
.hero-paper-front {
  margin-top: 28px;
  transform: rotate(1deg);
  width: 95%; margin-left: auto;
  /* Subtle amber glow so the focal animated paper feels alive */
  box-shadow: 0 30px 60px -10px rgba(217, 119, 6, 0.28),
              0 14px 24px -6px rgba(15, 23, 42, 0.12),
              0 0 0 1px rgba(217, 119, 6, 0.2);
}
.hp-line { height: 10px; background: var(--bg-soft); border-radius: 4px; margin-bottom: 10px; width: 70%; }
.hp-line.short { width: 40%; margin-bottom: 22px; }
.hp-rows { display: grid; gap: 14px; }
.hp-row { display: flex; gap: 12px; font-size: 15px; color: var(--ink); align-items: center; }
.hp-row > span:first-child { color: var(--blue); font-weight: 700; min-width: 18px; }
.hp-word { letter-spacing: 0.18em; font-weight: 700; }
.hero-paper.theme-space .hp-row > span:first-child { color: #7c3aed; }
.hero-paper.theme-animals .hp-row > span:first-child { color: #d97706; }

/* Badge in top corner of each hero paper */
.hp-badge {
  position: absolute; top: 16px; right: 16px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.06); color: var(--ink-soft);
}
.hero-paper.theme-space .hp-badge { background: rgba(124, 58, 237, 0.12); color: #5b21b6; }
.hero-paper.theme-animals .hp-badge { background: rgba(217, 119, 6, 0.13); color: #92400e; }

/* Live indicator (pulsing red dot + LIVE label) */
.hp-badge-live {
  background: white !important;
  border: 1.5px solid rgba(217, 119, 6, 0.3);
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.18);
  color: var(--ink-soft) !important;
}
.live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: live-pulse 1.4s ease-out infinite;
}
.live-text { font-weight: 800; color: #ef4444; letter-spacing: 0.1em; }
.live-sep { opacity: 0.4; margin: 0 2px; }
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0    rgba(239, 68, 68, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);   }
  100% { box-shadow: 0 0 0 0    rgba(239, 68, 68, 0);   }
}

/* Per-character rendering (Missing Letters demo) */
.demo-word { display: inline-flex; align-items: center; gap: 7px; letter-spacing: 0; font-size: 18px; }
.hp-ch { display: inline-block; min-width: 10px; text-align: center; }
.hp-ch.hp-blank {
  position: relative;
  min-width: 20px; height: 22px;
  border-bottom: 2.5px solid var(--ink);
  color: transparent;
  transition: color 0.35s ease;
}
.hp-ch.hp-blank.filled {
  color: var(--ink);
  animation: hp-fill-in 0.7s cubic-bezier(.34,1.56,.64,1);
}
.hp-ch.hp-blank.fading {
  color: transparent;
  transition: color 0.4s ease;
}

/* Dramatic letter-arrival: drops in BIG, accent-orange, then settles to ink.
   The amber-to-ink color cue is what makes the animation "obvious". */
@keyframes hp-fill-in {
  0%   { transform: translateY(-16px) scale(0.3); opacity: 0; color: #d97706; }
  35%  { transform: translateY(6px)   scale(1.5); opacity: 1; color: #d97706; }
  55%  { transform: translateY(-3px)  scale(1.15); opacity: 1; color: #d97706; }
  80%  { transform: translateY(0)     scale(1);   opacity: 1; color: #d97706; }
  100% { transform: translateY(0)     scale(1);   opacity: 1; color: var(--ink); }
}

/* Respect motion preferences */
@media (prefers-reduced-motion: reduce) {
  .hp-ch.hp-blank { transition: none; }
  .hp-ch.hp-blank.filled { animation: none; }
}

/* ---- How it works ---- */
.hiw { padding: 80px 0; background: var(--bg-soft); }
.hiw-grid {
  display: grid; gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.hiw-step {
  background: white; border: 1.5px solid var(--line);
  border-radius: 16px; padding: 28px;
  text-align: center;
}
.hiw-num {
  width: 44px; height: 44px;
  display: grid; place-items: center; margin: 0 auto 16px;
  border-radius: 12px;
  background: var(--blue); color: white;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 20px;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.3);
}
/* All step numbers share the brand blue — the per-step color rainbow
   (blue, coral, green) was extra visual noise without adding meaning. */
.hiw-step h3 { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.hiw-step p { color: var(--ink-soft); font-size: 14px; line-height: 1.55; }

/* ---- What you can make ---- */
.types { padding: 80px 0; }
.types-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.type-card {
  position: relative;
  display: flex; flex-direction: column;
  padding: 28px;
  background: white; border: 1.5px solid var(--line);
  border-radius: 16px;
  text-decoration: none; color: inherit;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.type-card:hover {
  border-color: var(--blue); transform: translateY(-4px);
  box-shadow: 0 16px 30px -8px rgba(37, 99, 235, 0.18);
}
.type-card.is-soon { pointer-events: none; background: var(--bg-soft); opacity: 0.7; }
.type-glyph { font-size: 36px; margin-bottom: 14px; line-height: 1; }
.type-card h3 {
  font-family: 'Fraunces', serif; font-size: 22px; font-weight: 700;
  margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.type-card p { font-size: 14px; color: var(--ink-soft); line-height: 1.55; margin-bottom: 18px; flex: 1; }
.type-example {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--bg-soft);
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  margin-bottom: 16px; align-self: flex-start;
}
.type-q { color: var(--ink-soft); letter-spacing: 0.15em; font-weight: 700; }
.type-arrow { color: var(--muted); display: inline-block; }
.type-a {
  color: var(--blue-deep); font-weight: 700; letter-spacing: 0.1em;
  display: inline-block;
}

/* Looping pulse animation — draws the eye to the puzzle-to-answer
   relationship every few seconds without being distracting. */
.type-example-anim .type-arrow {
  animation: type-arrow-pulse 4s ease-in-out infinite;
}
.type-example-anim .type-a {
  animation: type-answer-flash 4s ease-in-out infinite;
}
/* Second card is offset by 2s so the two animations alternate
   rather than fire in unison — keeps the eye moving. */
.type-card-b .type-example-anim .type-arrow,
.type-card-b .type-example-anim .type-a {
  animation-delay: 2s;
}

@keyframes type-arrow-pulse {
  0%, 50%        { transform: translateX(0); color: var(--muted); }
  62%            { transform: translateX(4px); color: #d97706; }
  78%            { transform: translateX(0);   color: var(--muted); }
  100%           { transform: translateX(0); color: var(--muted); }
}
@keyframes type-answer-flash {
  0%, 50%        { color: var(--blue-deep); transform: scale(1); }
  62%            { color: #d97706;           transform: scale(1.18); }
  78%            { color: #d97706;           transform: scale(1); }
  92%, 100%      { color: var(--blue-deep); transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .type-example-anim .type-arrow,
  .type-example-anim .type-a { animation: none; }
}
.type-cta { color: var(--blue); font-weight: 700; font-size: 14px; }
.badge-soon {
  font-size: 9px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--yellow-soft); color: #92400e;
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* ---- Topics cloud ---- */
.topics { padding: 80px 0; background: var(--bg-soft); }

/* Stats strip above the topic cloud — four big numbers establishing
   library credibility (words / lists / topics / grade range). */
.library-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; max-width: 720px; margin: 0 auto 40px;
  padding: 24px;
  background: white; border: 1.5px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 18px -10px rgba(15, 23, 42, 0.08);
}
.lib-stat { text-align: center; }
.lib-stat-num {
  display: block;
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: clamp(24px, 3.5vw, 34px);
  color: var(--blue);
  line-height: 1; letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.lib-stat-label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
}
@media (max-width: 640px) {
  .library-stats { grid-template-columns: repeat(2, 1fr); }
}

.topics-cloud {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 10px; max-width: 800px; margin: 0 auto;
}
.topic-pill {
  display: inline-block; padding: 9px 16px; border-radius: 999px;
  background: white; border: 1.5px solid var(--line);
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}
.topic-pill:hover { background: var(--blue); color: white; border-color: var(--blue); transform: translateY(-1px); }

/* ---- Audience ---- */
.audience { padding: 80px 0; }
.audience-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.audience-card {
  text-align: center; padding: 28px 20px;
  background: white; border: 1.5px solid var(--line);
  border-radius: 14px;
}
.audience-glyph { font-size: 32px; line-height: 1; margin-bottom: 12px; display: block; }
.audience-card h4 { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.audience-card p { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }

/* ---- Final CTA ---- */
.final-cta {
  padding: 80px 24px;
  /* Single-tone blue gradient — clean, focused, on-brand. The previous
     rainbow gradient pulled attention away from the headline + button. */
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
  color: white;
  text-align: center;
}
.final-cta h2 {
  font-family: 'Fraunces', serif; font-size: clamp(28px, 4vw, 40px);
  font-weight: 700; line-height: 1.2; margin-bottom: 14px;
  letter-spacing: -0.02em;
}
.final-cta p { font-size: 16px; opacity: 0.92; margin-bottom: 28px; }
.final-cta .btn-primary {
  background: white; color: var(--blue-deep);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.final-cta .btn-primary:hover { background: var(--bg-soft); transform: translateY(-2px); }

/* ---- Footer ---- */
.landing-footer {
  padding: 56px 24px 24px;
  background: var(--ink);
  color: rgba(255, 255, 255, 0.7);
}
.landing-footer .section-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  align-items: flex-start;
}
.footer-brand .logo { color: white; }
.footer-brand p { font-size: 13px; opacity: 0.7; margin-top: 6px; max-width: 280px; line-height: 1.55; }
.footer-links { display: flex; flex-direction: column; gap: 10px; }
.footer-links-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}
.footer-links a {
  color: rgba(255, 255, 255, 0.75); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: color 0.15s;
}
.footer-links a:hover { color: white; }
.footer-copy {
  grid-column: 1 / -1;
  padding-top: 24px; margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px; opacity: 0.6;
}
@media (max-width: 720px) {
  .landing-footer .section-inner { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

/* ---- Hero responsive tweaks ---- */
@media (max-width: 720px) {
  .hero { padding: 56px 20px 40px; }
  .hero-paper-stack { margin-top: 36px; }
  .hero-paper-back { left: 0; width: 88%; }
  .hero-paper-front { width: 96%; }
  .btn-xl { padding: 12px 18px; font-size: 14px; }
  .hiw, .types, .topics, .audience, .final-cta { padding: 56px 0; }
}

/* ---- Prose pages (About, Contact, Privacy, Terms) ---- */
.prose-wrap {
  max-width: 760px; margin: 0 auto;
  padding: 56px 24px 64px;
}
.prose-header {
  text-align: center; margin-bottom: 40px;
  padding-bottom: 32px; border-bottom: 1px solid var(--line);
}
.prose-header h1 {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: clamp(32px, 5vw, 44px);
  color: var(--ink); line-height: 1.15;
  margin: 14px 0 8px; letter-spacing: -0.02em;
}
.prose-meta {
  font-size: 14px; color: var(--muted);
}
.prose {
  font-size: 16px; line-height: 1.7; color: var(--ink-soft);
}
.prose-lede {
  font-size: 18px; line-height: 1.6;
  color: var(--ink); margin-bottom: 32px;
  padding: 20px 24px; border-radius: 12px;
  background: var(--blue-soft); border-left: 4px solid var(--blue);
}
.prose h2 {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 24px; color: var(--ink);
  margin-top: 40px; margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.prose h3 {
  font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700;
  font-size: 18px; color: var(--ink);
  margin-top: 28px; margin-bottom: 8px;
}
.prose p { margin-bottom: 16px; }
.prose ul { margin: 0 0 18px; padding-left: 22px; }
.prose ul li { margin-bottom: 8px; }
.prose a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.prose a:hover { color: var(--blue-deep); }
.prose strong { color: var(--ink); font-weight: 700; }
.prose code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.9em;
  padding: 1px 6px; border-radius: 4px;
  background: var(--bg-soft); color: var(--ink);
}

.contact-email {
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: center;
  padding: 28px;
  background: var(--bg-soft);
  border-radius: 14px;
  margin: 20px 0;
}
.contact-email-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px; font-weight: 700; color: var(--blue-deep);
  text-decoration: none; letter-spacing: 0.01em;
  word-break: break-all;
}
.contact-email-link:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 4px; }

.contact-email-copy {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px;
  background: white; border: 1.5px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--ink-soft);
  cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.15s;
}
.contact-email-copy:hover {
  border-color: var(--blue); color: var(--blue);
  transform: translateY(-1px);
}
.contact-email-copy.copied {
  background: var(--green-soft); border-color: #86efac;
  color: #166534;
}
.contact-email-copy .copy-icon { font-size: 14px; line-height: 1; }
@media (max-width: 480px) {
  .contact-email-link { font-size: 17px; }
}

/* ===== Contact form (on /contact.php) ===== */

.contact-form {
  background: white;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  margin-bottom: 32px;
  display: grid; gap: 18px;
}
.contact-form .form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 600px) {
  .contact-form .form-row { grid-template-columns: 1fr; }
}
.contact-form .form-field { display: grid; gap: 6px; }
.contact-form label {
  font-size: 13px; font-weight: 700; color: var(--ink);
  letter-spacing: 0.01em;
}
.contact-form .req { color: var(--coral); font-weight: 700; }
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form select,
.contact-form textarea {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1.5px solid var(--line);
  background: white; font-family: inherit; font-size: 14px; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.contact-form input:focus,
.contact-form select:focus,
.contact-form textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}
.contact-form textarea {
  resize: vertical; min-height: 140px; line-height: 1.55;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.contact-form .field-help {
  font-size: 12px; color: var(--muted);
}
.contact-form .field-error {
  font-size: 13px; color: #b91c1c; font-weight: 600;
}
.contact-form .form-field.has-error input,
.contact-form .form-field.has-error textarea,
.contact-form .form-field.has-error select {
  border-color: #fca5a5;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}
.contact-form .form-global-error {
  padding: 12px 16px; border-radius: 10px;
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fecaca;
  font-size: 13px; font-weight: 600;
}
.contact-form .form-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding-top: 8px;
}
.contact-form .form-note {
  font-size: 12px; color: var(--muted); flex: 1; min-width: 200px;
}
.contact-form .form-note a { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }

/* Honeypot — visible to bots, invisible to humans + screen readers */
.honeypot {
  position: absolute; left: -9999px; top: 0;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* Success banner shown after PRG redirect (?sent=1) */
.form-success {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 22px; border-radius: 12px;
  background: var(--green-soft); border: 1.5px solid #86efac;
  color: #166534; margin-bottom: 28px;
}
.form-success-icon {
  display: grid; place-items: center;
  width: 32px; height: 32px; flex-shrink: 0;
  background: var(--green); color: white;
  border-radius: 50%; font-size: 18px; font-weight: 700;
}
.form-success strong { display: block; font-size: 15px; margin-bottom: 2px; color: #14532d; }
.form-success p { font-size: 14px; color: #166534; margin: 0; }

/* Webmail compose buttons — one-click open in Gmail / Outlook / Yahoo */
.contact-webmail {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: center;
  margin: 14px 0 8px;
}
.contact-webmail-label {
  font-size: 13px; color: var(--muted);
  margin-right: 4px;
}
.webmail-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  text-decoration: none;
  border: 1.5px solid var(--line);
  background: white; color: var(--ink-soft);
  transition: transform 0.15s, border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}
.webmail-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px -4px rgba(15, 23, 42, 0.1);
}
.webmail-btn .webmail-glyph { font-size: 14px; line-height: 1; }

/* Per-provider brand accents on hover only — keeps the page calm
   when at rest, signals the destination on intent. */
.webmail-gmail:hover   { border-color: #ea4335; color: #c5221f; }
.webmail-outlook:hover { border-color: #0078d4; color: #005a9e; }
.webmail-yahoo:hover   { border-color: #6001d2; color: #4a01a3; }

@media (max-width: 480px) {
  .contact-webmail { gap: 8px; }
  .webmail-btn { padding: 8px 12px; font-size: 12px; }
}

.prose-cta {
  text-align: center; margin-top: 56px; padding: 32px 24px;
  background: var(--bg-soft); border-radius: 16px;
  border: 1px solid var(--line);
}
.prose-cta h3 {
  font-family: 'Fraunces', serif; font-size: 22px; font-weight: 700;
  color: var(--ink); margin-bottom: 18px;
}

/* =============================================================
   HUB — /studio/ worksheet-type picker
   ============================================================= */
.hub-wrap {
  max-width: 1100px; margin: 0 auto;
  padding: 48px 24px 64px;
}
.hub-header { text-align: center; margin-bottom: 36px; }
.hub-title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 36px; color: var(--ink); margin-bottom: 8px;
}
.hub-subtitle { color: var(--muted); font-size: 15px; max-width: 600px; margin: 0 auto; }

.hub-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.hub-card {
  display: flex; flex-direction: column;
  background: white; border: 1.5px solid var(--line);
  border-radius: 16px; padding: 28px 24px;
  text-decoration: none; color: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.hub-card:hover {
  border-color: var(--blue); transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.15);
}
.hub-card.is-disabled {
  pointer-events: none; opacity: 0.55;
  background: var(--bg-soft);
}
.hub-card-glyph { font-size: 40px; margin-bottom: 14px; line-height: 1; }
.hub-card-body { flex: 1; margin-bottom: 16px; }
.hub-card-body h2 {
  font-family: 'Fraunces', serif; font-size: 20px; font-weight: 700;
  color: var(--ink); margin-bottom: 6px;
  display: flex; align-items: center; gap: 10px;
}
.hub-card-body p {
  font-size: 13px; color: var(--ink-soft);
  line-height: 1.55; margin-bottom: 10px;
}
.hub-card-example {
  display: inline-block; font-family: 'JetBrains Mono', monospace;
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
  background: var(--bg-soft); color: var(--muted);
  letter-spacing: 0.05em;
}
.hub-card-example strong { color: var(--ink); font-weight: 700; }
.hub-card-go {
  font-size: 13px; font-weight: 700; color: var(--blue);
  display: inline-flex; align-items: center; gap: 4px;
}
.hub-card.is-disabled .hub-card-go { color: var(--muted); }
.hub-soon {
  font-size: 9px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--yellow-soft); color: #92400e;
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* =============================================================
   ADMIN — Developer word-list console
   ============================================================= */
.admin-page { background: var(--bg-soft); }

/* Login screen */
.admin-login-wrap {
  min-height: calc(100vh - 65px);
  display: grid; place-items: center;
  padding: 32px 16px;
}
.admin-card {
  width: 100%; max-width: 420px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}
.admin-card-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 22px;
}
.admin-card-head .admin-glyph {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--blue-soft);
  display: grid; place-items: center; font-size: 22px;
}
.admin-card-head h1 { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 700; color: var(--ink); }
.admin-card-head p  { font-size: 13px; color: var(--muted); margin-top: 2px; }

.admin-form .control-label { margin-top: 12px; }
.admin-form .control-label:first-child { margin-top: 0; }
.admin-submit { width: 100%; justify-content: center; margin-top: 18px; padding: 12px; }
.admin-alert {
  padding: 10px 14px; border-radius: 10px;
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fecaca;
  font-size: 13px; margin-bottom: 14px;
}
.admin-hint {
  font-size: 12px; color: var(--muted);
  margin-top: 18px; padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.admin-hint code {
  background: var(--bg-soft); padding: 1px 6px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
}

/* Console layout */
.admin-wrap {
  max-width: 1100px; margin: 0 auto;
  padding: 28px 24px 48px;
}
.admin-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 22px;
}
.admin-title { font-family: 'Fraunces', serif; font-size: 28px; font-weight: 700; color: var(--ink); }
.admin-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

.admin-flash {
  padding: 12px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  margin-bottom: 18px;
}
.admin-flash-ok  { background: var(--green-soft); color: #166534; border: 1px solid #bbf7d0; }
.admin-flash-err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.admin-empty {
  background: white; border: 1px dashed var(--line);
  border-radius: 14px; padding: 36px; text-align: center;
  color: var(--muted); font-size: 14px;
}

/* Data table */
.admin-table {
  width: 100%; border-collapse: collapse;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.admin-table th, .admin-table td {
  padding: 14px 18px; text-align: left; vertical-align: middle;
  font-size: 14px;
}
.admin-table th {
  background: var(--bg-soft);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.admin-table tbody tr { border-top: 1px solid var(--line); transition: background 0.1s; }
.admin-table tbody tr:hover { background: var(--bg-soft); }
.admin-table .num { text-align: right; width: 80px; }
.admin-table .row-actions { text-align: right; width: 180px; white-space: nowrap; }
.admin-list-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.admin-list-title:hover { color: var(--blue); }
.theme-tag, .grade-tag, .topic-tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--bg-soft); color: var(--ink-soft);
}
.grade-tag { background: var(--blue-soft); color: var(--blue-deep); }
.topic-tag { background: #fef3c7; color: #92400e; }
.muted { color: var(--muted); font-size: 12px; }

.row-btn {
  display: inline-block;
  padding: 6px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  background: white; border: 1.5px solid var(--line); color: var(--ink-soft);
  text-decoration: none; cursor: pointer;
  font-family: inherit;
  margin-left: 4px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.row-btn:hover { border-color: var(--blue); color: var(--blue); }
.row-btn-danger:hover { border-color: var(--coral); color: var(--coral); background: #fef2f2; }

/* Admin section nav — Word Lists / Messages tabs */
.admin-section-nav {
  display: flex; gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.admin-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px;
  font-size: 14px; font-weight: 700;
  color: var(--muted); text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.admin-tab:hover { color: var(--ink); }
.admin-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}
.admin-tab-badge {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 20px; padding: 0 7px;
  background: var(--coral); color: white;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
}

/* Admin filter pills on the messages list */
.admin-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-filter-pill {
  display: inline-block; padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-soft); text-decoration: none;
  background: white; border: 1.5px solid var(--line);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.admin-filter-pill:hover { border-color: var(--blue); color: var(--blue); }
.admin-filter-pill.active { background: var(--blue); border-color: var(--blue); color: white; }

/* Messages list table */
.messages-table .msg-row.is-unread { background: var(--blue-soft); }
.messages-table .msg-row.is-unread:hover { background: var(--blue-line); }
.messages-table th { font-size: 11px; }
.msg-status-cell { width: 36px; text-align: center; }
.msg-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--blue);
}
.msg-check { color: var(--green); font-weight: 700; font-size: 16px; margin-left: 2px; }
.msg-from { width: 200px; min-width: 0; }
.msg-from-link {
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
}
.msg-from-link strong { color: var(--ink); font-size: 14px; }
.msg-email { font-size: 12px; color: var(--muted); }
.msg-subject {
  display: flex; flex-direction: column; gap: 2px;
  text-decoration: none; color: inherit;
}
.msg-subject-line { font-weight: 600; color: var(--ink); font-size: 14px; }
.msg-preview { font-size: 12px; color: var(--muted); line-height: 1.4; }
.msg-when { white-space: nowrap; color: var(--muted); font-size: 12px; }

/* Messages — detail view */
.msg-detail {
  background: white; border: 1px solid var(--line);
  border-radius: 14px; padding: 28px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.msg-detail-meta {
  display: grid; gap: 10px;
  padding-bottom: 20px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.msg-meta-row {
  display: grid; grid-template-columns: 110px 1fr;
  gap: 12px; font-size: 13px;
}
.msg-meta-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
}
.msg-ua { font-family: 'JetBrains Mono', monospace; font-size: 11px; word-break: break-all; }
.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}
.status-pill-unread  { background: var(--blue-soft);  color: var(--blue-deep); }
.status-pill-read    { background: var(--bg-soft);    color: var(--ink-soft); }
.status-pill-replied { background: var(--green-soft); color: #166534; }

.msg-detail-body h2 { font-size: 14px; color: var(--muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.1em; }
.msg-body-text {
  white-space: pre-wrap; word-wrap: break-word;
  font-family: inherit; font-size: 15px; line-height: 1.65;
  color: var(--ink); margin: 0;
  padding: 18px; background: var(--bg-soft); border-radius: 10px;
}

.msg-detail-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--line);
}
.inline-form { display: inline; margin: 0; }
.btn.btn-danger:hover { border-color: var(--coral); color: var(--coral); background: #fef2f2; }

/* Editor form */
.admin-form-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.admin-form-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px;
  margin-bottom: 18px;
}
.admin-form-grid.two-col { grid-template-columns: 3fr 1fr; }
@media (max-width: 720px) {
  .admin-form-grid,
  .admin-form-grid.two-col { grid-template-columns: 1fr; }
}
.admin-words { min-height: 200px; font-family: 'JetBrains Mono', monospace; font-size: 13px; letter-spacing: 0.05em; }
.admin-form-actions { display: flex; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.control-group.has-error .control-input { border-color: var(--coral); }
.admin-field-error { font-size: 12px; color: #b91c1c; margin-top: 6px; font-weight: 600; }

/* =============================================================
   MOBILE RESPONSIVE PASS — phones (≤480px) and tablets (≤768px)
   Adds the missing intermediate breakpoints so the studio,
   landing, topics and admin pages all behave on small screens.
   ============================================================= */

/* ---- Tablets (≤768px): tighten studio, scale headings down ---- */
@media (max-width: 768px) {
  /* Studio: stack panel above preview (already done at 960px, but
     also pad the preview area down so the worksheet fits) */
  .preview-area { padding: 16px; }
  .paper { padding: 36px 28px; min-height: auto; }
  .ws-title { font-size: 24px; margin-bottom: 20px; }
  .ws-header { padding-bottom: 16px; margin-bottom: 20px; }
  .ws-name-row { gap: 18px; font-size: 12px; }
  .ws-name-row .blank { min-width: 120px; }
  .ws-name-row .blank.short { min-width: 80px; }

  /* Worksheet list collapses to single column on the preview pane,
     so two-column word rows don't get crushed. The PDF export
     stays at two columns since it generates from its own template. */
  .ws-list { grid-template-columns: 1fr; gap: 10px 0; }
  .ws-answer-grid { grid-template-columns: repeat(2, 1fr); gap: 6px 18px; }

  /* Word-list cards on topic pages */
  .word-list-grid { grid-template-columns: 1fr; }
  .topic-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

  /* Nav tightening when breadcrumb is hidden */
  .nav-inner { gap: 10px; padding: 12px 16px; }
  .landing-nav-inner { padding: 14px 16px; }

  /* Section padding breathing room */
  .section-inner, .prose-wrap, .topic-wrap, .hub-wrap { padding-left: 20px; padding-right: 20px; }

  /* Topic chips: tighter spacing */
  .topic-chips { gap: 5px; }
  .topic-chip { padding: 7px 11px; font-size: 12px; }

  /* Theme grid: 2 columns instead of 3 */
  .theme-grid { grid-template-columns: repeat(2, 1fr); }

  /* Studio worksheet-type tabs (Word Scramble / Missing Letters) */
  .ws-type-tab { padding: 12px 4px; font-size: 12px; }
  .ws-type-tab .ws-type-glyph { font-size: 14px; }
}

/* ---- Phones (≤480px): single-column everything, larger tap targets ---- */
@media (max-width: 480px) {
  /* Logo: drop the gap, tighten font */
  .logo { font-size: 17px; gap: 8px; }
  .logo-mark { width: 30px; height: 30px; font-size: 16px; }

  /* Nav: compact actions */
  .nav-inner { padding: 10px 14px; gap: 8px; }
  .landing-nav-inner { padding: 12px 14px; }
  .nav-actions, .landing-nav-actions { gap: 6px; }

  /* Buttons: 44px min tap target */
  .btn { padding: 11px 16px; min-height: 44px; }
  .btn-xl { padding: 13px 20px; font-size: 14px; min-height: 48px; }
  .row-btn { padding: 9px 14px; min-height: 36px; }

  /* Studio panel: trim outer padding so controls breathe */
  .panel { padding: 20px 16px; }
  .panel-header { margin-bottom: 18px; padding-bottom: 14px; }
  .panel-title { font-size: 19px; }
  .preview-area { padding: 12px; }
  .paper { padding: 28px 18px; }

  /* Make the worksheet preview itself smaller on phones —
     the full 794px design dwarfs a 360px screen; scale it down
     visually while keeping content readable. */
  .ws-title { font-size: 20px; margin-bottom: 16px; }
  .ws-name-row { gap: 14px; font-size: 11px; }
  .ws-name-row .blank { min-width: 90px; }
  .ws-name-row .blank.short { min-width: 60px; }
  .ws-word { font-size: 13px; letter-spacing: 0.08em; }
  .ws-word.missing-word { font-size: 14px; }

  /* Worksheet-type tabs: hide glyph on very small screens */
  .ws-type-tab { padding: 11px 2px; font-size: 11px; }
  .ws-type-tab .ws-type-glyph { display: none; }

  /* Topic chips on Studio tab + landing topic cloud */
  .topic-chip { padding: 6px 10px; font-size: 12px; }
  .topic-chips { gap: 4px; }

  /* Theme grid: stack into single column */
  .theme-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .theme-card .glyph { font-size: 24px; }

  /* Topic pages: single column grids */
  .topic-grid,
  .word-list-grid,
  .tip-grid,
  .related-grid,
  .hub-grid { grid-template-columns: 1fr; }
  .topic-wrap, .hub-wrap { padding: 32px 16px 48px; }
  .topic-card, .word-list-card, .tip-card, .hub-card { padding: 18px; }
  .topic-section-title { font-size: 22px; }

  /* Answer key: 2 columns on phone instead of 3 */
  .ws-answer-grid { grid-template-columns: repeat(2, 1fr); }

  /* Preview toolbar: hide zoom controls (pinch-zoom is more natural
     on mobile anyway) and stack actions tightly */
  .zoom-group { display: none; }
  .preview-toolbar { padding: 8px 10px; }
  .preview-toolbar-actions { gap: 6px; }
  .preview-toolbar-actions .btn-sm { padding: 9px 12px; font-size: 12px; min-height: 40px; }
  .icon-btn { width: 38px; height: 38px; }

  /* Hero on phones: tighter padding, smaller paper stack */
  .hero { padding: 40px 16px 32px; }
  .hero-paper-stack { margin-top: 28px; max-width: 100%; }
  .hero-paper { padding: 16px; }
  .hero-paper-back { display: none; } /* hide back paper on very small screens */
  .hero-paper-front { width: 100%; margin-left: 0; }

  /* Library stats: stack to single column on phones */
  .library-stats { grid-template-columns: 1fr 1fr !important; gap: 12px; }
  .library-stats .stat-num { font-size: 22px !important; }

  /* Hub picker on /studio/ */
  .hub-title { font-size: 28px; }
  .hub-card { padding: 22px 18px; }
  .hub-card-glyph { font-size: 32px; margin-bottom: 10px; }

  /* Prose pages (About/Privacy/Terms/Contact) */
  .prose-wrap { padding: 36px 18px 48px; }
  .prose-header { margin-bottom: 28px; padding-bottom: 22px; }
  .prose { font-size: 15px; }
  .prose h2 { font-size: 21px; margin-top: 32px; }
  .prose h3 { font-size: 17px; margin-top: 24px; }

  /* Contact form: tighter padding */
  .contact-form { padding: 20px; }

  /* Admin: stack section nav, reduce table padding */
  .admin-section-nav { overflow-x: auto; }
  .admin-tab { padding: 11px 14px; font-size: 13px; white-space: nowrap; }
  .admin-table th, .admin-table td { padding: 10px 12px; font-size: 13px; }
  .admin-table .row-actions { width: auto; }
  .msg-meta-row { grid-template-columns: 1fr; gap: 4px; }
  .msg-meta-row .msg-meta-label { margin-top: 8px; }

  /* Site foot: stack vertically on phones */
  .site-foot-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ---- Very small screens (≤360px): final fallback ---- */
@media (max-width: 360px) {
  .section-inner, .prose-wrap, .topic-wrap, .hub-wrap { padding-left: 14px; padding-right: 14px; }
  .panel { padding: 16px 12px; }
  .preview-area { padding: 10px; }
  .paper { padding: 22px 14px; }
  .hero { padding: 32px 12px 28px; }
  .hero-title { font-size: 30px; }
  .nav-inner, .landing-nav-inner { padding: 10px 10px; }
  .logo-text { display: none; } /* show only the W badge on tiny screens */
}
