/* ————————————————————————————————— The Flat File —
   Aged trace paper, warm ink, vermillion markups.   */

:root {
  --paper: #f2ecdd;
  --paper-deep: #e9e2cf;
  --card: #faf6ec;
  --ink: #221f1a;
  --ink-soft: #5c564a;
  --ink-faint: #a39a87;
  --rule: #c9c0aa;
  --vermillion: #bf4226;
  --blueprint: #2e5d84;
  --table: #26231e;
  --table-deep: #1b1916;
  --table-line: #55503f;
  --table-text: #e8e2d2;
  --table-soft: #9c9481;
  --table-overlay: rgba(27, 25, 22, .88);
  --thumb-bg: #fdfbf4;
  --stamp-bg: rgba(250, 246, 236, .85);
  --grain-o: .5;
  --cols: 5;
  --shadow: 3px 4px 0 rgba(34, 31, 26, .16);
  --shadow-lift: 5px 7px 0 rgba(34, 31, 26, .2);
  --display: "Futura", "Avenir Next Condensed", "Gill Sans", sans-serif;
  --body: "Avenir Next", "Avenir", "Helvetica Neue", sans-serif;
  --mono: "Courier New", "Courier", monospace;
}

/* ————————————————— Themes */

:root[data-theme="vellum"] {
  --paper: #edf0ee;
  --paper-deep: #e0e5e2;
  --card: #fbfcfa;
  --ink: #1d2126;
  --ink-soft: #4e5760;
  --ink-faint: #99a3ab;
  --rule: #c3cbd0;
  --vermillion: #b23a24;
  --blueprint: #1f5f8b;
  --table: #20262b;
  --table-deep: #171c20;
  --table-line: #46525c;
  --table-text: #dfe6ea;
  --table-soft: #8b98a1;
  --table-overlay: rgba(23, 28, 32, .88);
  --thumb-bg: #ffffff;
  --stamp-bg: rgba(251, 252, 250, .85);
  --shadow: 3px 4px 0 rgba(29, 33, 38, .14);
  --shadow-lift: 5px 7px 0 rgba(29, 33, 38, .18);
}

:root[data-theme="graphite"] {
  --paper: #211e18;
  --paper-deep: #2b2720;
  --card: #2e2a22;
  --ink: #e7dfcd;
  --ink-soft: #b0a691;
  --ink-faint: #6f6759;
  --rule: #453f33;
  --vermillion: #d96a4a;
  --blueprint: #7da7c9;
  --table: #1b1916;
  --table-deep: #141210;
  --thumb-bg: #efeadf;
  --stamp-bg: rgba(46, 42, 34, .85);
  --grain-o: .3;
  --shadow: 3px 4px 0 rgba(0, 0, 0, .45);
  --shadow-lift: 5px 7px 0 rgba(0, 0, 0, .55);
}

:root[data-theme="blueprint"] {
  --paper: #123553;
  --paper-deep: #0e2c46;
  --card: #17405f;
  --ink: #e6f0f7;
  --ink-soft: #a8c3d8;
  --ink-faint: #5d84a3;
  --rule: #2c567a;
  --vermillion: #e9c46a;
  --blueprint: #9cc7e8;
  --table: #0a2033;
  --table-deep: #071827;
  --table-line: #2c567a;
  --table-text: #dce9f4;
  --table-soft: #7fa2bd;
  --table-overlay: rgba(7, 24, 39, .88);
  --thumb-bg: #eaf1f6;
  --stamp-bg: rgba(23, 64, 95, .85);
  --grain-o: .25;
  --shadow: 3px 4px 0 rgba(4, 14, 24, .5);
  --shadow-lift: 5px 7px 0 rgba(4, 14, 24, .6);
}

