/* kigumi table — washi paper, sumi ink, one vermilion accent */

:root {
  --paper: #F3EFE6;
  --paper-2: #EFEADF;
  --stage: #E9E3D7;
  --ink: #26231F;
  --ink-2: #57514A;
  --ink-3: #8F877C;
  --ink-4: #B5AC9F;
  --hair: rgba(38, 35, 31, 0.15);
  --hair-2: rgba(38, 35, 31, 0.08);
  --accent: #C8432B;
  --accent-wash: rgba(200, 67, 43, 0.07);
  --moss: #6F8460;
  --ochre: #C29433;
  --sans: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Helvetica Neue", "Liberation Sans", Arial, system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Yu Mincho", "Hiragino Mincho ProN", Georgia, "DejaVu Serif", serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", "DejaVu Sans Mono", monospace;
  --left: 300px;
  --right: 272px;
  --top: 50px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-rows: var(--top) minmax(0, 1fr);
  grid-template-columns: var(--left) minmax(0, 1fr) var(--right);
  grid-template-areas: "top top top" "params stage report";
  font: 12.5px/1.45 var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
/* washi: fine pulp grain plus long fibres */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='a'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.36  0 0 0 0 0.28  0 0 0 0.07 0'/></filter><filter id='b'><feTurbulence type='fractalNoise' baseFrequency='0.035 0.05' numOctaves='3' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.44  0 0 0 0 0.36  0 0 0 -0.32 0.18'/></filter><rect width='100%' height='100%' filter='url(%23a)'/><rect width='100%' height='100%' filter='url(%23b)'/></svg>");
  mix-blend-mode: multiply;
}
body > * { position: relative; z-index: 1; }

button, input, select { font: inherit; color: inherit; }
kbd {
  font: 500 9.5px/1 var(--sans);
  color: var(--ink-3);
  border: 1px solid var(--hair);
  border-radius: 2px;
  padding: 1px 3px 2px;
  margin-left: 6px;
  vertical-align: 1px;
}
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px 0 20px;
  border-bottom: 1px solid var(--hair);
  background: rgba(243, 239, 230, 0.6);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: calc(var(--left) - 40px); }
.brand .mark { width: 15px; height: 15px; color: var(--ink); }
.brand .title { font: 400 15.5px/1 var(--serif); letter-spacing: 0.04em; }
.tools, .actions { display: flex; align-items: center; gap: 10px; }
.actions { margin-left: auto; }
.sep { width: 1px; height: 18px; background: var(--hair); margin: 0 4px; }
.field { display: inline-flex; align-items: baseline; gap: 7px; }
.flabel { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
#preset { min-width: 150px; }
#preset.custom { color: var(--ink-3); font-style: italic; }
#seed {
  width: 86px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--hair);
  padding: 2px 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  -moz-appearance: textfield;
}
#seed:focus { outline: none; border-bottom-color: var(--accent); color: var(--ink); }

.btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--hair);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.28);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--ink-3); background: rgba(255, 255, 255, 0.55); }
.btn:active { color: var(--accent); border-color: var(--accent); }
.btn.working { color: var(--accent); border-color: rgba(200, 67, 43, 0.5); }
.btn .dotwork { display: none; }
.btn.working .dotwork {
  display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%;
  background: var(--accent); vertical-align: 1px; animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; } }

select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238F877C' stroke-width='1.2'/></svg>") no-repeat right 1px center / 8px 5px;
  border: 0;
  border-bottom: 1px solid var(--hair);
  border-radius: 0;
  padding: 2px 16px 2px 0;
  cursor: pointer;
  color: var(--ink);
}
select:hover { border-bottom-color: var(--ink-3); }
select:focus-visible { outline: none; border-bottom-color: var(--accent); }
option { color: var(--ink); background: var(--paper); font-style: normal; }

