:root {
  --desk: #E9ECEF;
  --paper: #FFFFFF;
  --ink: #000000;
  --text: #24282C;
  --muted: #5E666E;
  --line: #CFE0EE;
  --margin-line: #E9A5A5;
  --marker: #FFF07A;
  --marker-strong: #FFE53D;
  --edge: #D3D8DD;
  --danger: #B3261E;
  --ui: 'Instrument Sans', system-ui, sans-serif;
  --serif: 'Newsreader', Georgia, serif;
  --radius-s: 6px;
  --radius-m: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--desk);
  color: var(--text);
  font: 400 17px/1.55 var(--ui);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
:focus-visible { outline: 3px solid #1F6FEB; outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1160px; margin: 0 auto; padding: 18px 24px;
}
.wordmark { font-weight: 700; font-size: 22px; letter-spacing: -0.02em; text-decoration: none; }
.top nav { display: flex; align-items: center; gap: 20px; font-size: 15px; }
.top nav > a { text-decoration: none; color: var(--muted); }
.top nav > a:hover { color: var(--text); }
.acct { display: flex; align-items: center; gap: 10px; }
.acct .pages { font-weight: 600; }
.acct .pages-sub { color: var(--muted); font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px/1 var(--ui); padding: 11px 16px; border-radius: var(--radius-s);
  border: 1.5px solid var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #2a2a2a; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn.big { font-size: 17px; padding: 15px 22px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; color: inherit; }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 56px; align-items: center;
  max-width: 1160px; margin: 0 auto; padding: 48px 24px 72px;
}
.hero h1 {
  font-size: clamp(42px, 6vw, 76px); line-height: 0.98; letter-spacing: -0.035em; font-weight: 700;
  margin: 0 0 22px; color: var(--ink); max-width: 11ch;
}
.lede { font-size: 20px; line-height: 1.5; color: var(--text); max-width: 34ch; margin: 0 0 28px; }
.fine { color: var(--muted); font-size: 14px; margin: 14px 0 0; }

