:root {
  --forest-950: #0b2d28;
  --forest-900: #123c34;
  --forest-800: #1a5144;
  --forest-700: #246758;
  --forest-100: #dfece7;
  --cream: #f7f4ec;
  --paper: #fffdf8;
  --ink: #1b2825;
  --muted: #60706b;
  --line: #d7ddd8;
  --ochre: #c97d38;
  --ochre-soft: #f5e5d3;
  --sky: #d8eaf0;
  --success: #28735b;
  --danger: #a34a3a;
  --shadow: 0 14px 40px rgba(19, 49, 42, 0.09);
  --radius-lg: 24px;
  --radius-md: 15px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(201, 125, 56, 0.36);
  outline-offset: 2px;
}

.site-shell { min-height: 100vh; }

.masthead {
  position: relative;
  overflow: hidden;
  color: white;
  background: var(--forest-950);
}

.masthead__pattern {
  position: absolute;
  inset: 0;
  opacity: .24;
  background-image:
    radial-gradient(circle at 15% 90%, transparent 0 18%, rgba(255,255,255,.16) 18.2% 18.5%, transparent 18.7% 27%, rgba(255,255,255,.11) 27.2% 27.5%, transparent 27.7%),
    radial-gradient(circle at 85% 0%, rgba(216,234,240,.18), transparent 38%),
    linear-gradient(125deg, transparent 54%, rgba(201,125,56,.14) 54.2% 63%, transparent 63.2%);
}