/* ------------------------------------------------------------------ panels */
.panel {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
}
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: var(--hair); border-radius: 3px; }
.params { grid-area: params; border-right: 1px solid var(--hair); padding: 0 18px 40px 20px; }
.filter {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0 8px;
  background: linear-gradient(var(--paper) 80%, rgba(243, 239, 230, 0));
  color: var(--ink-3);
}
.filter svg { width: 12px; height: 12px; flex-shrink: 0; }
.filter input {
  flex: 1; min-width: 0;
  border: 0; border-bottom: 1px solid var(--hair);
  background: transparent; padding: 3px 0;
  font-size: 12px; color: var(--ink);
}
.filter input::placeholder { color: var(--ink-4); }
.filter input:focus { outline: none; border-bottom-color: var(--accent); }
.filter input::-webkit-search-cancel-button { -webkit-appearance: none; }
.filter kbd { margin: 0; }
.row[hidden], .group[hidden] { display: none !important; }
.group.filtering .group-body { display: block !important; }
.empty-filter { padding: 18px 0; color: var(--ink-3); }
.hist { display: inline-flex; gap: 2px; margin-left: 2px; }
.icon {
  width: 26px; height: 28px; display: grid; place-items: center;
  border: 0; background: none; border-radius: 2px; color: var(--ink-2); cursor: pointer;
}
.icon svg { width: 14px; height: 14px; }
.icon:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, 0.4); }
.icon:active:not(:disabled) { color: var(--accent); }
.icon:disabled { color: var(--ink-4); opacity: 0.5; cursor: default; }
.report { grid-area: report; border-left: 1px solid var(--hair); padding: 4px 20px 40px 18px; }

/* groups */
.group { border-bottom: 1px solid var(--hair-2); }
.group-head { display: flex; align-items: center; gap: 4px; padding: 10px 0 6px; }
.group-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
  text-align: left;
}
.group-name { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.group-count { font-size: 10px; color: var(--ink-4); }
.chev { display: inline-grid; width: 9px; height: 9px; color: var(--ink-3); transition: transform .18s; transform: rotate(90deg); }
.chev svg { width: 9px; height: 9px; }
.group.collapsed .chev { transform: rotate(0deg); }
.group.collapsed .group-body { display: none; }
.group-toggle:hover .group-name { color: var(--ink); }
.lock {
  width: 24px; height: 22px;
  display: grid; place-items: center;
  border: 0; background: none; border-radius: 2px;
  color: var(--ink-4);
  cursor: pointer;
}
.lock svg { width: 12px; height: 12px; }
.lock:hover { color: var(--ink-2); }
.lock[aria-pressed="true"] { color: var(--accent); }
.group.locked .group-name { color: var(--ink); }
.group-body { padding: 0 0 10px; }

/* rows */
.row { padding: 5px 0 2px; }
.lbl { color: var(--ink-2); font-size: 11.5px; line-height: 1.3; user-select: none; }
.row:hover .lbl { color: var(--ink); }
.row.changed > .lbl::after,
.row.changed .check span::after {
  content: "";
  display: inline-block;
  width: 4px; height: 4px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--ink-3);
  vertical-align: 2px;
}
.row.num {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px;
  column-gap: 8px;
  align-items: end;
}
.row.num .slider { grid-column: 1 / -1; margin-top: 1px; }
.val {
  width: 62px;
  text-align: right;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 1px 0 0;
  font-size: 12px;
  color: var(--ink);
  -moz-appearance: textfield;
}
.val::-webkit-outer-spin-button, .val::-webkit-inner-spin-button,
#seed::-webkit-outer-spin-button, #seed::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.val:hover { border-bottom-color: var(--hair); }
.val:focus { outline: none; border-bottom-color: var(--accent); }
.row.choice { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0 4px; }
.row.choice select { max-width: 58%; font-size: 12px; text-align: right; }
.row.bool { padding: 7px 0 4px; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none;
  width: 11px; height: 11px; margin: 0; flex-shrink: 0;
  border: 1px solid var(--ink-3); border-radius: 2px;
  display: inline-grid; place-content: center; cursor: pointer;
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
  content: ""; width: 5px; height: 2.5px;
  border: 1.4px solid #fff; border-top: 0; border-right: 0;
  transform: translate(0, -0.5px) rotate(-45deg);
}
.row.text input { width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--hair); }

/* sliders */
input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --fill: 0%;
}
.slider:focus { outline: none; }
.slider::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(to right, var(--ink-3) var(--fill), var(--hair) var(--fill));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 9px; height: 9px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--ink-2);
  transition: transform .12s, background .12s, border-color .12s;
}
.slider:hover::-webkit-slider-thumb { border-color: var(--ink); transform: scale(1.18); }
.slider:active::-webkit-slider-thumb,
.slider:focus-visible::-webkit-slider-thumb { background: var(--accent); border-color: var(--accent); }
.row.active .slider::-webkit-slider-runnable-track,
.slider:active::-webkit-slider-runnable-track {
  background: linear-gradient(to right, var(--accent) var(--fill), var(--hair) var(--fill));
}
.slider::-moz-range-track { height: 1px; background: var(--hair); }
.slider::-moz-range-progress { height: 1px; background: var(--ink-3); }
.slider::-moz-range-thumb { width: 8px; height: 8px; border-radius: 50%; background: var(--paper); border: 1px solid var(--ink-2); }
.slider:active::-moz-range-thumb { background: var(--accent); border-color: var(--accent); }
.slider:disabled { opacity: 0.4; cursor: default; }

