/* =========================================================
   CalmChildTools - Social Story Generator (Ages 6-14)
   Large, readable, calm UI + Clean Print/PDF Stylesheet
   ========================================================= */

:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-soft: #f3efe7;
  --border: #e2dacd;
  --text: #23302b;
  --text-muted: #5c6b64;
  --primary: #2f6f5e;
  --primary-hover: #245749;
  --primary-light: #e8f3ee;
  --accent: #d98a2b;
  --accent-light: #fdf2dc;
  --radius: 16px;
  --shadow: 0 6px 22px rgba(45, 58, 51, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.6;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden {
  display: none !important;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}

.brand-name {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.brand-tag {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
}

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

.pill {
  background: var(--surface-soft);
  color: var(--primary);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}

/* Hero & Stepper */
.hero {
  text-align: center;
  padding: 36px 0 24px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.25;
  color: var(--text);
}

.hero-sub {
  max-width: 740px;
  margin: 0 auto 28px;
  font-size: 19px;
  color: var(--text-muted);
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.step-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.step-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.step-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step-btn.done {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
}

.step-btn.active .step-num {
  background: rgba(255, 255, 255, 0.25);
}

.step-line {
  width: 28px;
  height: 2px;
  background: var(--border);
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.panel-header h2 {
  margin: 0 0 6px;
  font-size: 25px;
}

.panel-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 17px;
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tab {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.filter-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Template Grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.template-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: border-color 0.15s ease, transform 0.15s ease;
  cursor: pointer;
  text-align: left;
}

.template-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.template-card.featured {
  border-color: #b7d6ca;
  background: #fdfcf9;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px;
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.card-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary);
}

.card-badge.highlight {
  background: var(--accent-light);
  color: #9a5404;
}

.template-card h3 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--text);
}

.template-card p {
  margin: 0;
  font-size: 16px;
  color: var(--text-muted);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  padding-top: 8px;
  border-top: 1px solid #edf2ef;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger-ghost {
  background: transparent;
  color: #b91c1c;
  border-color: #fecaca;
  padding: 6px 12px;
  font-size: 14px;
}

.btn-danger-ghost:hover {
  background: #fef2f2;
}

.btn-lg {
  padding: 14px 26px;
  font-size: 18px;
}

/* Step 2 Form & Page Editor */
.quick-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.field label {
  display: block;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.field input,
.field select,
.editor-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--text);
}

.field input:focus,
.field select:focus,
.editor-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.editor-pages {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.editor-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  background: #fcfdfd;
}

.editor-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.page-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.editor-card-body {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  align-items: start;
}

.visual-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.visual-thumb {
  width: 132px;
  height: 132px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px;
}

