/* blackout: You Like Modern Art's web language (white field, Arial 13/18, default blue for anything
   you can press, pale rules as scaffold, Georgia for display) on its 12-column compound grid. */
:root {
  --page: #fff; --ink: #000; --link: #0000ee; --rule: #c9c9c4; --secondary: #595959; --field: #f5f5f5;
  --cols: 12; --gap: 16px; --max: 1376px; --u: 8px;
  --sans: Arial, Helvetica, sans-serif; --serif: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { color-scheme: light; background: var(--page); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 13px/18px var(--sans); text-rendering: optimizeLegibility; }
a { color: var(--link); text-decoration: underline; text-underline-offset: .12em; }
a:hover { text-decoration-thickness: 2px; }
button, input, textarea { font: inherit; color: inherit; border-radius: 0; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
img { display: block; max-width: 100%; height: auto; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-180%); padding: 8px 10px; background: var(--page); border: 1px solid var(--rule); color: var(--ink); }
.skip-link:focus { transform: none; }

/* buttons are text, like links */
.link, .tool { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; text-decoration: underline; text-underline-offset: .12em; }
.link:hover { text-decoration-thickness: 2px; }
.link.quiet { color: var(--secondary); }
.primary { background: var(--ink); color: #fff; border: 0; min-height: 34px; padding: 0 14px; cursor: pointer; }
.primary:hover { background: #222; }
.secondary { color: var(--secondary); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- grid ---------- */
.layout { width: min(100% - 64px, var(--max)); margin: 56px auto 96px; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.rail { grid-column: 1 / span 2; min-width: 0; }
.wordmark { display: inline-block; margin-bottom: 16px; color: var(--ink); font-weight: 700; text-decoration: none; }
.rail p { max-width: 232px; margin: 0 0 24px; line-height: 24px; }
.rail nav { display: grid; padding-top: 15px; border-top: 1px solid var(--rule); }
.rail nav a { display: flex; align-items: center; min-height: 24px; width: max-content; }
.rail nav a[aria-current] { color: var(--ink); text-decoration: none; }
.main { grid-column: 3 / -1; min-width: 0; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); column-gap: var(--gap); }
.block { grid-column: 2 / span 8; margin-bottom: 48px; }

.display { margin: 0 0 12px; font: 400 38px/42px var(--serif); }
.label { display: flex; justify-content: space-between; align-items: baseline; margin: 0; padding-bottom: 12px; border-bottom: 1px solid var(--rule); font-size: 13px; line-height: 18px; font-weight: 400; }
.label a { font-size: 11px; }
.meta, .hint, .status { color: var(--secondary); font-size: 11px; line-height: 16px; }
.hint { max-width: 60ch; }
.status:empty { display: none; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { min-height: 40px; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 4fr) auto; gap: 24px; align-items: center; border-bottom: 1px solid var(--rule); }
.rows li > span { color: var(--secondary); font-size: 11px; line-height: 16px; }
.rows li > span.num { text-align: right; }
.file-link { cursor: pointer; position: relative; }
.file-link input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-link:focus-within { outline: 2px solid var(--link); outline-offset: 3px; }

.strip { display: flex; gap: 12px; overflow-x: auto; padding: 16px 0 4px; }
.strip.wrap { flex-wrap: wrap; overflow: visible; row-gap: 24px; }
.thumb { flex: none; width: 160px; color: var(--ink); text-decoration: none; font-size: 11px; line-height: 16px; display: grid; gap: 4px; }
.thumb img { width: 160px; height: 200px; object-fit: cover; border: 1px solid var(--rule); background: var(--page); }
.thumb:hover span:first-of-type { text-decoration: underline; color: var(--link); }

/* ---------- book pager ---------- */
.book-head { border-top: 1px solid var(--rule); padding-top: 24px; margin-bottom: 24px; }
.pager { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 3fr); gap: 32px; align-items: start; }
.page-preview { margin: 0; background: var(--field); padding: 24px; display: flex; justify-content: center; }
.page-preview canvas { width: min(100%, 480px, calc((100dvh - 200px) * .8)); aspect-ratio: 4 / 5; background: var(--page); border: 1px solid var(--rule); touch-action: pan-y; }
.pager-controls { display: grid; gap: 16px; position: sticky; top: 24px; }
.pager-line { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; min-height: 34px; }
.pager-controls input[type=range] { width: 100%; accent-color: var(--ink); }

/* ---------- done ---------- */
.done { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 3fr); gap: 32px; align-items: start; }
.done-figure { margin: 0; background: var(--field); padding: 24px; }
.done-figure img { width: min(100%, 560px); margin: 0 auto; border: 1px solid var(--rule); background: var(--page); }
.done-text { display: grid; gap: 16px; position: sticky; top: 24px; }
.poem { margin: 0; font: 400 24px/32px var(--serif); }
.done-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; color: var(--secondary); font-size: 11px; }
.check input { accent-color: var(--ink); margin: 0; }

/* ---------- forms ---------- */
.paste form { display: grid; gap: 24px; max-width: 680px; }
.field { display: grid; gap: 6px; }
.field span { color: var(--secondary); font-size: 11px; }
.field input, .field textarea { width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: transparent; padding: 0 0 6px; min-height: 34px; }
.field textarea { border: 1px solid var(--rule); padding: 10px; font: 15px/24px var(--serif); resize: vertical; }
.paste .primary { justify-self: start; }
.about p { max-width: 60ch; font-size: 15px; line-height: 24px; }
.about p.meta { font-size: 11px; line-height: 16px; }
.about { border-top: 1px solid var(--rule); padding-top: 24px; }

/* ---------- editor: the word surface ---------- */
body.editing { overflow: hidden; overscroll-behavior: none; }
body.editing .layout { margin: 0 auto; height: 100dvh; padding: 24px 0 0; width: min(100% - 32px, var(--max)); }
body.editing .main { display: block; height: calc(100dvh - 24px); }
.editor { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.editor-head { order: -2; min-height: 34px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tally { color: var(--secondary); font-size: 11px; white-space: nowrap; margin-left: auto; }
.head-actions { display: flex; gap: 16px; }
.head-actions .done-link { font-weight: 700; }
.head-actions .done-link.finished { background: var(--ink); color: #fff; text-decoration: none; padding: 0 14px; min-height: 30px; display: inline-flex; align-items: center; }
.toolbar { order: -1; padding: 6px 0; display: flex; flex-wrap: wrap; column-gap: 40px; }
.tool-row { display: flex; flex-wrap: wrap; align-items: center; column-gap: 18px; }
.toolbar .tool-row:last-child { flex: 1; }
.seg { display: inline-flex; gap: 12px; align-items: center; }
.tool { min-height: 34px; text-decoration: none; }
.tool:hover { text-decoration: underline; }
.tool[aria-pressed=true] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .3em; }
.tool:disabled { color: #a3a3a3; cursor: default; text-decoration: none; }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--field); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.stage-canvas { position: absolute; inset: 0; touch-action: none; cursor: pointer; outline: none; }
.zoom { display: inline-flex; gap: 10px; align-items: center; margin-left: auto; }
.zoom .num { min-width: 42px; text-align: center; }

.stage-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 3; width: max-content; max-width: calc(100% - 24px); margin: 0; padding: 6px 10px; background: var(--page); border: 1px solid var(--rule); color: var(--secondary); font-size: 11px; line-height: 16px; pointer-events: none; transition: opacity .4s; }
.stage-hint.gone { opacity: 0; }

@media (max-width: 900px) {
  .layout { width: auto; margin: 20px 20px 48px; display: block; }
  .rail p { max-width: 350px; margin-bottom: 16px; line-height: 20px; }
  .rail nav { display: flex; gap: 18px; padding-top: 0; }
  .rail nav a { min-height: 44px; }
  .main { display: block; margin-top: 24px; }
  .block { margin-bottom: 40px; }
  .display { font-size: 30px; line-height: 34px; }
  .rows li { grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0; }
  .rows li > a, .rows li > label { min-height: 28px; display: flex; align-items: center; }
  .rows li > span:not(.num) { grid-column: 1; grid-row: 2; }
  .rows li > span.num { grid-row: 1 / span 2; grid-column: 2; }
  .pager, .done { grid-template-columns: 1fr; gap: 16px; }
  .page-preview, .done-figure { padding: 12px; margin: 0 -20px; }
  .done-text { position: static; }
  .pager-controls { position: sticky; bottom: 0; top: auto; z-index: 2; gap: 4px; margin: 0 -20px; padding: 4px 20px max(8px, env(safe-area-inset-bottom)); background: var(--page); border-top: 1px solid var(--rule); }
  .pager-controls .hint { display: none; }
  .pager-line { justify-content: space-between; }
  .book-head { margin-bottom: 12px; padding-top: 16px; }
  .pager-line .link, .done-actions .link, .done-actions a { min-height: 44px; display: inline-flex; align-items: center; }
  .primary { min-height: 44px; }
  .thumb { width: 128px; } .thumb img { width: 128px; height: 160px; }

  body.editing .rail { display: none; }
  body.editing .layout { margin: 0; padding: 0; width: 100%; height: 100dvh; }
  body.editing .main { margin: 0; height: 100dvh; }
  .editor-head { padding: 6px 12px; min-height: 44px; padding-top: max(6px, env(safe-area-inset-top)); gap: 10px; }
  .editor-head a { min-height: 32px; display: inline-flex; align-items: center; }
  .toolbar { order: 2; display: grid; padding: 2px 8px max(6px, env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); background: var(--page); }
  .tool-row { column-gap: 0; justify-content: space-between; flex-wrap: nowrap; }
  .seg, .zoom { gap: 0; }
  .zoom { margin-left: 0; }
  .zoom .num { min-width: 40px; }
  .tool { min-height: 44px; padding: 0 7px; }
}
@media (max-width: 420px) { .tool { padding: 0 5px; } .tally { display: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