/* ------------------------------------------------------------------ stage */
.stage {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  background: var(--stage);
  min-width: 0;
}
#gl-host { position: absolute; inset: 0; }
#gl-host canvas { display: block; outline: none; touch-action: none; }
.stage.hovering #gl-host canvas { cursor: crosshair; }
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(130% 110% at 50% 42%, rgba(0, 0, 0, 0) 58%, rgba(70, 52, 34, 0.07) 100%);
}
.busyline {
  position: absolute; left: 0; right: 0; top: 0; height: 1.5px;
  overflow: hidden; opacity: 0; transition: opacity .25s;
  pointer-events: none;
}
.busyline::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 34%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: sweep 1.1s ease-in-out infinite;
}
@keyframes sweep { from { left: -34%; } to { left: 100%; } }
.stage.busy .busyline { opacity: 0.85; transition-delay: .12s; }
.status {
  position: absolute; left: 18px; top: 12px;
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3);
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.stage.busy .status { opacity: 1; transition-delay: .25s; }
#busy-label:not(:empty)::after { content: "…"; }

.viewtools { position: absolute; right: 14px; top: 12px; display: flex; gap: 6px; }
.chip {
  height: 24px; padding: 0 9px;
  background: rgba(243, 239, 230, 0.72);
  border: 1px solid var(--hair);
  border-radius: 2px;
  font-size: 11px; color: var(--ink-2);
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--accent); border-color: rgba(200, 67, 43, 0.45); }
.chip:disabled { opacity: 0.4; cursor: default; }
.chip kbd { margin-left: 5px; }
.hint {
  position: absolute; right: 16px; bottom: 76px;
  font-size: 10.5px; color: var(--ink-4); pointer-events: none;
}
.hint kbd { margin-left: 0; }

/* hover tooltip */
.tip {
  position: absolute; left: 0; top: 0;
  display: none;
  flex-direction: column; gap: 1px;
  max-width: 280px;
  padding: 7px 10px 8px;
  background: rgba(246, 243, 236, 0.94);
  border: 1px solid var(--hair);
  box-shadow: 0 6px 18px rgba(40, 30, 20, 0.08);
  font-size: 11.5px; color: var(--ink-2);
  pointer-events: none;
  z-index: 5;
}
.tip.show { display: flex; }
.tip b { font: 600 12px var(--mono); color: var(--ink); }
.tip .faint { color: var(--ink-3); }