/* Diazo: brownline print — deep sepia lines on ammonia-process tan paper */
:root[data-theme="diazo"] {
  --paper: #e9dbbd;
  --paper-deep: #dfd0ac;
  --card: #f2e8d2;
  --ink: #3c2a1a;
  --ink-soft: #7a6248;
  --ink-faint: #b3a184;
  --rule: #cdbb95;
  --vermillion: #a63d1f;
  --blueprint: #2e6470;
  --table: #241c12;
  --table-deep: #1a140d;
  --table-line: #4f4230;
  --table-text: #ead9bd;
  --table-soft: #a08a68;
  --table-overlay: rgba(26, 20, 13, .88);
  --thumb-bg: #f6efdd;
  --stamp-bg: rgba(242, 232, 210, .85);
  --grain-o: .45;
  --shadow: 3px 4px 0 rgba(60, 42, 26, .18);
  --shadow-lift: 5px 7px 0 rgba(60, 42, 26, .24);
}

/* Phosphor: the CAD years — layer-green linework on a dark terminal */
:root[data-theme="phosphor"] {
  --paper: #0c110c;
  --paper-deep: #080d08;
  --card: #111811;
  --ink: #7be382;
  --ink-soft: #4da65e;
  --ink-faint: #2e6b3c;
  --rule: #1e3a24;
  --vermillion: #e8a03e;
  --blueprint: #4dc4d8;
  --table: #071007;
  --table-deep: #040a04;
  --table-line: #1c3a22;
  --table-text: #a9edb1;
  --table-soft: #4da65e;
  --table-overlay: rgba(4, 10, 4, .9);
  --thumb-bg: #edf2e6;
  --stamp-bg: rgba(17, 24, 17, .85);
  --grain-o: .25;
  --shadow: 3px 4px 0 rgba(0, 0, 0, .5);
  --shadow-lift: 5px 7px 0 rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

.grain {
  position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: var(--grain-o);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.frame { min-height: 100vh; display: flex; flex-direction: column; }

/* ————————————————— Title block header */

.titleblock {
  display: grid;
  grid-template-columns: auto 1fr auto auto 110px;
  border: 2px solid var(--ink);
  margin: 18px 22px 0;
  background: var(--card);
  box-shadow: var(--shadow);
}

.titleblock > * {
  border-right: 1.5px solid var(--ink);
  padding: 12px 18px;
}
.titleblock > *:last-child { border-right: none; }

.tb-brand h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: .22em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.05;
}
.tb-brand .tb-sub {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--vermillion);
  font-weight: 700;
}

.tb-cell label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.tb-cell label kbd {
  font-family: var(--mono);
  font-weight: 400;
  letter-spacing: 0;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
  color: var(--ink-soft);
}

.tb-search input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--ink);
  background: transparent;
  font-family: var(--body);
  font-size: 17px;
  padding: 2px 0 4px;
  color: var(--ink);
  border-radius: 0;
}
.tb-search input:focus { outline: none; border-bottom-color: var(--vermillion); }
.tb-search input::placeholder { color: var(--ink-faint); font-style: italic; }

.tb-count output {
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: .06em;
  white-space: nowrap;
}
.tb-count output.fraction { font-size: 16px; }

.tb-actions { display: flex; align-items: center; }

.view-controls { display: flex; align-items: center; gap: 10px; padding-top: 2px; }

/* density stepper, top-right of the grid content */
.grid-tools {
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
  margin: -6px 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.grid-tools #cols-count { color: var(--ink-soft); font-weight: 700; }

/* Worded view tabs — drawing-stage stamps in the title block */
.seg { display: flex; border: 1.5px solid var(--ink); }
.seg-btn {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  background: none;
  border: none;
  border-right: 1.5px solid var(--ink);
  color: var(--ink);
  padding: 5px 11px 4px;
  cursor: pointer;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:not(.active):hover { background: var(--paper-deep); }
.seg-btn.active { background: var(--ink); color: var(--card); }

.mini-btn {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  width: 26px; height: 26px;
  line-height: 1;
  cursor: pointer;
}
.mini-btn:hover { background: var(--vermillion); border-color: var(--vermillion); color: var(--card); }

#cols-count {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  min-width: 1.2em;
  text-align: center;
}

.view-sep { width: 1.5px; height: 20px; background: var(--rule); margin: 0 2px; }

#theme-select {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: transparent;
  color: var(--ink);
  border: none;
  border-bottom: 1.5px solid var(--ink);
  padding: 3px 2px 4px;
  border-radius: 0;
  cursor: pointer;
}
#theme-select:focus { outline: none; border-bottom-color: var(--vermillion); }