.visual-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.icon-select {
  width: 100%;
  font-size: 15px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.upload-label {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.upload-label:hover {
  background: #d2ebe4;
}

.upload-input {
  display: none;
}

.editor-textarea {
  min-height: 128px;
  resize: vertical;
  line-height: 1.55;
}

.panel-footer {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

/* Step 3 Print Toolbar & Preview */
.print-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.toolbar-options {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.toggle-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.toggle-option input {
  width: 19px;
  height: 19px;
  accent-color: var(--primary);
}

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

/* Story Preview Cards */
.story-preview {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.story-cover {
  border: 2px solid var(--primary);
  border-radius: 14px;
  padding: 24px 28px;
  background: var(--primary-light);
  text-align: center;
}

.story-cover h3 {
  margin: 0 0 6px;
  font-size: 28px;
  color: var(--text);
}

.story-cover p {
  margin: 0;
  font-size: 18px;
  color: var(--text-muted);
}

.story-cards-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.story-preview.compact-layout .story-cards-wrap {
  grid-template-columns: repeat(2, 1fr);
}

.story-card {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.story-card-num {
  align-self: flex-start;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.story-card-visual {
  width: 184px;
  height: 184px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid #e5ece8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  overflow: hidden;
}

.story-card-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.story-card-text {
  margin: 0;
  font-size: 21px;
  line-height: 1.55;
  color: var(--text);
  max-width: 520px;
}

/* Ink-Saver Mode */
.story-preview.ink-saver .story-cover {
  background: #fff;
  border-color: #222;
}

.story-preview.ink-saver .story-card {
  border-color: #333;
}

.story-preview.ink-saver .story-card-visual {
  background: #fff;
  border: 1px solid #999;
  filter: grayscale(100%);
}

.story-preview.ink-saver .story-card-num {
  background: #fff;
  border: 1px solid #666;
  color: #111;
}

/* FAQ & Footer */
.faq-section {
  padding: 12px 0 36px;
}

.faq-section h2 {
  font-size: 24px;
  margin-bottom: 18px;
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.faq-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.faq-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.faq-card p {
  margin: 0;
  font-size: 16px;
  color: var(--text-muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 0;
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 720px) {
  .step-line {
    display: none;
  }
  .editor-card-body {
    grid-template-columns: 1fr;
  }
  .story-preview.compact-layout .story-cards-wrap {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 20px;
  }
}

/* =========================================================
   Clean Print / Save-as-PDF Rules
   ========================================================= */
@media print {
  body {
    background: #fff;
    font-size: 16px;
  }

  .no-print {
    display: none !important;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .panel {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }

  .story-cover {
    margin-bottom: 16px;
    padding: 16px 20px;
  }

  .story-cards-wrap {
    gap: 14px;
  }

  .story-card {
    padding: 18px;
    border-width: 1.5px;
  }

  .story-card-visual {
    width: 120px;
    height: 120px;
    font-size: 58px;
  }

  .story-card-text {
    font-size: 18px;
  }
}

/* =========================================================
   Shared Multi-Tool Navigation + Token Board + Visual Schedule
   ========================================================= */

.main-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-link {
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.nav-link:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.nav-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Token Board Styles */
.tb-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 22px;
}

.tb-board {
  border: 3px solid var(--primary);
  border-radius: 18px;
  padding: 28px;
  background: #fff;
  text-align: center;
  position: relative;
}

.tb-board.celebrating {
  border-color: #d97706;
  box-shadow: 0 0 0 6px rgba(244, 185, 66, 0.25);
}

.tb-reward-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--primary-light);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 18px 24px;
  margin-bottom: 24px;
}

.tb-reward-visual {
  width: 92px;
  height: 92px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  overflow: hidden;
  flex-shrink: 0;
}

.tb-reward-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tb-reward-text {
  text-align: left;
}

.tb-reward-kicker {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.tb-reward-title {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.tb-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 16px;
  max-width: 780px;
  margin: 0 auto 24px;
}

.tb-slot {
  aspect-ratio: 1 / 1;
  border: 3px dashed var(--border);
  border-radius: 18px;
  background: #f9fbfa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}

.tb-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  display: block;
}

.tb-slot:hover {
  border-color: var(--primary);
  transform: scale(1.03);
}

.tb-slot.filled {
  border-style: solid;
  border-color: var(--primary);
  background: #fff;
}

.tb-banner {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  color: #92400e;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 18px;
}

.tb-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tb-timer-bar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 17px;
  font-weight: 700;
}

.tb-cutout-sheet {
  display: none;
  margin-top: 24px;
  border-top: 2px dashed #666;
  padding-top: 16px;
  text-align: center;
}

.tb-cutout-grid {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.tb-cutout-item {
  width: 80px;
  height: 80px;
  border: 2px dashed #444;
  border-radius: 12px;
  background: #fff;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tb-cutout-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Visual Schedule Styles */
.vs-mode-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.vs-progress-wrap {
  margin-bottom: 20px;
}

.vs-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.vs-progress-track {
  height: 14px;
  background: var(--surface-soft);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.vs-progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.25s ease;
}

.vs-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.vs-list.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.vs-item {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: all 0.15s ease;
  break-inside: avoid;
}

.vs-list.card-grid .vs-item {
  flex-direction: column;
  text-align: center;
  padding: 20px;
}

.vs-item.done {
  background: #edf7f3;
  border-color: var(--primary);
}

.vs-item.done .vs-item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.vs-item-main {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.vs-list.card-grid .vs-item-main {
  flex-direction: column;
}

.vs-check {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 3px solid var(--primary);
  background: #fff;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.vs-item.done .vs-check {
  background: var(--primary);
}

.vs-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5ece8;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.vs-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.vs-list.card-grid .vs-icon {
  width: 112px;
  height: 112px;
  border-radius: 16px;
  padding: 4px;
}

.vs-item-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.vs-item-edit {
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  width: 100%;
  max-width: 320px;
}

.vs-item-actions {
  display: flex;
  gap: 6px;
}

.vs-list.written-only .vs-icon {
  display: none;
}

.vs-sheet.ink-saver .vs-item {
  border-color: #333;
  background: #fff;
}

.vs-sheet.ink-saver .vs-icon {
  filter: grayscale(100%);
}

@media print {
  .tb-cutout-sheet {
    display: block !important;
  }
  .tb-board {
    border-color: #222;
    padding: 18px;
  }
  .vs-item {
    border-color: #333;
  }
}