/* toast */
.toast {
  position: absolute; left: 50%; bottom: 84px;
  transform: translate(-50%, 8px);
  max-width: min(560px, 80%);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  padding: 8px 10px 8px 14px;
  background: rgba(246, 243, 236, 0.96);
  border: 1px solid var(--hair);
  border-left: 2px solid var(--ink-3);
  box-shadow: 0 8px 24px rgba(40, 30, 20, 0.08);
  font-size: 12px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 6;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { border-left-color: var(--accent); }
.toast .msg { flex: 1; min-width: 0; }
.toast details { width: 100%; font-size: 11px; color: var(--ink-3); }
.toast pre { max-height: 180px; overflow: auto; font: 10.5px/1.4 var(--mono); white-space: pre-wrap; margin: 6px 0 0; }
.x { background: none; border: 0; font-size: 16px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 0 2px; }
.x:hover { color: var(--ink); }

/* dock */
.dock {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: minmax(200px, 270px) minmax(0, 1fr);
  gap: 34px;
  align-items: start;
  padding: 18px 22px 14px;
  background: linear-gradient(to top, rgba(233, 227, 215, 0.97) 35%, rgba(233, 227, 215, 0));
}
.dock label, .steplabel { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.explode { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; row-gap: 1px; align-items: center; }
.explode .dval { grid-column: 2; font-size: 11px; color: var(--ink-3); }
.assembly {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  column-gap: 12px; row-gap: 1px;
  align-items: center;
}
.assembly .stepcap {
  grid-column: 3;
  font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.assembly .stepcap b { font-weight: 600; color: var(--ink-2); margin-right: 6px; }
.assembly.partial .stepcap { color: var(--ink); }
.assembly.partial .stepcap b { color: var(--accent); }
.play {
  grid-row: 1;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--ink-3);
  background: rgba(243, 239, 230, 0.8);
  color: var(--ink-2);
  cursor: pointer;
}
.play svg { width: 10px; height: 10px; }
.play:hover { border-color: var(--ink); color: var(--ink); }
.play[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------------ report */
.rsec { padding: 14px 0 12px; border-bottom: 1px solid var(--hair-2); }
.rsec:last-child { border-bottom: 0; }
.rsec h3 {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0 0 8px;
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  font-weight: 600; color: var(--ink-2);
}
.rsec h3 .faint { font-weight: 400; letter-spacing: 0.04em; }
.rsec p { margin: 0; }
.faint { color: var(--ink-3); }
.small { font-size: 10.5px; margin-top: 4px !important; }
.headline { padding-top: 18px; }
.dims { display: flex; align-items: baseline; gap: 6px; font: 300 22px/1.1 var(--serif); letter-spacing: 0.01em; }
.dims i { font-style: normal; font-size: 14px; color: var(--ink-4); }
.dims em { font: 11px var(--sans); font-style: normal; color: var(--ink-3); margin-left: 2px; }
.headline .sub { margin-top: 6px; color: var(--ink-2); }
.headline .sub b { font: 400 16px var(--serif); color: var(--ink); }
ul.kv, ul.counts, ul.notes, ul.checks, ul.files { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; justify-content: space-between; gap: 10px; padding: 1.5px 0; }
.kv .k { color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.kv .v { color: var(--ink); }
.sw { width: 9px; height: 9px; border-radius: 1px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); display: inline-block; }
.counts { display: flex; flex-wrap: wrap; gap: 3px 12px; color: var(--ink-2); }
.counts b { color: var(--ink); font-weight: 600; }
.tiers { display: flex; flex-direction: column; gap: 4px; }
.tier { display: grid; grid-template-columns: 12px minmax(0, 1fr) 18px; align-items: center; gap: 8px; font-size: 11px; }
.tier .tn { color: var(--ink-4); }
.tier .tc { text-align: right; color: var(--ink); }
.tier .bar { height: 5px; background: var(--hair-2); }
.tier .bar i { display: block; height: 100%; background: var(--ink-3); }
.notes li { position: relative; padding: 2px 0 2px 12px; color: var(--ink-2); }
.notes li::before { content: ""; position: absolute; left: 0; top: 0.75em; width: 5px; height: 1px; background: var(--ink-3); }
.checks li {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: baseline; column-gap: 6px; padding: 2px 0;
}
.checks .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); transform: translateY(-1px); }
.checks .pass .dot { background: var(--moss); }
.checks .warn .dot { background: var(--ochre); }
.checks .fail .dot { background: var(--accent); }
.checks .cname { color: var(--ink-2); }
.checks .cval { color: var(--ink); }
.checks .lim { color: var(--ink-3); }
.checks .cdetail { grid-column: 2 / -1; font-size: 10.5px; line-height: 1.35; color: var(--ink-3); padding-bottom: 3px; }
.checks li.pass { cursor: default; }
.pill { font-size: 9.5px; letter-spacing: 0.08em; padding: 1px 6px; border-radius: 8px; border: 1px solid var(--hair); font-weight: 500; }
.pill.pass { color: var(--moss); }
.pill.warn { color: var(--ochre); border-color: rgba(194, 148, 51, 0.4); }
.pill.fail { color: var(--accent); border-color: rgba(200, 67, 43, 0.4); }
details.cut summary { list-style: none; cursor: pointer; }
details.cut summary::-webkit-details-marker { display: none; }
details.cut summary h3 { margin: 0; }
details.cut summary h3::after { content: "+"; margin-left: auto; color: var(--ink-3); font-weight: 400; }
details.cut[open] summary h3::after { content: "−"; }
details.cut table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 11px; }
details.cut th { text-align: left; font-weight: 500; color: var(--ink-3); border-bottom: 1px solid var(--hair); padding: 2px 4px 3px 0; }
details.cut td { padding: 1.5px 4px 1.5px 0; color: var(--ink-2); border-bottom: 1px solid var(--hair-2); }
details.cut td:first-child { font-family: var(--mono); font-size: 10.5px; }
details.cut .r { text-align: right; }
details.cut tr[data-part]:hover td { color: var(--accent); }
.build p b { font-weight: 600; }

