:root {
  --ink: #17211d;
  --muted: #63706a;
  --paper: #f4f0e8;
  --surface: #fffdf8;
  --line: #d9d2c5;
  --orange: #ff9d00;
  --red: #eb2629;
  --mint: #26d9aa;
  --blue: #173bd6;
  --green: #168763;
  --shadow: 0 18px 48px rgba(38, 32, 22, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 5% 10%, rgba(38,217,170,.12), transparent 25rem), radial-gradient(circle at 95% 5%, rgba(255,157,0,.12), transparent 25rem), var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(23,59,214,.28); outline-offset: 2px; }
.hidden { display: none !important; }

.topbar { min-height: 78px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; padding: 10px clamp(20px, 5vw, 72px); color: #fff; background: var(--ink); border-bottom: 5px solid; border-image: linear-gradient(90deg,var(--orange) 0 25%,var(--red) 25% 50%,var(--mint) 50% 75%,var(--blue) 75%) 1; }
.brand { display: block; width: fit-content; color: inherit; text-decoration: none; }
.brand img { display: block; width: 104px; height: 57px; object-fit: contain; }
.product-name { text-align: center; }
.product-name span { display: block; font: 500 20px Georgia, serif; }
.product-name small { color: #aeb8b3; font-size: 10px; text-transform: uppercase; letter-spacing: .15em; }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.provider-status { padding: 6px 9px; border: 1px solid #59645f; border-radius: 99px; color: #c8cfcc; font-size: 10px; }
.provider-status.ready { color: #bcffe9; border-color: #39846d; }
.inverse { color: #fff !important; border-color: #59645f !important; }

main { width: min(1320px, calc(100% - 40px)); margin: 0 auto; }
.view { padding: clamp(42px, 7vw, 92px) 0; }
.auth-view { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(360px,.7fr); gap: clamp(42px,7vw,100px); align-items: center; min-height: calc(100vh - 190px); }
.auth-intro { padding-block: 32px; }
.auth-card { display: grid; gap: 24px; padding: clamp(28px,4vw,44px); }
.auth-card button { width: 100%; }
.setup-grid { display: grid; grid-template-columns: minmax(0,.9fr) minmax(500px,1.1fr); gap: clamp(42px,7vw,100px); align-items: start; }
.intro { position: sticky; top: 42px; padding-top: 32px; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 11px; line-height: 1.4; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; max-width: 760px; font: 500 clamp(42px,6vw,78px)/.98 Georgia,serif; letter-spacing: -.045em; }
.lede { max-width: 610px; margin: 28px 0; color: var(--muted); font-size: 18px; line-height: 1.65; }
.principles { display: flex; flex-wrap: wrap; gap: 9px; }
.principles span { padding: 8px 11px; border: 1px solid var(--line); background: rgba(255,255,255,.45); border-radius: 99px; color: #42504a; font-size: 12px; }
.resume-note { display: grid; gap: 7px; margin-top: 28px; padding: 18px; border-left: 4px solid var(--orange); background: rgba(255,253,248,.78); }
.resume-note span { color: var(--muted); font-size: 13px; }
.resume-note button { width: fit-content; margin-top: 4px; }

.card { background: var(--surface); border: 1px solid rgba(97,82,56,.16); border-radius: 20px; box-shadow: var(--shadow); }
.setup-card { display: grid; gap: 20px; padding: clamp(24px,4vw,42px); }
.section-heading { display: flex; gap: 14px; align-items: flex-start; }
.section-heading > span { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--blue); font-size: 12px; font-weight: 800; }
.section-heading h2 { margin: 0 0 4px; font: 500 27px/1.1 Georgia,serif; }
.section-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.section-heading.compact { margin-top: 12px; padding-top: 22px; border-top: 1px solid var(--line); }
label, legend { color: #39463f; font-size: 13px; font-weight: 750; letter-spacing: .015em; }
.optional { margin-left: 5px; color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; margin-top: 8px; border: 1px solid #cbc3b6; border-radius: 10px; padding: 12px 13px; color: var(--ink); background: #fff; transition: .18s ease; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { margin-bottom: 9px; }

button { border: 1px solid transparent; border-radius: 9px; padding: 11px 16px; font-weight: 800; transition: transform .15s ease, background .15s ease; }
button:hover { transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: .55; transform: none; }
.primary { color: #fff; background: var(--blue); }
.primary:hover { background: #102ba7; }
.secondary { color: var(--ink); background: #e9fff8; border-color: #aadfce; }
.split-button { display: flex; justify-content: space-between; align-items: center; }
.secondary small { color: #4b6d62; font-weight: 600; }
.quiet { background: transparent; border-color: var(--line); color: var(--ink); }
.danger-quiet { color: #a5161b; background: transparent; border-color: #e8b4b6; }
.start-button { padding-block: 15px; font-size: 15px; }
.status { min-height: 18px; margin: -9px 0 0; color: var(--muted); font-size: 12px; }
.status.error { color: #a5161b; }
.ideas { display: grid; gap: 8px; }
.idea { text-align: left; padding: 13px 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); }
.idea strong, .idea span { display: block; }
.idea strong { font: 500 17px Georgia,serif; }
.idea span { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.idea.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(23,59,214,.12); }
.sources { padding: 14px 16px; border-left: 3px solid var(--mint); background: #f1faf7; color: var(--muted); font-size: 12px; line-height: 1.45; }
.sources strong { color: var(--ink); }
.sources ol { display: grid; gap: 5px; margin: 8px 0 0; padding-left: 20px; }
.sources a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.duration-options { display: grid; grid-template-columns: repeat(5,1fr); gap: 8px; }
.duration-options label { position: relative; }
.duration-options input, .warning-options input { position: absolute; opacity: 0; pointer-events: none; }
.duration-options span { display: block; padding: 11px 6px; text-align: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.duration-options input:checked + span { color: #fff; background: var(--blue); border-color: var(--blue); }
.range-label { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.range-label output { color: var(--blue); font-weight: 800; }
.range-label input { grid-column: 1/-1; padding: 0; accent-color: var(--blue); }
.warning-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.warning-options label { position: relative; }
.warning-options label > span { display: block; min-height: 72px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.warning-options strong, .warning-options small { display: block; }
.warning-options small { margin-top: 4px; color: var(--muted); font-weight: 500; }
.warning-options input:checked + span { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(23,59,214,.12); background: #f2f4ff; }

.writing-shell { display: grid; grid-template-columns: 300px 1fr; gap: 32px; min-height: 70vh; }
.session-rail { position: sticky; top: 30px; height: fit-content; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,253,248,.82); }
.timer { font: 500 58px/1 Georgia,serif; letter-spacing: -.05em; transition: color .2s ease; }
.timer.steady { color: var(--green); }
.timer.closing { color: #b56c00; }
.timer.urgent { color: var(--red); }
.progress-track { height: 6px; margin: 20px 0; background: #d8d2c8; border-radius: 9px; overflow: hidden; }
.progress-track div { height: 100%; width: 0; background: linear-gradient(90deg,var(--orange),var(--red),var(--blue)); transition: width 1s linear; }
.live-stats { display: grid; grid-template-columns: 1fr 1fr; margin: 22px 0; border-top: 1px solid var(--line); }
.live-stats div { padding: 13px 5px; border-bottom: 1px solid var(--line); }
.live-stats div:nth-child(odd) { border-right: 1px solid var(--line); }
.live-stats strong, .live-stats span { display: block; }
.live-stats strong { font: 500 24px Georgia,serif; }
.live-stats span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.rail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rail-actions button:nth-last-child(-n+2) { grid-column: 1/-1; }
.editor-panel { min-width: 0; padding: clamp(26px,5vw,62px); border: 1px solid transparent; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); transition: border-color .2s ease, background .2s ease; }
.editor-panel h2 { margin: 0; font: 500 clamp(28px,4vw,48px)/1.08 Georgia,serif; }
.prompt { max-width: 800px; color: var(--muted); line-height: 1.6; }
.editor-panel textarea { min-height: 430px; margin-top: 18px; padding: 0; border: 0; border-radius: 0; background: transparent; font: 21px/1.8 Georgia,serif; resize: none; }
.editor-panel textarea:focus { outline: 0; }
.editor-panel textarea:disabled { opacity: .55; }
.privacy-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; }
.momentum-alert { min-height: 40px; margin-top: 18px; padding: 10px 12px; border-left: 3px solid var(--mint); background: #effaf6; color: #356153; font-size: 12px; }
.momentum-alert:not(.active) span:empty::before { content: "Your page is ready."; }
.momentum-alert.active.gentle { border-color: var(--orange); background: #fff9e9; color: #7b5b17; }
.momentum-alert.active.moderate { border-color: #dc6b00; background: #fff3e4; color: #874500; font-weight: 700; }
.momentum-alert.active.strict { border-color: var(--red); background: #fff0f0; color: #a5161b; font-weight: 800; }
.editor-panel.warning-moderate { border-color: rgba(220,107,0,.55); }
.editor-panel.warning-strict { border-color: var(--red); box-shadow: 0 0 0 3px rgba(235,38,41,.1), var(--shadow); animation: strict-pulse 1.2s ease-in-out infinite; }
@keyframes strict-pulse { 50% { background: #fff8f5; } }

.continue-card { width: min(780px,100%); margin: 5vh auto; padding: clamp(32px,6vw,72px); text-align: center; }
.continue-card h1 { margin-inline: auto; font-size: clamp(38px,5vw,62px); }
.continue-card > p:not(.eyebrow) { color: var(--muted); font-size: 17px; }
.time-icon { width: fit-content; margin: 0 auto 25px; padding: 11px 15px; border: 2px solid var(--red); border-radius: 10px; color: var(--red); font: 700 22px ui-monospace, monospace; }
.continue-actions { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-top: 30px; }

.results-head { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 35px; }
.results-head h1 { font-size: clamp(38px,5vw,64px); }
.export-menu { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.summary-grid { display: grid; grid-template-columns: repeat(4,1fr); margin-bottom: 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.summary-grid div { display: flex; align-items: baseline; gap: 10px; padding: 18px; }
.summary-grid div + div { border-left: 1px solid var(--line); }
.summary-grid strong { font: 500 34px Georgia,serif; }
.summary-grid span { color: var(--muted); font-size: 11px; }
.draft-card, .result-section { padding: clamp(24px,4vw,42px); }
.draft-card { margin-bottom: 24px; }
.draft-card h2, .result-section h2 { margin: 0 0 20px; font: 500 32px/1.15 Georgia,serif; }
.prose { white-space: pre-wrap; font: 18px/1.75 Georgia,serif; }
.result-section { margin-top: 24px; }
.feedback-title { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.feedback-title h2 { margin-bottom: 0; }
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 26px; }
.comparison-grid section { min-width: 0; }
.comparison-grid h3, .strength-grid h3, .coach-grid h3 { margin: 0 0 10px; color: #304039; font-size: 14px; }
.comparison-copy { min-height: 230px; max-height: 520px; overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 11px; background: #f7f4ee; white-space: pre-wrap; font: 16px/1.7 Georgia,serif; }
.comparison-copy.muted, .feedback-output.muted { color: var(--muted); font-family: inherit; font-style: italic; }
#copy-refined { margin-top: 10px; }
.feedback-output { margin-top: 26px; color: #39463f; font-size: 14px; line-height: 1.55; }
.score-cards { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; }
.score-card { padding: 18px 14px; border-radius: 12px; background: #f0f3ff; }
.score-card strong, .score-card span { display: block; }
.score-card strong { font: 500 34px Georgia,serif; color: var(--blue); }
.score-card span { margin: 4px 0 12px; color: var(--muted); font-size: 11px; }
.score-card i { display: block; height: 5px; overflow: hidden; border-radius: 6px; background: rgba(23,59,214,.12); }
.score-card i span { height: 100%; margin: 0; background: var(--blue); }
.tone-1 { background: #effaf6; }.tone-1 strong { color: var(--green); }.tone-1 i span { background: var(--green); }
.tone-2 { background: #fff8e6; }.tone-2 strong { color: #a96700; }.tone-2 i span { background: var(--orange); }
.tone-3 { background: #fff0f0; }.tone-3 strong { color: #b31d20; }.tone-3 i span { background: var(--red); }
.strength-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.strength-grid section, .coach-grid section { padding: 18px; border-radius: 11px; background: #effaf6; }
.strength-grid section + section { background: #fff8e6; }
.strength-grid p, .coach-grid p { margin: 0; white-space: pre-wrap; }
.coach-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.coach-grid section:nth-child(2) { background: #f0f3ff; }
.coach-grid section:nth-child(3) { background: #fff0f0; }
.completion-actions { display: flex; justify-content: center; margin-top: 30px; }
.completion-actions button { padding: 14px 28px; }

footer { display: flex; justify-content: space-between; gap: 24px; padding: 24px clamp(20px,5vw,72px); color: #bdc6c1; background: var(--ink); font-size: 11px; }

@media (max-width: 1000px) {
  .auth-view, .setup-grid, .writing-shell { grid-template-columns: 1fr; }
  .intro, .session-rail { position: static; }
  .session-rail { display: grid; grid-template-columns: auto 1fr; gap: 12px 25px; align-items: center; }
  .session-rail .eyebrow, .session-rail .progress-track, .live-stats, .rail-actions { grid-column: 1/-1; }
  .live-stats { grid-template-columns: repeat(4,1fr); }
  .live-stats div { border-right: 1px solid var(--line); }
  .live-stats div:last-child { border-right: 0; }
  .score-cards { grid-template-columns: repeat(3,1fr); }
}

@media (max-width: 700px) {
  main { width: min(100% - 24px,1320px); }
  .topbar { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .brand img { width: 84px; height: 46px; }
  .product-name, .provider-status { display: none; }
  .top-actions { gap: 6px; }
  .top-actions button { padding-inline: 10px; }
  .view { padding: 34px 0; }
  .two-columns, .comparison-grid, .strength-grid, .coach-grid { grid-template-columns: 1fr; }
  .duration-options { grid-template-columns: repeat(5,1fr); }
  .warning-options { grid-template-columns: 1fr; }
  .continue-actions, .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-grid div:nth-child(odd) { border-left: 0; }
  .summary-grid div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .results-head { align-items: flex-start; flex-direction: column; }
  .export-menu { justify-content: flex-start; }
  .live-stats { grid-template-columns: 1fr 1fr; }
  .score-cards { grid-template-columns: 1fr 1fr; }
  .feedback-title { align-items: flex-start; flex-direction: column; }
  footer { flex-direction: column; }
}

@media (max-width: 430px) {
  .duration-options { grid-template-columns: repeat(3,1fr); }
  .continue-actions, .summary-grid { grid-template-columns: 1fr; }
  .summary-grid div + div { border-left: 0; border-top: 1px solid var(--line); }
  .score-cards { grid-template-columns: 1fr; }
}

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