.btn {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border: 1.5px solid var(--ink);
  padding: 9px 16px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { background: var(--vermillion); border-color: var(--vermillion); }
.btn:active { transform: translate(1px, 1px); }
.btn[disabled] { opacity: .5; cursor: wait; }

/* ————————————————— Workspace: drawers + grid */

.workspace {
  display: grid;
  grid-template-columns: 218px 1fr;
  gap: 0 22px;
  padding: 18px 22px 60px;
  flex: 1;
  align-items: start;
}

.drawers {
  position: sticky; top: 18px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 4px 0 10px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}

.drawers section { padding: 10px 0 4px; }
.drawers section + section { border-top: 1px solid var(--rule); }

.drawers h2 {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 14px 6px;
}

.drawers ul { list-style: none; margin: 0; padding: 0; }
.drawers .h2-hint { font-weight: 400; letter-spacing: .08em; opacity: .55; text-transform: lowercase; }

.drawer {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  font-family: var(--body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  padding: 6px 14px 6px 11px;
  cursor: pointer;
}
.drawer:hover { background: var(--paper-deep); }
.drawer.active {
  border-left-color: var(--vermillion);
  background: var(--paper-deep);
  font-weight: 700;
}
.drawer-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 700;
}

.drawer-more {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
  font-style: italic;
}
.drawer.active .drawer-count { color: var(--vermillion); }

.drawers-note {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  margin: 12px 14px 2px;
  line-height: 1.5;
}

/* ————————————————— Project groups & cards */

.project-group { margin-bottom: 34px; }

.project-head {
  display: flex; align-items: baseline; gap: 14px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 6px;
  margin-bottom: 16px;
}
.project-head h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 19px;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin: 0;
}
.project-head .sheet-count {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink-soft);
}

/* Project description under the heading — a pencilled note on the drawer label */
.project-desc {
  margin: -8px 0 16px;
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 78ch;
  cursor: text;
}
.project-desc.empty { opacity: .5; }
.project-desc-edit {
  display: block;
  width: 100%; max-width: 78ch;
  margin: -8px 0 16px;
  font: italic 13.5px/1.5 inherit;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--ink-soft);
  padding: 6px 8px;
  resize: vertical;
}
.project-desc-edit:focus { outline: none; border-color: var(--vermillion); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1.5px solid var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform .14s ease, box-shadow .14s ease;
  animation: card-in .4s ease backwards;
}
.card:hover { transform: translate(-2px, -3px); box-shadow: var(--shadow-lift); }
.card:active { transform: translate(0, 0); box-shadow: var(--shadow); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-thumb {
  position: relative;
  aspect-ratio: 3 / 2;
  background: var(--thumb-bg);
  border-bottom: 1.5px solid var(--ink);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card-thumb img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.card-thumb .thumb-wait {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stamps {
  position: absolute; top: 8px; right: 8px;
  display: flex; flex-direction: column; gap: 5px; align-items: flex-end;
}

.stamp {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--vermillion);
  border: 1.5px solid var(--vermillion);
  padding: 2px 7px;
  background: var(--stamp-bg);
  transform: rotate(3deg);
}
.stamp.missing { color: var(--ink-soft); border-color: var(--ink-soft); }
.stamp.bit { color: var(--blueprint); border-color: var(--blueprint); transform: rotate(-2deg); }

.card-body { padding: 10px 12px 11px; display: flex; flex-direction: column; gap: 6px; flex: 1; }

.card-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.card-title.untitled { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); font-weight: 400; }

.card-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: auto;
}

.cat-chip {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blueprint);
  border: 1px solid var(--blueprint);
  padding: 1.5px 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.card-star {
  margin-left: auto;
  background: none; border: none;
  font-size: 16px;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.card-star.on { color: var(--vermillion); }
.card-star:hover { color: var(--vermillion); }

.card-no {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-soft);
  letter-spacing: .06em;
}

