/* Bindery v2 — "Night Bench"
 * Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V5
 * Macrostructure: Instrument bench (slim topbar + segmented tool switch + asymmetric workbench)
 * Theme: Night bench (off-black · Archivo display · signal-amber accent)
 * Genre: modern-minimal / utilitarian instrument
 * Motion: press physics 140ms · dropzone lift · row slide-in · result fade · tab slide
 * Shape rule: containers 6px · controls 3px · switcher pill (documented, consistent)
 */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-var.woff2") format("woff2");
  font-weight: 700 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibmplexmono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibmplexmono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibmplexmono-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #131316;
  --surface: #1B1B21;
  --surface-2: #26262E;
  --ink: #F2F0E8;
  --ink-2: #A6A49A;
  --ink-3: #6E6C63;
  --line: #2C2C34;
  --accent: #E8A33D;
  --accent-deep: #C77F1F;
  --accent-ink: #131316;
  --accent-wash: rgba(232, 163, 61, 0.10);
  --pos: #3ECF6F;
  --neg: #E06C6C;
  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --topbar-h: 64px;
}

html, body { overflow-x: clip; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-style: normal; margin: 0; overflow-wrap: anywhere; min-width: 0; }

/* every numeral is data */
.num, .mono, .fmeta, .rmeta, .file-row .idx, #extract-info,
.localnote, .pageno, .field .help {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 32px; }

/* ============ topbar ============ */
.topbar {
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 28px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.brand { text-decoration: none; color: inherit; flex: 0 0 auto; }
.brand .wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
}

/* segmented tool switch — the nav IS the tool picker */
.toolswitch {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 160ms ease-out, color 160ms ease-out;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.localnote {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
}
.livedot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); flex: 0 0 auto; }

/* ============ intro ============ */
.intro { padding: 64px 0 40px; max-width: 720px; }
.intro h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 4.8vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}
.intro .sub { color: var(--ink-2); font-size: 16.5px; margin: 0; max-width: 58ch; }

/* ============ workbench ============ */
.bench { padding: 8px 0 64px; }
.bench-head { margin-bottom: 28px; max-width: 640px; }
.bench-head h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.bench-head .lede { color: var(--ink-2); font-size: 14.5px; margin: 0; max-width: 60ch; }
.bench-head .lede a { color: var(--ink); font-weight: 600; }

.bench-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 40px;
  align-items: start;
}

/* dropzone */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 16px;
  transition: border-color 160ms ease-out, background 160ms ease-out, transform 160ms var(--ease-out);
}
.dropzone:hover { border-color: var(--ink-3); }
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-wash);
  transform: scale(1.01);
}
.dropzone strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.dropzone .hint { font-size: 13px; color: var(--ink-3); }
.dropzone input[type="file"] {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

/* file queue */
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
@keyframes row-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.file-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  min-width: 0; cursor: grab;
  animation: row-in 0.22s var(--ease-out) both;
}
.file-row .idx { color: var(--accent); font-size: 13px; font-weight: 600; flex: 0 0 30px; }
.file-row .fname {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; font-weight: 600;
}
.file-row .fmeta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.file-row .rowbtns { display: flex; gap: 6px; flex: 0 0 auto; }
.file-row.dragging { opacity: 0.4; }
.file-row.dragover-row { border-bottom-color: var(--accent); border-bottom-style: dashed; }

.iconbtn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  border-radius: 3px;
  width: 30px; height: 30px;
  font-size: 15px; line-height: 1;
  cursor: pointer;
  transition: color 140ms ease-out, border-color 140ms ease-out, transform 140ms ease-out;
}
.iconbtn:hover { color: var(--ink); border-color: var(--ink-3); }
.iconbtn:active { transform: scale(0.94); }
.iconbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.iconbtn.danger:hover { color: var(--neg); border-color: var(--neg); }

/* action column */
.bench-actions { position: sticky; top: calc(var(--topbar-h) + 24px); }
.btnrow { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.btn {
  appearance: none;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit; font-weight: 700; font-size: 14.5px;
  padding: 12px 26px;
  cursor: pointer;
  display: inline-block; text-decoration: none; text-align: center;
  transition: transform 140ms ease-out, background 140ms ease-out;
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink-3); background: var(--surface); }

.status { font-size: 13.5px; color: var(--ink-2); min-height: 1.5em; margin: 0 0 12px; }
.status.error { color: var(--neg); font-weight: 600; }
.status.ok { color: var(--pos); font-weight: 600; }

