:root {
  --bg: #f5ecdc;
  --bg-deep: #ead7bd;
  --paper: #fffdfa;
  --surface: rgba(255, 252, 247, 0.76);
  --surface-strong: rgba(255, 250, 242, 0.94);
  --ink: #1d2f36;
  --muted: #58656d;
  --line: rgba(29, 47, 54, 0.12);
  --accent: #d96b3a;
  --accent-deep: #ab4f27;
  --teal: #2d7f72;
  --honey: #e4b550;
  --sage: #537162;
  --shadow: 0 28px 80px rgba(36, 40, 39, 0.14);

  font-family: "Manrope", "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(228, 181, 80, 0.28), transparent 34%),
    linear-gradient(180deg, #f8f1e7 0%, #f3eadf 40%, #efe4d5 100%);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: transparent;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled, input:disabled, select:disabled, textarea:disabled {
  cursor: not-allowed;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 3vw, 2rem) 3rem;
}

.hero {
  margin-bottom: 1.5rem;
}

.module-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
  align-items: center;
}

.suite-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(29, 47, 54, 0.08);
  color: var(--teal);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.hero-copy, .panel, .preview-toolbar, .report-sheet {
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
}

.hero-copy, .panel, .preview-toolbar {
  background: var(--surface);
  backdrop-filter: blur(18px);
}

.hero-copy {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: 32px;
}

.eyebrow, .panel-kicker, .report-kicker, .meta-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  font-weight: 800;
}

.eyebrow, .panel-kicker, .report-kicker {
  color: var(--accent-deep);
}

.hero h1, .panel h2, .preview-toolbar h2, .report-title {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", Georgia, serif;
  line-height: 1;
}

.hero h1 {
  margin-top: 0.55rem;
  font-size: clamp(2.6rem, 7vw, 4.8rem);
  max-width: 12ch;
}

.mockup-banner {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.1rem;
  padding: 0.95rem 1rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(29, 47, 54, 0.08);
}

.mockup-banner strong {
  font-size: 0.95rem;
}