/* ------------------------------------------------------------------ lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(38, 35, 31, 0.28);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .18s;
}
.lightbox.open { opacity: 1; }
.lightbox[hidden] { display: none; }
.lb-card {
  width: min(1120px, 92vw);
  max-height: 92vh;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: var(--paper);
  border: 1px solid var(--hair);
  box-shadow: 0 24px 70px rgba(30, 22, 14, 0.22);
}
.lb-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 10px 20px; border-bottom: 1px solid var(--hair-2); }
.lb-head h2 { margin: 0; font: 400 15px var(--serif); letter-spacing: 0.03em; }
.lb-body { overflow: auto; padding: 18px 20px 16px; }
.photo { margin: 0; display: grid; place-items: center; background: var(--paper-2); }
.photo img { display: block; max-width: 100%; max-height: 72vh; }
.lb-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.views { display: flex; gap: 6px; }
.views .chip { text-transform: lowercase; }
.links { display: flex; gap: 16px; align-items: baseline; }
a { color: var(--ink); text-decoration-color: var(--hair); text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
.lb-wait { display: grid; place-items: center; gap: 16px; padding: 70px 0 60px; color: var(--ink-2); }
.lb-wait:has(.pt-preview:not([hidden])) { padding-top: 0; }
.lb-wait:has(.pt-preview:not([hidden])) .spinner { display: none; }
.pt-preview { display: block; max-width: 100%; max-height: 62vh; background: var(--paper-2); }
.pt-preview[hidden] { display: none; }
.lb-msg { padding: 8px 0 4px; max-width: 760px; }
.lb-msg p { margin: 0 0 8px; }
.lb-msg pre { max-height: 300px; overflow: auto; font: 11px/1.45 var(--mono); white-space: pre-wrap; background: var(--paper-2); padding: 10px 12px; border: 1px solid var(--hair-2); }
.lb-msg details summary { cursor: pointer; color: var(--ink-3); font-size: 11.5px; }
.files li { padding: 2px 0; font-family: var(--mono); font-size: 11.5px; }
code { font: 11.5px var(--mono); background: var(--paper-2); padding: 1px 4px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--hair);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 1180px) {
  :root { --left: 270px; --right: 236px; }
  .brand { min-width: 0; }
  .hint { display: none; }
  .topbar { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
}

/* checks arriving, export list */
.checking { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; letter-spacing: 0.06em; text-transform: none; color: var(--ink-3); }
.mini-spin {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid var(--hair); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.files { columns: 2; column-gap: 28px; margin-top: 10px !important; }
.files li { display: flex; align-items: baseline; gap: 10px; break-inside: avoid; }
.files .ext {
  width: 34px; flex-shrink: 0;
  font: 600 9.5px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
}

/* engine boot overlay (browser build) */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(243, 239, 230, 0.86);
  backdrop-filter: blur(3px); z-index: 50; transition: opacity .4s ease; }