.hero-page { position: relative; }
.paper {
  position: relative; background: var(--paper); border-radius: 3px;
  padding: 44px 30% 48px 22%;
  box-shadow: 0 1px 0 var(--edge), 0 18px 40px -24px rgba(20, 30, 40, 0.35);
  transform: rotate(-1.2deg);
  font-family: var(--serif); font-size: 14.5px; line-height: 1.62; color: #1d1d1d;
}
.paper-title { font-family: var(--serif); font-weight: 500; font-size: 22px; line-height: 1.2; margin: 0 0 14px; color: #111; }
.paper p { margin: 0 0 12px; }
.paper mark {
  background: rgba(255, 233, 61, 0.55); color: inherit; padding: 1px 0;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ink path { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
.ink.draw path { animation: write var(--dur, 1.2s) var(--delay, 0s) ease-in-out both; }
@keyframes write { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .ink.draw path { animation: none; } }

/* ---------- tool ---------- */
.tool {
  max-width: 1160px; margin: 0 auto 72px; padding: 40px 24px 36px;
  background: var(--paper); border-radius: var(--radius-m);
  box-shadow: 0 1px 0 var(--edge);
}
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 40px; }
.step h2 { font-size: 22px; letter-spacing: -0.015em; margin: 0 0 16px; display: flex; align-items: center; gap: 12px; color: var(--ink); }
.num {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--ink); font-size: 15px; font-weight: 600; flex: none;
}

.drop {
  display: grid; gap: 6px; place-items: center; text-align: center; cursor: pointer;
  padding: 36px 20px; border: 2px dashed #AEB7C0; border-radius: var(--radius-m);
  background: #FBFCFD;
}
.drop:hover, .drop.over { border-color: var(--ink); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 3px solid #1F6FEB; outline-offset: 2px; }
.drop-main { font-weight: 600; font-size: 18px; color: var(--ink); }
.drop-sub { color: var(--muted); font-size: 14px; }
.drop.has-file { border-style: solid; border-color: var(--ink); }

.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.style-opt {
  position: relative; display: grid; place-items: center; height: 76px; padding: 10px 14px;
  background: var(--paper); border: 1.5px solid var(--edge); border-radius: var(--radius-s); cursor: pointer;
  font: 600 15px/1.2 var(--ui); color: var(--ink);
}
.style-opt:hover { border-color: #8A949E; }
.style-opt img { position: relative; max-width: 100%; max-height: 44px; z-index: 1; }
.style-opt::before {
  content: ''; position: absolute; left: 8px; right: 8px; top: 30%; bottom: 26%;
  background: var(--marker); border-radius: 2px; transform: scaleX(0); transform-origin: left; transition: transform 0.25s ease;
}
.style-opt[aria-checked="true"] { border-color: var(--ink); }
.style-opt[aria-checked="true"]::before { transform: scaleX(1); }
@media (prefers-reduced-motion: reduce) { .style-opt::before { transition: none; } }
.style-opt .tag { position: absolute; left: 10px; bottom: 6px; font-size: 12px; color: var(--muted); z-index: 1; }
.style-opt.custom { border-style: dashed; }
.style-opt.custom.ready { border-style: solid; }

.range-field { max-width: 560px; }
.range-label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; margin-bottom: 6px; }
.range-label output { font-weight: 700; font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }
.dual { position: relative; height: 36px; }
.dual-track { position: absolute; left: 11px; right: 11px; top: 16px; height: 4px; border-radius: 2px; background: #D9DEE3; }
.dual-fill { position: absolute; top: 0; bottom: 0; background: var(--ink); border-radius: 2px; }
.dual input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 36px; margin: 0; background: none;
  -webkit-appearance: none; appearance: none; pointer-events: none;
}
.dual input[type=range]::-webkit-slider-runnable-track { background: none; height: 36px; }
.dual input[type=range]::-moz-range-track { background: none; }
.dual input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; cursor: grab; width: 22px; height: 22px; margin-top: 7px;
  border-radius: 50%; background: #fff; border: 2px solid var(--ink);
}
.dual input[type=range]::-moz-range-thumb {
  pointer-events: auto; cursor: grab; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--ink);
}
.dual input[type=range]:focus-visible { outline: none; }
.dual input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.45); }
.dual input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.45); }
.dual-scale { display: flex; justify-content: space-between; padding: 0 6px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.example { color: var(--muted); font-size: 14px; margin: 6px 0 0; font-style: italic; }
.settings-row { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 40px; margin-top: 26px; align-items: start; }
.slider label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; margin-bottom: 10px; }
.slider output { font-weight: 700; font-size: 20px; color: var(--ink); }
.slider input[type=range] { width: 100%; accent-color: var(--ink); height: 28px; }
.colors { border: 0; margin: 0; padding: 0; min-width: 0; }
.colors legend { font-weight: 600; margin-bottom: 10px; padding: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch span {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px 0 12px; border-radius: 18px;
  background: var(--c); color: var(--ink); font-size: 14px; font-weight: 600; border: 2px solid transparent;
}
.swatch input:checked + span { border-color: var(--ink); }
.swatch input:focus-visible + span { outline: 3px solid #1F6FEB; outline-offset: 2px; }
.focus-field { margin-top: 28px; max-width: 720px; }
.focus-field label { display: flex; align-items: baseline; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.focus-field .optional { font-weight: 400; font-size: 14px; color: var(--muted); }
.focus-field input {
  width: 100%; font: 400 16px var(--ui); padding: 12px 14px; border: 1.5px solid #B9C1C9; border-radius: var(--radius-s);
  background: #fff; color: var(--text);
}
.focus-field input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.25); }
.focus-field .example { font-style: normal; }

.go { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--edge); }
.cost { color: var(--muted); margin: 0; }
.error { color: var(--danger); font-weight: 500; margin: 0; flex-basis: 100%; }