.mockup-banner span {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.mockup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.editor-form {
  display: grid;
  gap: 1rem;
}

.panel {
  border-radius: 32px;
  padding: 1.5rem;
}

.panel-section {
  border: none;
  margin: 0;
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.panel-kicker {
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

.form-field input[type="text"],
.form-field input[type="date"],
.form-field select,
.form-field textarea {
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  outline: none;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(217, 107, 58, 0.15);
}

.age-display {
  padding: 0.6rem 0.8rem;
  background: rgba(29, 47, 54, 0.04);
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.92rem;
  min-height: 2.4rem;
  display: flex;
  align-items: center;
}

/* Domain Tabs styling */
.domain-tabs-header {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.domain-tab-btn {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
  padding: 0.5rem 0.25rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.domain-tab-btn[data-domain="social"].is-active { background: var(--teal); color: #fff; border-color: var(--teal); }
.domain-tab-btn[data-domain="language"].is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.domain-tab-btn[data-domain="cognitive"].is-active { background: var(--honey); color: #fff; border-color: var(--honey); }
.domain-tab-btn[data-domain="motor"].is-active { background: var(--sage); color: #fff; border-color: var(--sage); }

/* Milestone item list inside editor */
.milestone-item-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
}

.milestone-item-text {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
}

.milestone-item-rating {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
}

.rate-btn {
  background: #fff;
  border: 1px solid var(--line);
  padding: 0.35rem 0.2rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.rate-btn.r-0.is-active { background-color: #bdbdbd; color: #fff; border-color: #bdbdbd; }
.rate-btn.r-1.is-active { background-color: #f1c40f; color: #fff; border-color: #f1c40f; }
.rate-btn.r-2.is-active { background-color: #e67e22; color: #fff; border-color: #e67e22; }
.rate-btn.r-3.is-active { background-color: #27ae60; color: #fff; border-color: #27ae60; }

.milestone-item-notes {
  margin-top: 0.2rem;
}

.milestone-item-notes input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  background: rgba(255,255,255,0.6);
}

.counter {
  align-self: flex-end;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  transition: all 0.2s ease;
}

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

.button-primary:hover {
  background: var(--accent-deep);
}

.button-ghost {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--teal);
}

.button-ghost:hover {
  background: #fff;
}

/* Preview Column */
.preview-column {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-radius: 24px;
}

.preview-toolbar h2 {
  font-size: 1.4rem;
}

.draft-status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.preview-actions {
  display: flex;
  gap: 0.5rem;
}

/* Report Sheet */
.report-sheet {
  background: var(--paper);
  border-radius: 24px;
  padding: 2rem;
  min-height: 10.5in;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  gap: 1.2rem;
}

.report-header {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
}

.report-title {
  font-size: 2.2rem;
  margin-top: 0.2rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.meta-card {
  background: rgba(29, 47, 54, 0.02);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}

.meta-card strong {
  display: block;
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

/* Progress bars overview in preview */
.progress-overview-section {
  background: rgba(29,47,54,0.01);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem 1.2rem;
}

.section-title {
  margin: 0 0 0.8rem;
  font-family: "Fraunces", serif;
  font-size: 1.15rem;
}

.progress-bar-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}

.progress-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
}

.progress-zone {
  color: var(--accent-deep);
}

.progress-track {
  height: 10px;
  background: rgba(29,47,54,0.08);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 5px;
}

.fill-social { background-color: var(--teal); }
.fill-language { background-color: var(--accent); }
.fill-cognitive { background-color: var(--honey); }
.fill-motor { background-color: var(--sage); }

/* Table breakdowns */
.milestones-detail-section {
  display: grid;
  gap: 1.2rem;
}

.preview-domain-group {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}

.preview-domain-title {
  margin: 0 0 0.5rem;
  font-family: "Fraunces", serif;
  font-size: 1.1rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--line);
}

.pr-social .preview-domain-title { border-bottom-color: var(--teal); color: var(--teal); }
.pr-language .preview-domain-title { border-bottom-color: var(--accent); color: var(--accent-deep); }
.pr-cognitive .preview-domain-title { border-bottom-color: var(--honey); color: #d19f38; }
.pr-motor .preview-domain-title { border-bottom-color: var(--sage); color: var(--sage); }

.milestone-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.milestone-table th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
}

.milestone-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px dashed rgba(29, 47, 54, 0.08);
  vertical-align: top;
}

.milestone-table tr:last-child td {
  border-bottom: none;
}

.preview-rating-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  font-size: 0.7rem;
  text-transform: uppercase;
  min-width: 75px;
  text-align: center;
}

/* Narrative sections */
.narrative-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.report-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem 1.2rem;
}

.primary-card {
  background: rgba(45, 127, 114, 0.02);
  border-color: rgba(45, 127, 114, 0.2);
}

.family-card {
  background: rgba(228, 181, 80, 0.04);
  border-color: rgba(228, 181, 80, 0.25);
}

.card-title {
  margin: 0 0 0.5rem;
  font-family: "Fraunces", serif;
  font-size: 1.1rem;
}

.strengths-growth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.report-copy {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.report-copy.placeholder {
  color: var(--muted);
  font-style: italic;
}

.report-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

/* Theme Toggle button override */
html[data-theme="dark"] .suite-link {
  background: rgba(40, 36, 30, 0.74);
  border-color: rgba(240, 230, 213, 0.08);
  color: var(--cn-accent);
}

/* Print view rules */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  
  .app-shell {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .hero, .panel, .preview-toolbar, .lang-switcher {
    display: none !important;
  }

  .workspace {
    display: block !important;
  }

  .preview-column {
    display: block !important;
  }

  .report-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: 0 !important;
    max-height: 100vh;
    aspect-ratio: auto;
    background: transparent !important;
  }

  /* Force page size to portrait Letter */
  @page {
    size: letter portrait;
    margin: 0.4in;
  }
  
  .preview-domain-group, .report-card {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* Mobile responsive rules */
@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .domain-tabs-header {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.2rem;
  }

  .progress-bar-grid {
    grid-template-columns: 1fr;
  }

  .strengths-growth-grid {
    grid-template-columns: 1fr;
  }
}