@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.result-card {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--pos);
  border-radius: 6px;
  padding: 20px 22px;
}
.result-card.show { display: block; animation: card-in 0.24s var(--ease-out) both; }
.result-card .rname { font-weight: 700; font-size: 15.5px; margin-bottom: 4px; overflow-wrap: anywhere; }
.result-card .rmeta { font-size: 12.5px; color: var(--ink-2); margin-bottom: 16px; }
.result-card .rmeta .saved { color: var(--pos); font-weight: 700; }
.chainrow { margin-top: 14px; }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(19,19,22,0.25);
  border-top-color: var(--accent-ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* thumbnails */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.thumb {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  padding: 0; color: inherit; font: inherit;
  transition: border-color 140ms ease-out, transform 140ms ease-out;
}
.thumb:hover { transform: translateY(-2px); border-color: var(--ink-3); }
.thumb canvas { display: block; width: 100%; height: auto; background: #fff; }
.thumb .pageno { display: block; text-align: center; font-size: 11.5px; color: var(--ink-3); padding: 5px 0; }
.thumb[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.thumb[aria-pressed="true"] .pageno { color: var(--accent); font-weight: 600; }
.thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumb-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; font-size: 13px; color: var(--ink-2);
}
.thumb-actions { display: flex; gap: 4px; }
.linkbtn {
  appearance: none; background: none; border: none;
  color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 4px 8px; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--line);
}
.linkbtn:hover { color: var(--accent); }

/* fields */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.field input[type="text"] {
  width: 100%; box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  font: inherit; font-family: var(--font-data); font-size: 14px;
  padding: 11px 14px;
  transition: border-color 140ms ease-out;
}
.field input[type="text"]:focus { outline: none; border-color: var(--accent); }
.field .help { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
textarea#out-text {
  width: 100%; box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  font: inherit; font-size: 13.5px; line-height: 1.65;
  padding: 14px;
  resize: vertical; min-height: 220px;
  transition: border-color 140ms ease-out;
}
textarea#out-text:focus { outline: none; border-color: var(--accent); }
.muted { color: var(--ink-3); font-size: 13px; }

/* ============ why — ruled rows, not cards ============ */
.why { border-top: 1px solid var(--line); padding: 40px 0 72px; }
.why h2 {
  font-family: var(--font-display); font-weight: 800;
  font-size: 24px; letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.why-row {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.why-row .why-lead {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  letter-spacing: -0.01em; margin: 0;
}
.why-row p { margin: 0; color: var(--ink-2); font-size: 14.5px; max-width: 62ch; }

/* ============ footer ============ */
footer { border-top: 1px solid var(--line); padding: 32px 0 48px; }
.foot-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 32px; }
.footnav { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.footnav a { color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; width: fit-content; }
.footnav a:hover { text-decoration: underline; text-underline-offset: 3px; }
.sister { font-size: 13.5px; color: var(--ink-2); margin: 0; max-width: 34ch; }
.sister a { color: var(--ink); font-weight: 600; }
.foot-note { font-size: 13px; color: var(--ink-2); margin: 0; max-width: 44ch; }
.colophon {
  grid-column: 1 / -1;
  font-family: var(--font-data);
  font-size: 11.5px;
  color: var(--ink-3);
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 8px;
}

/* ============ doc pages ============ */
.doc { padding: 56px 0 72px; }
.doc-inner { max-width: 68ch; }
.doc h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 4.2vw, 48px);
  letter-spacing: -0.03em; line-height: 1.05;
  margin-bottom: 14px;
}
.doc .lede-sub { color: var(--ink-2); font-size: 16.5px; margin: 0 0 44px; max-width: 56ch; }
.doc-section { border-top: 1px solid var(--line); padding: 26px 0; }
.doc-section h2 {
  font-family: var(--font-display); font-weight: 700;
  font-size: 21px; letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.doc-section p { color: var(--ink-2); margin: 0 0 12px; }
.doc-section p:last-child { margin-bottom: 0; }
.doc-section a { color: var(--ink); font-weight: 600; }
.doc-section strong { color: var(--ink); }
.doc-section ol, .doc-section ul { color: var(--ink-2); padding-left: 24px; margin: 0 0 12px; }
.doc-section li { margin-bottom: 6px; }

/* entrance */
@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.intro > * { animation: rise-in 0.55s var(--ease-out) both; }
.intro > *:nth-child(2) { animation-delay: 0.08s; }
.bench { animation: rise-in 0.55s var(--ease-out) 0.16s both; }
.why { animation: rise-in 0.55s var(--ease-out) 0.24s both; }
.doc > * { animation: rise-in 0.5s var(--ease-out) both; }
.doc > *:nth-child(2) { animation-delay: 0.07s; }
.doc > *:nth-child(3) { animation-delay: 0.14s; }
[role="tabpanel"]:not([hidden]) { animation: rise-in 0.26s var(--ease-out) both; }

/* ============ responsive ============ */
@media (max-width: 900px) {
  .bench-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .bench-actions { position: static; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-note { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
  .topbar-inner { flex-wrap: wrap; row-gap: 10px; }
  .toolswitch { order: 3; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; }
  .toolswitch::-webkit-scrollbar { display: none; }
  .localnote { display: none; }
  .intro { padding-top: 40px; }
  .why-row { grid-template-columns: 1fr; gap: 6px; }
  .foot-grid { grid-template-columns: 1fr; }
  .dropzone { padding: 40px 16px; }
  .file-row .fmeta { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; }
  .spinner { animation: none; }
}