.card.is-missing { opacity: .55; }

.empty-state {
  border: 1.5px dashed var(--ink-faint);
  padding: 60px 20px;
  text-align: center;
  font-family: var(--mono);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-size: 13px;
}

/* ————————————————— Viewer: the light table */

.viewer {
  position: fixed; inset: 0; z-index: 100;
  background: var(--table);
  display: flex; flex-direction: column;
  color: var(--table-text);
}
.viewer[hidden] { display: none; }

.v-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--table-deep);
  border-bottom: 1px solid var(--table-line);
}

.v-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.v-title strong {
  font-family: var(--display);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.v-title span {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--table-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.v-nav { display: flex; align-items: center; gap: 6px; }
#v-position { font-family: var(--mono); font-size: 11px; color: var(--table-soft); margin-right: 6px; }
/* Search strip: everything about the active search, in one labelled row */
.v-search-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px;
  background: var(--table-overlay);
  border-bottom: 1px solid var(--table-line);
  font-family: var(--mono); font-size: 11px;
  color: var(--table-soft);
  letter-spacing: .04em;
}
.v-search-strip[hidden] { display: none; }
.strip-label { text-transform: uppercase; letter-spacing: .18em; font-size: 10px; }
.strip-terms { display: flex; gap: 4px; max-width: 38%; overflow: hidden; }
.strip-dot { color: var(--table-line); }
.strip-btn { padding: 2px 8px; }
.v-search-strip .v-btn { font-size: 11px; }
.v-term {
  font-family: var(--mono); font-size: 11px;
  color: #201d18;
  background: rgba(255, 214, 0, .8);
  padding: 2px 7px;
  border-radius: 3px 9px 4px 8px / 8px 4px 9px 3px;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.v-btn {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: transparent;
  color: var(--table-text);
  border: 1.5px solid var(--table-line);
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.v-btn:hover { border-color: var(--table-text); }
.v-btn.active, .v-btn:active { background: var(--table-text); color: var(--table-deep); }

.v-body { flex: 1; display: flex; min-height: 0; }

.v-stage {
  flex: 1; position: relative; overflow: hidden;
  cursor: grab;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 250, 230, .07), transparent 65%),
    var(--table);
}
.v-stage.dragging { cursor: grabbing; }

.v-canvas-wrap { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.v-canvas-wrap canvas { display: block; box-shadow: 0 12px 60px rgba(0, 0, 0, .55); background: #fff; }

.v-loading[hidden] { display: none; }

.v-loading {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--table-text);
  display: flex; align-items: center; gap: 10px;
  background: var(--table-overlay);
  border: 1px solid var(--table-line);
  padding: 7px 14px;
}
.v-loading span {
  width: 10px; height: 10px;
  border: 2px solid var(--table-text); border-top-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.v-controls {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: var(--table-overlay);
  border: 1px solid var(--table-line);
  padding: 7px;
}
.v-zoom-label { min-width: 64px; text-align: center; }
.v-sep { width: 1px; height: 20px; background: var(--table-line); margin: 0 4px; }
#v-hits.muted { opacity: .45; text-decoration: line-through; }

/* Search-hit highlighter marks over the sheet */
.v-hl-layer { position: absolute; top: 0; left: 0; pointer-events: none; }
.v-hl-layer[hidden] { display: none; }
.v-hl {
  position: absolute;
  background: rgba(255, 214, 0, .42);
  border-radius: 20% / 50%;
  mix-blend-mode: multiply;
}
.v-hl.active {
  background: rgba(255, 205, 0, .5);
  /* red-pencil ring; divided by the current zoom so it stays hairline-thin */
  box-shadow: 0 0 0 calc(1.5px / var(--z, 1)) var(--vermillion);
  transition: box-shadow .25s ease;
}
/* Approximate hit: dashed pencil ring, not a marker stroke — the position is
   inferred (near-spelling or garbled machine-read of handwriting) */
.v-hl.approx {
  background: rgba(255, 214, 0, .1);
  border: calc(2.5px / var(--z, 1)) dashed var(--vermillion);
  border-radius: 50% / 50%;
}
.v-hl.approx.active {
  background: rgba(255, 205, 0, .3);
  box-shadow: none;
}

/* ————————————————— Timeline view */

.workspace.timeline-mode { grid-template-columns: 1fr; }
.workspace.timeline-mode .drawers { display: none; }
.mini-btn.active { background: var(--ink); border-color: var(--ink); color: var(--card); }

.timeline {
  position: relative;
  max-width: 860px;
  margin: 10px auto 60px;
  padding: 24px 0 10px;
}
/* the spine: a dimension line running down the page */
.timeline::before {
  content: '';
  position: absolute;
  left: 96px; top: 0; bottom: 0;
  width: 2px;
  background: var(--ink);
}

.tl-entry {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 44px;
  margin: 0 0 44px;
}
.tl-year {
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .06em;
  text-align: right;
  color: var(--ink);
  padding-top: 2px;
}
.tl-body { position: relative; }
/* survey-marker node on the spine */
.tl-body::before {
  content: '';
  position: absolute;
  left: -19px; top: 9px;
  width: 9px; height: 9px;
  background: var(--vermillion);
  transform: translateX(-50%) rotate(45deg);
}
.tl-body h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 21px;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: 0 0 4px;
  cursor: pointer;
}
.tl-body h3:hover { color: var(--vermillion); }
.tl-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 8px;
  display: flex; align-items: center; gap: 10px;
}
.tl-coast {
  border: 1px solid var(--vermillion);
  color: var(--vermillion);
  padding: 1px 7px;
  border-radius: 2px 8px 3px 7px / 7px 3px 8px 2px;
}
.tl-desc {
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 64ch;
  margin: 0 0 12px;
}
.tl-thumbs { display: flex; gap: 8px; align-items: stretch; }
.tl-thumbs img {
  height: 74px;
  border: 1px solid var(--ink);
  background: #fff;
  cursor: pointer;
}
.tl-thumbs img:hover { outline: 2px solid var(--vermillion); }
.tl-more {
  font-family: var(--mono);
  font-size: 12px;
  padding: 0 12px;
  background: none;
  border: 1px dashed var(--ink-soft);
  color: var(--ink-soft);
  cursor: pointer;
}
.tl-more:hover { border-color: var(--vermillion); color: var(--vermillion); }

/* long silences: break the dimension line */
.tl-gap {
  position: relative;
  height: 46px;
  margin: 0 0 44px;
}
.tl-gap i {
  position: absolute;
  left: 97px; top: 50%;
  transform: translate(-50%, -50%);
  font-style: normal;
  font-size: 22px;
  color: var(--ink);
  background: var(--paper);
  padding: 2px 0;
  line-height: 1;
}
.tl-gap span {
  position: absolute;
  left: 140px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: .7;
}

.tl-era {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 44px;
  margin: 0 0 30px;
}
.tl-era span {
  grid-column: 2;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--vermillion);
  border-bottom: 1px solid var(--rule, var(--ink-soft));
  padding-bottom: 5px;
}
.tl-note {
  margin: 10px 0 0 116px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  font-style: italic;
}

