@font-face { font-family: 'Saira Stencil One'; src: url('/fonts/SairaStencilOne.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Archivo'; src: url('/fonts/Archivo.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/JetBrainsMono.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }

:root {
  --ink: #14202b;
  --ink-2: #1d2c3a;
  --steel: #33475a;
  --paper: #f2eee4;
  --paper-2: #e9e3d5;
  --line: #d3cab7;
  --muted: #6a6f73;
  --signal: #ff5a1f;
  --signal-ink: #c63e0c;
  --verify: #17806f;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Archivo', system-ui, sans-serif;
  --stencil: 'Saira Stencil One', 'Archivo', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--signal-ink); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ---- top bar with the corrugated container wall ---- */
.bar {
  height: 58px; display: flex; align-items: center; gap: 28px; padding: 0 18px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.035) 0 9px, rgba(0,0,0,.18) 9px 12px, rgba(255,255,255,.06) 12px 15px, transparent 15px 22px),
    var(--ink);
  color: var(--paper); border-bottom: 3px solid var(--signal);
}
.mark { text-decoration: none; color: var(--paper); display: flex; align-items: center; gap: 10px; }
.mark-word { font-family: var(--stencil); font-size: 25px; letter-spacing: .06em; }
.mark-word::after { content: ''; display: inline-block; width: 9px; height: 9px; margin-left: 6px; background: var(--signal); transform: translateY(-3px) rotate(45deg); }
.bar-nav { display: flex; gap: 20px; }
.bar-nav a { color: #c9d2da; text-decoration: none; font-weight: 500; font-size: 14px; letter-spacing: .02em; }
.bar-nav a[aria-current] { color: var(--paper); box-shadow: inset 0 -2px 0 var(--signal); padding-bottom: 4px; }
.pill { margin-left: auto; background: transparent; border: 1px solid #50606f; color: #dfe5ea; border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer; }
.pill:hover { border-color: var(--paper); }
.pill.pro { border-color: var(--verify); background: rgba(23,128,111,.25); color: #e8fff9; }

/* ---- workspace ---- */
.workspace { display: grid; grid-template-columns: minmax(400px, 470px) 1fr; height: calc(100vh - 58px); }
.panel { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--paper); min-height: 0; }
.panel-scroll { overflow-y: auto; padding: 18px 18px 8px; flex: 1; }
.block { padding: 4px 0 18px; border-bottom: 1px dashed var(--line); margin-bottom: 14px; }
.block:last-child { border-bottom: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
h2 { font-family: var(--stencil); font-weight: 400; font-size: 18px; letter-spacing: .05em; margin: 0 0 10px; text-transform: uppercase; }
h3 { font-size: 14px; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .06em; }

.units { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.units button { border: 0; background: transparent; padding: 2px 10px; font-size: 12px; font-family: var(--mono); cursor: pointer; }
.units button.on { background: var(--ink); color: var(--paper); }

.container-row { position: relative; background: #fbf9f4; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.container-row .preset { width: calc(100% - 26px); padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: white; font-weight: 600; }
.dims { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-top: 8px; }
.dims label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: flex; flex-direction: column; gap: 3px; }
.dims input { width: 100%; padding: 6px 7px; border: 1px solid var(--line); border-radius: 5px; font-family: var(--mono); font-size: 13px; background: white; }
.x { position: absolute; right: 8px; top: 9px; border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }

.items-head, .item-row { display: grid; grid-template-columns: 10px 1.6fr .8fr .8fr .8fr .65fr .65fr 26px; gap: 5px; align-items: center; }
.items-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 0 4px; }
.item-row { padding: 4px 0; border-bottom: 1px solid #e7e0d0; }
.item-row input { width: 100%; min-width: 0; padding: 6px 6px; border: 1px solid transparent; border-radius: 5px; background: transparent; font-family: var(--mono); font-size: 13px; }
.item-row input[data-k="name"] { font-family: var(--sans); font-weight: 500; }
.item-row input:hover { border-color: var(--line); }
.item-row input:focus { border-color: var(--ink); background: white; outline: none; }
.swatch { width: 10px; height: 22px; border-radius: 2px; background: var(--sw); display: inline-block; }
.left-behind .swatch { height: 12px; margin-right: 8px; vertical-align: -1px; }
.more { border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--muted); }
.item-more { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 13px; padding: 4px 0 6px; }
.item-more select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: white; }
.item-more .check { display: inline-flex; gap: 6px; align-items: center; }
.item-ops { margin-left: auto; display: inline-flex; gap: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }

.link-btn { border: 0; background: none; padding: 4px 0; color: var(--signal-ink); cursor: pointer; font-weight: 600; font-size: 13.5px; text-decoration: none; }
.link-btn:hover { text-decoration: underline; }
.pro-tag { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; background: var(--ink); color: var(--paper); border-radius: 3px; padding: 1px 5px; margin-left: 4px; vertical-align: 1px; }
.is-pro .pro-tag { background: var(--verify); }

.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; font-size: 14px; }
.field select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: white; min-width: 190px; }

.panel-foot { padding: 14px 18px 16px; border-top: 1px solid var(--line); background: var(--paper-2); }
.go { width: 100%; padding: 13px; border: 0; border-radius: 8px; background: var(--signal); color: white; font-family: var(--stencil); font-size: 19px; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; box-shadow: 0 2px 0 var(--signal-ink); }
.go:hover { filter: brightness(1.05); }
.go:disabled { opacity: .6; cursor: progress; }
.go.small { width: auto; padding: 8px 16px; font-size: 15px; }
.hint { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.hint.err { color: #b42318; font-weight: 600; }

/* ---- stage ---- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--ink); color: var(--paper); }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; overflow-x: auto; }
.tabs[hidden] { display: none; }
.tabs button { border: 0; background: var(--ink-2); color: #b9c4cd; padding: 7px 12px; border-radius: 6px 6px 0 0; cursor: pointer; display: flex; gap: 8px; font-size: 13px; white-space: nowrap; }
.tabs button b { font-family: var(--mono); color: var(--paper); }
.tabs button.on { background: #24384a; color: var(--paper); box-shadow: inset 0 2px 0 var(--signal); }
.view { position: relative; flex: 1; min-height: 260px; }
.view canvas { display: block; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #b9c4cd; padding: 20px; pointer-events: none; }
.empty .link-btn { pointer-events: auto; color: #ffb38f; }
.empty-title { font-size: 20px; color: var(--paper); margin: 0 0 6px; }
.view-tools { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 4px; }
.view-tools button { border: 1px solid #3d5163; background: rgba(20,32,43,.75); color: #d6dee5; padding: 5px 11px; border-radius: 5px; font-size: 12px; cursor: pointer; font-family: var(--mono); }
.view-tools button:hover { border-color: var(--signal); }

.stamp {
  position: absolute; right: 18px; top: 16px; transform: rotate(-6deg);
  border: 3px solid #39c2a9; color: #39c2a9; border-radius: 6px; padding: 4px 12px 5px; text-align: center;
  font-family: var(--stencil); letter-spacing: .14em; background: rgba(20,32,43,.55);
  box-shadow: 0 0 0 2px rgba(57,194,169,.25) inset;
}
.stamp span { font-size: 22px; display: block; }
.stamp small { font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em; display: block; opacity: .9; }

.stepper { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-top: 1px solid #263a4b; }
.stepper[hidden] { display: none; }
.stepper button { width: 34px; height: 30px; border-radius: 6px; border: 1px solid #3d5163; background: var(--ink-2); color: var(--paper); cursor: pointer; }
.stepper input { flex: 1; accent-color: var(--signal); }
.stepper .mono { font-size: 12px; color: #b9c4cd; min-width: 90px; text-align: right; }

.readout { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 10px 14px; background: #101a23; }
.readout[hidden] { display: none; }
.tag { background: var(--paper); color: var(--ink); border-radius: 4px; padding: 7px 10px 8px; position: relative; }
.tag::before { content: ''; position: absolute; left: -1px; top: 50%; width: 7px; height: 7px; border-radius: 50%; background: #101a23; transform: translate(-50%, -50%); }
.tag-k { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.tag-v { font-family: var(--mono); font-weight: 600; font-size: 15px; }

.after { padding: 12px 16px 16px; background: var(--paper); color: var(--ink); border-top: 3px solid var(--signal); max-height: 34vh; overflow-y: auto; }
.after[hidden] { display: none; }
.note p { margin: 0 0 8px; background: #fff3e8; border-left: 3px solid var(--signal); padding: 7px 10px; font-size: 14px; }
.left-behind ul { list-style: none; padding: 0; margin: 0 0 8px; columns: 2; }
.left-behind li { padding: 2px 0; font-size: 14px; }
.exports { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ghost { border: 1px solid var(--ink); background: transparent; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.ghost:hover { background: var(--ink); color: var(--paper); }

/* ---- dialogs ---- */
dialog { border: 0; border-radius: 10px; padding: 0; max-width: 560px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(20,32,43,.6); }
.dlg { padding: 20px 22px; background: var(--paper); }
.dlg textarea { width: 100%; font-family: var(--mono); font-size: 12.5px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: white; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 12px; }
.dlg-actions .link-btn { margin-right: auto; }
.dlg-msg { min-height: 1.2em; font-size: 13.5px; color: var(--verify); font-weight: 600; margin: 6px 0 0; }

.print-only { display: none; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; }
  .stage { min-height: 80vh; }
  .readout { grid-template-columns: repeat(2, 1fr); }
  .bar-nav { display: none; }
}

@media print {
  body.app > *:not(#print-sheet) { display: none !important; }
  #print-sheet { display: block !important; color: #000; font-family: var(--sans); }
  #print-sheet h1 { font-family: var(--stencil); letter-spacing: .05em; margin: 0; }
  .ps-meta { color: #333; margin: 2px 0 14px; }
  .ps-load { page-break-before: always; }
  .ps-load:first-of-type { page-break-before: auto; }
  .ps-shots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ps-shots img { width: 100%; border: 1px solid #999; }
  figure { margin: 0; } figcaption { font-size: 11px; }
  table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 10px; }
  th, td { border-bottom: 1px solid #bbb; padding: 3px 5px; text-align: left; font-family: var(--mono); }
  th { font-family: var(--sans); }
}