.progress { margin-top: 24px; }
.bar { height: 10px; background: #EEF1F4; border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--marker-strong); transition: width 0.3s ease; }
.progress p { margin: 10px 0 0; color: var(--muted); }

.result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; margin-top: 28px; }
.result canvas { width: 100%; height: auto; background: #fff; box-shadow: 0 1px 0 var(--edge), 0 12px 30px -18px rgba(20, 30, 40, 0.4); border-radius: 2px; }
.result-actions { display: grid; gap: 14px; justify-items: start; }
.result-actions p { margin: 0; font-size: 18px; }

/* ---------- pricing ---------- */
.pricing { max-width: 1160px; margin: 0 auto; padding: 0 24px 80px; }
.pricing h2 { font-size: 34px; letter-spacing: -0.025em; margin: 0 0 6px; color: var(--ink); }
.pricing-sub { color: var(--muted); margin: 0 0 24px; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.plan { background: var(--paper); border-radius: var(--radius-m); padding: 24px; display: grid; gap: 4px; align-content: start; box-shadow: 0 1px 0 var(--edge); }
.plan.featured { box-shadow: inset 0 0 0 2px var(--ink); }
.plan h3 { margin: 0; font-size: 18px; }
.price { font-size: 38px; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); margin: 4px 0; }
.price span { font-size: 16px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan p:not(.price) { margin: 0 0 16px; color: var(--text); }
.plan .btn { justify-self: start; }

.foot { max-width: 1160px; margin: 0 auto; padding: 24px; color: var(--muted); font-size: 14px; border-top: 1px solid #D5DADF; }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: var(--radius-m); padding: 28px; width: min(480px, calc(100vw - 32px)); color: var(--text); }
dialog::backdrop { background: rgba(20, 24, 28, 0.45); }
dialog h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; color: var(--ink); }
.dialog-sub { color: var(--muted); margin: 0 0 18px; }
dialog label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; margin-bottom: 14px; }
dialog input[type=email], dialog input[type=password] {
  font: 400 16px var(--ui); padding: 11px 12px; border: 1.5px solid #B9C1C9; border-radius: var(--radius-s);
}
dialog input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.25); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.switch { margin: 18px 0 0; color: var(--muted); font-size: 15px; }
.buy-options { display: grid; gap: 10px; margin-bottom: 8px; }
.buy-option {
  display: grid; gap: 2px; text-align: left; padding: 16px; border-radius: var(--radius-s);
  border: 1.5px solid var(--edge); background: #fff; cursor: pointer; font: inherit;
}
.buy-option:hover { border-color: var(--ink); }
.buy-option strong { font-size: 18px; color: var(--ink); }
.buy-option span { color: var(--muted); font-size: 14px; }

#writer-dialog { width: min(760px, calc(100vw - 32px)); }
.copy-this { font-family: var(--serif); font-size: 22px; margin: 0 0 12px; color: var(--ink); }
#pad {
  display: block; width: 100%; height: 170px; border-radius: var(--radius-s); border: 1.5px solid var(--edge);
  touch-action: none; cursor: crosshair;
  background:
    linear-gradient(to right, transparent 46px, var(--margin-line) 46px 48px, transparent 48px),
    repeating-linear-gradient(to bottom, transparent 0 55px, var(--line) 55px 57px),
    #fff;
}
.writer-preview p { margin: 14px 0 6px; color: var(--muted); }
#writer-sample { width: 100%; height: 60px; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding-top: 24px; }
  .plans, .result, .settings-row { grid-template-columns: 1fr; }
  .paper { padding: 32px 26% 36px 20%; font-size: 13px; }
}
@media (max-width: 520px) {
  .top { padding: 14px 16px; }
  .top nav > a { display: none; }
  .tool { padding: 28px 16px; border-radius: 0; }
  .hero, .pricing { padding-left: 16px; padding-right: 16px; }
  .styles { grid-template-columns: 1fr 1fr; }
  .style-opt { height: 64px; }
}