@media (max-width: 700px) {
  .timeline::before { left: 52px; }
  .tl-entry, .tl-era { grid-template-columns: 36px 1fr; gap: 32px; }
  .tl-year { font-size: 14px; }
  .tl-body::before { left: -15px; }
  .tl-gap i { left: 53px; }
  .tl-gap span { left: 84px; }
  .tl-note { margin-left: 68px; }
}

/* ————————————————— Scan-rolls view */

.workspace.rolls-mode { grid-template-columns: 1fr; }
.workspace.rolls-mode .drawers { display: none; }

.rolls-batch { max-width: 1060px; margin: 14px auto 46px; }
.rolls-batch h3 {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--vermillion);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 5px;
  margin: 0 0 14px;
}
/* the pigeonhole rack */
.rolls-rack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 3px;
  background: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow);
}
.roll-cell {
  background: var(--card);
  box-shadow: inset 0 16px 26px rgba(34, 31, 26, .16), inset 0 -6px 12px rgba(34, 31, 26, .06);
  border: none;
  padding: 24px 14px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.roll-cell:hover { background: var(--thumb-bg); }
.roll-cell:hover .roll-tag { border-color: var(--vermillion); color: var(--vermillion); }
.roll-cell svg { width: 112px; height: 116px; flex-shrink: 0; }
.roll-tag {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.45;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--ink-soft);
  padding: 6px 12px 7px;
  max-width: 100%;
  box-shadow: 2px 2px 0 rgba(34, 31, 26, .12);
}
.roll-tag b {
  display: block;
  font-size: 11px;
  letter-spacing: .06em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.roll-tag .roll-meta { display: block; color: var(--ink-soft); letter-spacing: .12em; text-transform: uppercase; font-size: 9.5px; margin-top: 2px; }
.roll-tag .roll-projects {
  display: block;
  color: var(--ink-soft);
  font-size: 9.5px;
  margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ————————————————— Sheet record panel */

.v-panel {
  width: 320px; flex-shrink: 0;
  background: var(--card);
  color: var(--ink);
  border-left: 2px solid var(--ink);
  overflow-y: auto;
  padding: 18px 20px 30px;
}
.v-panel.hidden { display: none; }

.v-panel h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: .24em;
  text-transform: uppercase;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}

.field { margin-bottom: 14px; flex: 1; }
.field-row { display: flex; gap: 14px; }

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.field .hint { text-transform: none; letter-spacing: .04em; font-weight: 400; }

.field input, .field select, .field textarea {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--ink);
  background: transparent;
  font-family: var(--body);
  font-size: 14.5px;
  color: var(--ink);
  padding: 3px 0 4px;
  border-radius: 0;
}
.field textarea { border: 1.5px solid var(--rule); padding: 7px 9px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--vermillion); }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); font-style: italic; opacity: 1; }