.masthead__content {
  position: relative;
  max-width: 1480px;
  min-height: 174px;
  margin: 0 auto;
  padding: 38px 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand { display: flex; align-items: center; gap: 18px; }
.brand__mark {
  width: 64px; height: 64px; flex: 0 0 64px;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 18px;
  background: rgba(255,255,255,.08);
}
.brand__mark svg { width: 44px; fill: none; stroke: #e4c095; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow, .section-kicker, .step-label { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .15em; font-size: .73rem; font-weight: 800; }
.eyebrow { color: #e4c095; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4vw, 3.05rem); font-weight: 500; line-height: 1.04; letter-spacing: -.025em; }
.tagline { margin: 8px 0 0; color: rgba(255,255,255,.72); }
.masthead__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 750;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button svg, .icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button--primary { color: var(--forest-950); background: #f4c98f; }
.button--primary:hover { background: #ffd8a1; }
.button--ghost { color: white; border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.06); }
.button--ghost:hover { background: rgba(255,255,255,.12); }
.button--subtle { color: var(--forest-900); border-color: var(--line); background: white; }
.button--dark { color: white; background: var(--forest-800); }
.button--dark:hover { background: var(--forest-700); }
.button--danger { color: white; background: var(--danger); }
.button:disabled { opacity: .42; cursor: not-allowed; transform: none; }

main { max-width: 1480px; margin: 0 auto; padding: 32px 42px 46px; }

.setup {
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: minmax(250px, .68fr) minmax(540px, 1.32fr);
  gap: 28px;
  align-items: end;
}
.setup h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.72rem; font-weight: 500; }
.setup p:not(.section-kicker) { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.section-kicker { color: var(--ochre); }
.setup__fields { display: grid; grid-template-columns: minmax(260px, 1.4fr) minmax(140px, .65fr) minmax(150px, .7fr); gap: 12px; align-items: end; }
.field { display: grid; gap: 6px; }
.field > span, .writing-field > span { font-size: .78rem; color: var(--forest-900); font-weight: 800; letter-spacing: .02em; }
.field input, .field select {
  width: 100%; height: 45px; padding: 9px 12px;
  color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
}
.completion { padding-bottom: 4px; }
.completion__label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: .78rem; }
.completion__label span { color: var(--muted); }
.completion__label strong { color: var(--forest-800); }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #dfe3df; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ochre), #dda96d); transition: width .25s ease; }

.workspace {
  min-height: 680px;
  display: grid;
  grid-template-columns: minmax(230px, .74fr) minmax(380px, 1.18fr) minmax(320px, 1fr);
  background: var(--paper);
  border: 1px solid rgba(17,61,52,.10);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.part-nav { padding: 22px 14px; background: #eef1ec; border-right: 1px solid var(--line); }
.part-tab {
  width: 100%; min-height: 92px; padding: 14px 11px;
  display: grid; grid-template-columns: 34px 1fr 10px; gap: 9px; align-items: start;
  color: var(--ink); text-align: left; border: 0; border-radius: 13px; background: transparent;
  transition: background .16s ease, box-shadow .16s ease;
}
.part-tab + .part-tab { margin-top: 5px; }
.part-tab:hover { background: rgba(255,255,255,.7); }
.part-tab.is-active { background: white; box-shadow: 0 6px 22px rgba(27,60,53,.08); }
.part-tab__number { padding-top: 2px; color: var(--ochre); font-family: Georgia, serif; font-size: 1.05rem; font-weight: 700; }
.part-tab strong { display: block; font-size: .88rem; line-height: 1.3; }
.part-tab small { display: block; margin-top: 5px; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.part-tab__status { width: 8px; height: 8px; margin-top: 5px; border: 1.5px solid #9ba7a2; border-radius: 50%; }
.part-tab.is-complete .part-tab__status { border-color: var(--success); background: var(--success); box-shadow: 0 0 0 3px rgba(40,115,91,.12); }

.editor-panel { min-width: 0; padding: 30px 30px 24px; display: flex; flex-direction: column; }
.editor { flex: 1; }
.editor[hidden] { display: none; }
.editor__heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.step-label { color: var(--ochre); }
.editor h3, .lesson-preview h3 { margin: 0; color: var(--forest-950); font-family: Georgia, "Times New Roman", serif; font-size: 1.42rem; font-weight: 500; }
.editor__intro { max-width: 680px; margin: 10px 0 18px; color: var(--muted); font-size: .91rem; }
.text-button { padding: 2px; color: var(--forest-700); border: 0; border-bottom: 1px solid rgba(36,103,88,.25); background: transparent; font-size: .77rem; font-weight: 750; }
.prompt-box { margin: 0 0 18px; padding: 14px 16px; border-left: 3px solid var(--ochre); border-radius: 0 10px 10px 0; background: var(--ochre-soft); font-size: .8rem; }
.prompt-box strong { color: #81491f; }
.prompt-box ul { margin: 6px 0 0; padding-left: 18px; }
.prompt-box li + li { margin-top: 3px; }
.writing-field { position: relative; display: grid; gap: 7px; }
.writing-field textarea {
  width: 100%; min-height: 246px; resize: vertical; padding: 15px 16px 28px;
  color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff;
  line-height: 1.62; transition: border-color .16s ease, box-shadow .16s ease;
}
.writing-field textarea:focus { border-color: var(--ochre); box-shadow: 0 0 0 4px rgba(201,125,56,.09); }
.writing-field small { position: absolute; right: 12px; bottom: 9px; color: #87928d; font-size: .7rem; }
.action-checker { margin-top: 17px; padding: 15px 16px; border: 1px solid #c9ddd4; border-radius: var(--radius-md); background: #f0f7f4; }
.action-checker__heading { display: flex; justify-content: space-between; gap: 12px; color: var(--forest-900); font-size: .82rem; }
.action-checker__heading > div { display: flex; gap: 8px; align-items: center; }
.action-checker__heading > span { color: var(--muted); font-size: .72rem; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(40,115,91,.12); }
.action-checker p { margin: 4px 0 10px; color: var(--muted); font-size: .72rem; }
.action-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.action-chip { padding: 5px 8px; display: inline-flex; align-items: center; gap: 5px; color: #6d7773; border: 1px solid #ced8d4; border-radius: 7px; background: white; font-size: .71rem; font-weight: 700; }
.action-chip::before { content: "○"; font-size: .87rem; }
.action-chip.is-detected { color: var(--success); border-color: #9fc8b7; background: #e0f0e9; }
.action-chip.is-detected::before { content: "✓"; }
.editor-nav { padding-top: 22px; display: flex; justify-content: space-between; gap: 12px; }

.lesson-preview { min-width: 0; padding: 30px 26px; border-left: 1px solid var(--line); background: #f8f5ec; }
.lesson-preview__heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; color: var(--forest-800); border: 1px solid var(--line); border-radius: 10px; background: white; }
.icon-button:hover { border-color: var(--forest-700); }
.preview-meta { margin-top: 18px; display: flex; gap: 7px; }
.preview-meta span { padding: 4px 8px; color: var(--forest-800); border-radius: 6px; background: var(--forest-100); font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.lesson-preview h4 { margin: 18px 0 20px; color: var(--forest-950); font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; line-height: 1.25; }
.preview-part { padding: 13px 0; border-top: 1px solid #deded6; }
.preview-part:first-child { border-top-color: var(--ochre); }
.preview-part__label { display: flex; gap: 9px; color: var(--forest-800); font-size: .74rem; font-weight: 800; }
.preview-part__label span:first-child { color: var(--ochre); }
.preview-part p { margin: 5px 0 0 27px; color: #44514d; white-space: pre-wrap; overflow-wrap: anywhere; font-family: Georgia, "Times New Roman", serif; font-size: .82rem; line-height: 1.55; }
.preview-part p.is-empty { color: #8e9793; font-family: inherit; font-style: italic; }

footer { max-width: 1480px; margin: 0 auto; padding: 0 42px 28px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .78rem; }
.text-button--danger { color: var(--danger); border-color: rgba(163,74,58,.28); }

.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 28px; transform: translate(-50%, 18px);
  padding: 10px 15px; color: white; border-radius: 10px; background: var(--forest-950);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  font-size: .83rem; font-weight: 700;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.presentation { position: fixed; z-index: 100; inset: 0; color: white; background: var(--forest-950); }
.presentation[hidden] { display: none; }
.presentation::before { content: ""; position: absolute; inset: 0; opacity: .22; background: radial-gradient(circle at 85% 20%, #39786a 0, transparent 34%), radial-gradient(circle at 12% 100%, #b36d35 0, transparent 30%); }
.presentation__bar { position: relative; height: 92px; padding: 22px 4.5vw; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid rgba(255,255,255,.15); }
.presentation__bar > div { display: grid; }
.presentation__brand { color: #e4c095; font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.presentation__bar strong { font-family: Georgia, serif; font-size: 1.14rem; font-weight: 500; }
.button--ghost-light { color: white; border-color: rgba(255,255,255,.28); background: transparent; }
.button--light { color: var(--forest-950); background: white; }
.presentation__content { position: relative; min-height: calc(100vh - 92px); padding: 8vh 9vw 5vh; display: flex; flex-direction: column; }
.presentation__part-label { display: flex; gap: 16px; align-items: baseline; color: #e4c095; text-transform: uppercase; letter-spacing: .1em; font-size: clamp(.8rem, 1.3vw, 1rem); font-weight: 800; }
.presentation__part-label span:first-child { font-family: Georgia, serif; font-size: clamp(1.5rem, 2.7vw, 2.4rem); }
.presentation__content > p { max-width: 1120px; margin: 5vh 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.65rem, 3.7vw, 3.4rem); line-height: 1.32; }
.presentation__actions { margin-top: auto; display: grid; grid-template-columns: 135px 1fr 135px; gap: 14px; align-items: center; }
.presentation__actions span { color: rgba(255,255,255,.65); text-align: center; font-size: .8rem; font-weight: 700; }

dialog { width: min(430px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(7,28,24,.58); backdrop-filter: blur(3px); }
dialog form { padding: 30px; text-align: center; }
.dialog-icon { width: 42px; height: 42px; margin: 0 auto 14px; display: grid; place-items: center; color: var(--danger); border-radius: 50%; background: #f4dfda; font-family: Georgia, serif; font-size: 1.3rem; font-weight: 800; }
dialog h3 { margin: 0; font-family: Georgia, serif; font-size: 1.4rem; }
dialog p { margin: 8px auto 22px; color: var(--muted); font-size: .87rem; }
.dialog-actions { display: flex; justify-content: center; gap: 10px; }

@media (max-width: 1120px) {
  .setup { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 220px minmax(420px, 1fr); }
  .lesson-preview { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
  .preview-parts { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 26px; }
  .preview-part:nth-child(2) { border-top-color: var(--ochre); }
}

@media (max-width: 760px) {
  .masthead__content { padding: 28px 20px; align-items: flex-start; flex-direction: column; }
  .brand__mark { width: 52px; height: 52px; flex-basis: 52px; }
  .tagline { font-size: .88rem; }
  main { padding: 24px 14px 34px; }
  .setup__fields { grid-template-columns: 1fr 1fr; }
  .field--title { grid-column: 1 / -1; }
  .completion { align-self: center; }
  .workspace { display: block; border-radius: 17px; }
  .part-nav { padding: 10px; display: flex; gap: 6px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .part-tab { min-width: 68px; min-height: 58px; padding: 10px; display: flex; justify-content: center; align-items: center; }
  .part-tab strong, .part-tab small { display: none; }
  .part-tab__status { align-self: flex-start; }
  .editor-panel { padding: 24px 18px 20px; }
  .editor__heading { flex-direction: column; gap: 8px; }
  .writing-field textarea { min-height: 220px; }
  .lesson-preview { padding: 25px 20px; }
  .preview-parts { display: block; }
  .preview-part:nth-child(2) { border-top-color: #deded6; }
  footer { padding: 0 20px 24px; flex-direction: column; align-items: flex-start; }
  .presentation__bar { height: auto; align-items: flex-start; }
  .presentation__bar > div { max-width: 62%; }
  .presentation__content { min-height: calc(100vh - 90px); }
  .presentation__actions { grid-template-columns: 1fr 50px 1fr; }
}

@media print {
  body { background: white; }
  .masthead, .setup, .part-nav, .editor-panel, footer, .toast, .presentation { display: none !important; }
  main { max-width: none; padding: 0; }
  .workspace { display: block; min-height: auto; border: 0; box-shadow: none; }
  .lesson-preview { padding: 18mm; border: 0; background: white; }
  .icon-button { display: none; }
  .lesson-preview h3 { font-size: 22pt; }
  .lesson-preview h4 { font-size: 18pt; }
  .preview-part { break-inside: avoid; }
  .preview-part p { font-size: 10.5pt; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
