/* Blue Pencil — a quiet, Apple-style interface.
   System type (SF Pro / New York), soft grouped surfaces, one blue accent. */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --fill: rgba(120, 120, 128, 0.12);        /* control tracks, tinted wells */
  --fill-strong: rgba(120, 120, 128, 0.2);
  --ink: #1d1d1f;
  --ink-soft: #6e6e73;
  --hairline: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-wash: rgba(0, 113, 227, 0.12);
  --accent-ink: #ffffff;
  --good: #1d8348;
  --good-wash: rgba(52, 199, 89, 0.15);
  --warn: #b25000;
  --warn-wash: rgba(255, 149, 0, 0.16);
  --nav: rgba(245, 245, 247, 0.72);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 30px rgba(0, 0, 0, 0.06);
  --raise: 0 1px 1px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.12);

  --radius: 20px;
  --radius-sm: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --fill: rgba(120, 120, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --ink: #f5f5f7;
    --ink-soft: #98989f;
    --hairline: rgba(255, 255, 255, 0.1);
    --accent: #2997ff;
    --accent-hover: #4aa8ff;
    --accent-wash: rgba(41, 151, 255, 0.2);
    --accent-ink: #ffffff;
    --good: #30d158;
    --good-wash: rgba(48, 209, 88, 0.16);
    --warn: #ffb340;
    --warn-wash: rgba(255, 159, 10, 0.18);
    --nav: rgba(0, 0, 0, 0.7);
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
    --raise: 0 1px 2px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.page {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding-inline: clamp(14px, 2.5vw, 40px);
  padding-block: 0 clamp(24px, 4vw, 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

/* ---------- masthead ---------- */
.mast {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 10px;
  padding-block: 56px 16px;
}
.brand {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: clamp(2.4rem, 6.5vw, 4rem);
  letter-spacing: -0.035em;
  line-height: 1.05;
}
.brand::before {
  content: "";
  width: 0.62em;
  height: 0.62em;
  border-radius: 28%;
  background: linear-gradient(160deg, #5ac8fa 0%, var(--accent) 60%, #0050c8 100%);
  box-shadow: 0 6px 16px -4px rgba(0, 113, 227, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.pitch {
  margin: 4px 0 0;
  max-width: 32em;
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--ink-soft);
  text-wrap: balance;
}
.privacy {
  margin: 6px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink-soft);
  font-size: 0.82rem;
  letter-spacing: 0;
}
.privacy::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
}

/* ---------- settings ---------- */
.slip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  padding: 18px 22px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .eyebrow {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-soft);
}
.field-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  max-width: 25rem;
}
.field-check label {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  cursor: pointer;
}
.hint { display: block; margin-top: 2px; font-size: 0.82rem; font-weight: 400; color: var(--ink-soft); }

/* iOS switch */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 999px;
  background: var(--fill-strong);
  cursor: pointer;
  transition: background 0.25s ease;
}
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.3, 1);
}
input[type="checkbox"]:checked { background: #34c759; }
input[type="checkbox"]:checked::after { transform: translateX(20px); }

select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  background-color: var(--fill);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 38px 10px 14px;
  min-width: 15rem;
  max-width: 100%;
  cursor: pointer;
}
select:hover { background-color: var(--fill-strong); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--accent);
  background: var(--accent-wash);
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, color 0.2s ease;
}
.btn:hover { background: var(--accent); color: var(--accent-ink); }
.btn:active { transform: scale(0.97); }
.btn-wide { width: 100%; margin-top: 14px; padding-block: 12px; background: var(--accent); color: var(--accent-ink); }
.btn-wide:hover { background: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent-wash); outline-offset: 2px; box-shadow: 0 0 0 1.5px var(--accent); }
textarea:focus-visible { box-shadow: none; }

/* ---------- layout ---------- */
.grid { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 960px) {
  .grid { grid-template-columns: minmax(0, 1.6fr) minmax(340px, 1fr); }
}
@media (min-width: 1500px) {
  .grid { grid-template-columns: minmax(0, 2fr) minmax(420px, 1fr); }
}