.date-parts { display: flex; gap: 12px; }
.date-parts input:first-child { flex: 0 0 4em; }
.date-parts select { flex: 1; }
.date-parts input:last-child { flex: 0 0 3em; }

.v-panel-foot { align-items: center; margin-top: 4px; }

.star-btn { background: transparent; color: var(--ink); }
.star-btn:hover { background: transparent; color: var(--vermillion); border-color: var(--vermillion); }
.star-btn.on { background: var(--vermillion); border-color: var(--vermillion); color: var(--card); }

.save-stamp {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--blueprint);
  border: 1.5px solid var(--blueprint);
  padding: 3px 8px;
  transform: rotate(-3deg);
  opacity: 0;
  transition: opacity .25s ease;
}
.save-stamp.show { opacity: 1; }

.file-facts {
  margin: 22px 0 0;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
}
.file-facts dt { font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: 9.5px; margin-top: 8px; }
.file-facts dd { margin: 1px 0 0; overflow-wrap: anywhere; }

.ocr-details {
  margin-top: 14px;
  border-top: 1px solid var(--rule);
  padding-top: 10px;
}
.ocr-details summary {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
}
.ocr-details summary:hover { color: var(--vermillion); }
.ocr-details #ocr-count { font-weight: 400; letter-spacing: .06em; text-transform: none; }
.ocr-details textarea {
  width: 100%;
  font-family: var(--body);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  margin-top: 8px;
  padding: 7px 9px;
  border: 1.5px solid var(--rule);
  background: transparent;
  resize: vertical;
}
.ocr-details textarea:focus { outline: none; border-color: var(--vermillion); }

.ocr-details pre {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 300px;
  overflow-y: auto;
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  background: var(--paper-deep);
}

/* ————————————————— Small screens */

@media (max-width: 900px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important; }
  .workspace { grid-template-columns: 1fr; }
  .drawers { position: static; max-height: none; margin-bottom: 18px; }
  .titleblock { grid-template-columns: 1fr; }
  .titleblock > * { border-right: none; border-bottom: 1.5px solid var(--ink); }
  .titleblock > *:last-child { border-bottom: none; }
  .v-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: -10px 0 40px rgba(0,0,0,.4); }
}