.boot.done { opacity: 0; pointer-events: none; }
.boot-card { width: min(420px, 86vw); text-align: center; color: #26231f; font-size: 14px; }
.boot-card .mark { width: 34px; height: 34px; }
.boot-title { font-size: 20px; letter-spacing: .02em; margin: 8px 0 4px; }
.boot-text { margin: 0 0 12px; min-height: 1.4em; }
.boot-bar { height: 3px; background: rgba(38, 35, 31, .12); border-radius: 2px; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 0; background: #26231f; transition: width .3s ease; }
.boot-note { margin-top: 14px; font-size: 12px; opacity: .65; line-height: 1.45; }

/* ------------------------------------------------------------------ phones
   The view fills the screen; a tab bar at the bottom opens the parameters or
   the report as a sheet under the view (beside it on a phone held sideways)
   and starts a photo or an export. */
.tabbar { display: none; }
@media (max-width: 760px), (pointer: coarse) and (max-width: 1100px) and (orientation: portrait),
       (pointer: coarse) and (max-height: 520px) {
  :root { --top: 48px; --tabs: 52px; --sheet: 0px; }
  body {
    height: 100vh;
    height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--top) minmax(0, 1fr) var(--sheet) calc(var(--tabs) + env(safe-area-inset-bottom, 0px));
    grid-template-areas: "top" "stage" "sheet" "tabs";
  }
  body[data-sheet="design"], body[data-sheet="report"] { --sheet: min(50dvh, 460px); }

  /* top bar: mark, preset, the generative buttons, undo and redo */
  .topbar { gap: 8px; padding: 0 10px; }
  .brand { min-width: 0; flex-shrink: 0; }
  .brand .title, .sep, .seedbox, .actions, kbd, .topbar .flabel { display: none; }
  .tools { flex: 1; min-width: 0; gap: 6px; }
  .tools > .field { flex: 1 1 auto; min-width: 0; }
  #preset { min-width: 0; width: 100%; max-width: 160px; }
  .hist { margin-left: auto; }
  .btn { height: 34px; padding: 0 10px; }
  .icon { width: 34px; height: 34px; }
  button { -webkit-tap-highlight-color: transparent; }
  html, body { overscroll-behavior: none; touch-action: manipulation; }     /* no pull-to-refresh, no double-tap zoom */

  /* the sheet */
  .panel { grid-area: sheet; display: none; border: 0; border-top: 1px solid var(--hair); }
  body[data-sheet="design"] .params, body[data-sheet="report"] .report { display: block; }
  .params, .report { padding: 0 16px 28px; overscroll-behavior: contain; }

  .tabbar {
    grid-area: tabs;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--hair);
    background: rgba(243, 239, 230, 0.94);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tabbar button {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; padding: 0;
    color: var(--ink-2); font-size: 11px; letter-spacing: 0.04em;
    cursor: pointer;
  }
  .tabbar svg { width: 20px; height: 20px; }
  .tabbar button[aria-selected="true"] { color: var(--accent); }
  .tabbar button.working { color: var(--accent); }
  .tabbar button.working svg { animation: pulse 1.1s ease-in-out infinite; }
  .tabdot { position: absolute; top: 7px; left: calc(50% + 9px); width: 6px; height: 6px; border-radius: 50%; display: none; }
  .tabdot.warn { display: block; background: var(--ochre); }
  .tabdot.fail { display: block; background: var(--accent); }

  /* the view */
  .status { left: 12px; top: 12px; }
  .viewtools { right: 10px; top: 8px; }
  .chip { height: 32px; padding: 0 12px; font-size: 12px; }
  .dock { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 16px 14px 8px; }
  body[data-sheet="design"] .dock, body[data-sheet="report"] .dock { display: none; }
  .dock label, .steplabel { font-size: 9.5px; }
  .toast { bottom: 96px; max-width: 94%; }
  .tip { max-width: min(280px, 80vw); }

  /* touch sizes, and 16 px text in fields (smaller makes iOS zoom the page on focus) */
  .filter input, .val, select, .row.text input, #seed { font-size: 16px; }
  .filter kbd { display: none; }
  .row { padding: 8px 0 4px; }
  .group-head { padding: 14px 0 8px; }
  .lock { width: 36px; height: 34px; }
  .lock svg { width: 14px; height: 14px; }
  input[type="range"].slider { height: 30px; }
  .slider::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -10.5px; }
  .slider::-moz-range-thumb { width: 20px; height: 20px; }
  .slider:hover::-webkit-slider-thumb { transform: none; }
  .play { width: 32px; height: 32px; }

  /* lightboxes: a full-width card */
  .lb-card { width: 100vw; max-height: 92vh; max-height: 92dvh; }
  .lb-head { padding: 10px 12px 8px 16px; }
  .lb-body { padding: 14px 14px 16px; }
  .photo img { max-height: 62vh; max-height: 62dvh; }
  .files { columns: 1; }
  .x { font-size: 22px; padding: 4px 8px; }
}
/* a phone held sideways: the sheet beside the view, a slimmer tab bar */
@media (pointer: coarse) and (max-height: 520px) and (orientation: landscape) {
  :root { --top: 44px; --tabs: 42px; --side: 0px; }
  body {
    grid-template-columns: minmax(0, 1fr) var(--side);
    grid-template-rows: var(--top) minmax(0, 1fr) calc(var(--tabs) + env(safe-area-inset-bottom, 0px));
    grid-template-areas: "top top" "stage sheet" "tabs tabs";
  }
  body[data-sheet="design"], body[data-sheet="report"] { --side: min(46vw, 400px); }
  .panel { border-top: 0; border-left: 1px solid var(--hair); }
  .tabbar button { flex-direction: row; gap: 7px; }
  .tabbar svg { width: 18px; height: 18px; }
  .tabdot { top: 9px; left: auto; right: calc(50% - 40px); }
  .dock { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; padding: 10px 14px 6px; }
  body[data-sheet="design"] .dock, body[data-sheet="report"] .dock { display: grid; }
  .toast { bottom: 70px; }
}