/* ---------- manuscript ---------- */
.sheet {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.sheet-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
}
.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--fill);
  border-radius: 10px;
}
.seg-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 16px;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.seg-btn[aria-pressed="true"] { background: var(--surface); box-shadow: var(--raise); }
@media (prefers-color-scheme: dark) {
  .seg-btn[aria-pressed="true"] { background: #636366; }
}
.counts { margin: 0; font-size: 0.82rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.sample-note {
  margin: 0; padding: 10px 18px;
  font-size: 0.85rem; color: var(--accent);
  background: var(--accent-wash);
}

.paper { display: block; width: 100%; min-height: 28rem; padding: 28px max(clamp(20px, 5vw, 56px), calc((100% - 50rem) / 2)) 44px; }
.manuscript { font-family: var(--serif); font-size: 1.12rem; line-height: 1.75; letter-spacing: 0; color: var(--ink); }
textarea.paper {
  border: 0; background: transparent; resize: vertical; height: 36rem; max-height: 80vh;
  outline: none;
}
textarea::placeholder { color: var(--ink-soft); opacity: 0.8; }

.marked p { margin: 0 0 1em; text-indent: 1.6em; overflow-wrap: anywhere; }
.marked p.skip { text-indent: 0; text-align: center; color: var(--ink-soft); font-family: var(--sans); font-size: 0.9rem; font-weight: 600; letter-spacing: 0.02em; margin-block: 1.4em; }
.marked p.pulse { animation: pulse 1.4s ease-out; }
.hard {
  background: var(--accent-wash);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 4px;
  padding: 1px 3px;
  margin-inline: -3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  scroll-margin-top: 90px;
}
.hard.pulse { animation: pulse 1.4s ease-out; }
.rank {
  display: inline-block; min-width: 1.45em; height: 1.45em; margin-right: 0.35em;
  font: 600 0.72rem/1.45em var(--sans); text-align: center; text-indent: 0; letter-spacing: 0;
  color: var(--accent-ink); background: var(--accent); border-radius: 999px; vertical-align: 0.1em;
}
@keyframes pulse { 0% { outline: 3px solid var(--accent); outline-offset: 3px; } 100% { outline: 3px solid transparent; outline-offset: 3px; } }

/* ---------- report ---------- */
.report { display: grid; gap: 16px; min-width: 0; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h2 {
  margin: 0 0 14px;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.score-row { display: flex; gap: 12px; }
.big {
  flex: 1 1 0;
  display: grid;
  gap: 0;
  min-width: 0;
  padding: 14px 16px 12px;
  background: var(--bg);
  border-radius: 16px;
}
.num { font-size: 3.4rem; line-height: 1.05; font-weight: 600; letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.band { font-size: 0.85rem; color: var(--ink-soft); letter-spacing: 0; min-height: 1.4em; }

.ruler { position: relative; height: 8px; margin-top: 24px; border-radius: 999px; background: var(--fill); }
.ruler-target { position: absolute; top: 0; bottom: 0; background: var(--accent-wash); border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--accent); }
.ruler-tick {
  position: absolute; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: left 0.45s cubic-bezier(0.3, 0.7, 0.3, 1);
}
.ruler-scale { display: flex; justify-content: space-between; margin-top: 10px; font-size: 0.75rem; color: var(--ink-soft); letter-spacing: 0; }
.verdict { margin: 16px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: 500; line-height: 1.35; background: var(--accent-wash); color: var(--accent); }
.verdict:empty { display: none; }
.verdict.ok { background: var(--good-wash); color: var(--good); }
.verdict.off { background: var(--warn-wash); color: var(--warn); }
.vs-basic { margin: 12px 0 0; font-size: 0.85rem; line-height: 1.4; color: var(--ink-soft); letter-spacing: 0; }
.vs-basic:empty { display: none; }

.hardest { list-style: none; margin: 0; padding: 0; display: grid; }
.hardest li {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px;
  padding-block: 14px; border-bottom: 1px solid var(--hairline);
}
.hardest li:first-child { padding-top: 2px; }
.hardest li:last-child { padding-bottom: 0; border-bottom: 0; }
.hardest .rank { margin: 3px 0 0; }
.excerpt { margin: 0; font-family: var(--serif); font-size: 1rem; line-height: 1.45; letter-spacing: 0; overflow-wrap: anywhere; }
.meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; font-size: 0.78rem; color: var(--ink-soft); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.link {
  font: inherit; font-weight: 500; color: var(--accent); background: none; border: 0; padding: 4px 0; cursor: pointer;
  margin-left: auto;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.empty { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

.strip-wrap { position: relative; height: 104px; padding: 0; border-radius: 12px; overflow: hidden; background: var(--bg); }
.strip-band { position: absolute; left: 0; right: 0; background: var(--accent-wash); border-block: 1px dashed var(--accent); pointer-events: none; }
.strip { position: absolute; inset: 8px 8px 0; display: flex; align-items: flex-end; gap: 2px; }
.bar { flex: 1 1 0; min-width: 3px; padding: 0; border: 0; background: var(--ink); opacity: 0.75; border-radius: 3px 3px 0 0; cursor: pointer; transition: background 0.15s ease, opacity 0.15s ease; }
.bar.thin { opacity: 0.25; }
.bar:hover, .bar:focus-visible { background: var(--accent); opacity: 1; }
.note { margin: 12px 0 0; font-size: 0.82rem; line-height: 1.4; color: var(--ink-soft); letter-spacing: 0; }
.note:empty { display: none; }

.measures { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.measures th, .measures td { padding: 10px 0; border-bottom: 1px solid var(--hairline); text-align: left; font-weight: 400; vertical-align: baseline; }
.measures tr:first-child th, .measures tr:first-child td { padding-top: 2px; }
.measures td { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 12px; }
.measures tr:last-child th, .measures tr:last-child td { border-bottom: 0; }
.measures .sub { display: block; margin-top: 1px; font-size: 0.78rem; color: var(--ink-soft); letter-spacing: 0; }

.foot { color: var(--ink-soft); font-size: 0.8rem; line-height: 1.5; max-width: 54em; margin-inline: auto; text-align: center; letter-spacing: 0; }
.foot p { margin: 0; }

/* Roomy screens: fill the viewport like an app. Header and settings stay put;
   the manuscript and the report each scroll inside their own pane. */
@media (min-width: 960px) and (min-height: 660px) {
  .page { height: 100vh; height: 100dvh; padding-block: 0 clamp(14px, 2vw, 28px); gap: 16px; grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .mast { grid-template-columns: auto minmax(0, 1fr) auto; justify-items: start; text-align: left; align-items: center; gap: 4px 20px; padding-block: 18px 0; }
  .brand { font-size: 2rem; }
  .pitch { margin: 0; font-size: 1rem; max-width: none; text-wrap: pretty; }
  .privacy { margin: 0; }
  .slip { padding: 12px 20px; }
  .grid { height: 100%; min-height: 0; align-items: stretch; }
  .sheet { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .paper { flex: 1 1 0; min-height: 0; overflow-y: auto; }
  textarea.paper { height: auto; max-height: none; resize: none; }
  .report { height: 100%; min-height: 0; overflow-y: auto; padding: 0 2px 2px; scrollbar-width: thin; }
  .foot { max-width: none; margin: 0; text-align: left; font-size: 0.74rem; line-height: 1.4; }
}

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  .page { padding-inline: 14px; }
  .mast { padding-block: 28px 8px; }
  .actions { margin-left: 0; width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  select { min-width: 0; width: 100%; }
  .field { width: 100%; }
  .card { padding: 18px; }
  .num { font-size: 2.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ruler-tick, input[type="checkbox"], input[type="checkbox"]::after, .btn, .seg-btn { transition: none; }
  .hard.pulse, .marked p.pulse { animation: none; }
}
