/* App layout: 100dvh cockpit on desktop, single column + bottom sheet on mobile. */
html, body { height: 100%; overflow: hidden; }
svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; width: 18px; height: 18px; flex: none; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 500; }
button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.35), 0 6px 18px oklch(0.78 0.14 230 / 0.22); }
button.primary:hover { background: oklch(0.83 0.13 230); }
button.icon { width: 40px; padding: 0; }
button.ghost { background: transparent; box-shadow: none; color: var(--muted); }
button.ghost:hover { background: var(--n3); color: var(--text); }
button.small, .small { font-size: 12px; }
button.small { min-height: 32px; padding: 4px 10px; }

.shell {
  height: 100dvh; overflow: hidden; display: grid; gap: 10px; padding: 10px;
  grid-template-columns: 272px minmax(0, 1fr) 320px; grid-template-rows: 52px minmax(0, 1fr);
  grid-template-areas: "bar bar bar" "tray stage inspector";
}
.bar { grid-area: bar; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 0 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { color: var(--accent); stroke-width: 1.6; }
.brand h1 { font-size: 15px; letter-spacing: -0.01em; }
.sample-pill { font-size: 11px; padding: 3px 9px; border-radius: 99px; background: oklch(0.80 0.13 80 / 0.14); color: var(--warn); white-space: nowrap; }
.bar-actions { display: flex; gap: 6px; align-items: center; }

.tray { grid-area: tray; display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 10px; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.pane-head h2 { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 11px; color: var(--muted); background: var(--n3); padding: 1px 7px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.photo-list { list-style: none; margin: 0; padding: 2px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; flex: 1; scrollbar-width: thin; }
.photo { display: grid; grid-template-columns: 22px 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border-radius: var(--radius-sm); cursor: grab; transition: background-color .18s ease, transform .3s var(--spring); }
.photo:hover { background: var(--n3); }
.photo[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px oklch(0.78 0.14 230 / 0.35); }
.photo.dragging { opacity: .4; }
.photo.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.photo .num { font: 500 11px var(--mono); font-variant-numeric: tabular-nums; color: var(--faint); text-align: right; }
.photo canvas { width: 44px; height: 44px; border-radius: 7px; background: var(--well); object-fit: cover; }
.photo .meta { min-width: 0; display: flex; flex-direction: column; }
.photo .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo .dims { font: 400 11px var(--mono); font-variant-numeric: tabular-nums; color: var(--faint); }
.photo button { width: 32px; min-height: 32px; padding: 0; background: transparent; box-shadow: none; color: var(--faint); opacity: 0; }
.photo:hover button, .photo[aria-selected="true"] button, .photo button:focus-visible { opacity: 1; }
.photo button:hover { color: var(--bad); background: var(--n4); }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 16px 12px; border-radius: var(--radius); background: var(--well); box-shadow: var(--inset); color: var(--muted); font-size: 13px; cursor: pointer; transition: background-color .2s ease; }
.dropzone:hover, .dropzone:focus-within { background: oklch(0.12 0.01 230); color: var(--text); }
.dropzone svg { width: 22px; height: 22px; color: var(--accent); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.empty { padding: 18px 8px; text-align: center; color: var(--muted); font-size: 13px; }

.stage { grid-area: stage; display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 8px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 0 4px; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); min-width: 0; font-variant-numeric: tabular-nums; }
.stats b { color: var(--text); font-weight: 500; }
.stats .warn { color: var(--warn); }
.stats .good { color: var(--signal); }
.seg-group { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--well); box-shadow: var(--inset); flex: none; }
.seg { min-height: 34px; padding: 4px 12px; background: transparent; box-shadow: none; color: var(--muted); font-size: 12px; border-radius: 8px; }
.seg:hover { background: var(--n3); }
.seg[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: var(--specular); }
.viewport { position: relative; flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 18px; scrollbar-width: thin; }
.viewport.zoom-width { place-items: start center; }
#preview { display: block; border-radius: 6px; box-shadow: var(--shadow); cursor: grab; touch-action: none; transition: opacity .2s ease; }
#preview.dragging { cursor: grabbing; }
.drop-veil, .busy { position: absolute; inset: 0; display: grid; place-items: center; border-radius: var(--radius); }
.drop-veil { background: oklch(0.78 0.14 230 / 0.12); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); font-weight: 500; pointer-events: none; }
.drop-veil div { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop-veil svg { width: 32px; height: 32px; }
.busy { background: oklch(0.1 0.004 250 / 0.7); gap: 10px; grid-auto-flow: column; place-content: center; color: var(--muted); font-size: 13px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--n5); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { margin: 0; font-size: 12px; padding: 0 4px; }

.inspector { grid-area: inspector; display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 12px; }
.grab { display: none; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; gap: 2px; border-radius: 11px; background: var(--well); box-shadow: var(--inset); }
.tab { min-height: 34px; background: transparent; box-shadow: none; color: var(--muted); border-radius: 8px; font-size: 12px; }
.tab:hover { background: var(--n3); }
.tab[aria-selected="true"] { background: var(--raised); color: var(--text); box-shadow: var(--specular); }
.tab-body { overflow-y: auto; min-height: 0; flex: 1; padding: 2px 2px 8px; scrollbar-width: thin; }
.tab-body-inner { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > .lbl { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.field > .lbl output { color: var(--text); font-size: 11px; }
.field .seg-group { display: flex; flex-wrap: wrap; }
.field .seg-group .seg { flex: 1 1 0; min-width: 34px; padding: 4px 6px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.field .seg-group.words .seg { font-family: var(--font); }
.field .note { font-size: 11px; color: var(--faint); margin: 0; }
.text-in { min-height: 40px; padding: 8px 12px; border: 0; border-radius: var(--radius-sm); background: var(--well); box-shadow: var(--inset); outline: none; width: 100%; font-size: 13px; }
.text-in:focus-visible { box-shadow: var(--inset), 0 0 0 2px var(--accent); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; font-size: 13px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--n5); position: relative; cursor: pointer; transition: background-color .2s ease; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .3s var(--spring); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); background: var(--accent-ink); }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 28px; }
.card { padding: 12px; border-radius: var(--radius-sm); background: var(--n3); display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.card .row { display: flex; justify-content: space-between; gap: 10px; }
.card .row span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); }
.card .row span:first-child { color: var(--muted); }
.reco { font-size: 12px; color: var(--muted); line-height: 1.5; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.reco strong { color: var(--text); }
.label-row { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 8px; }
.label-row .num { font: 500 11px var(--mono); font-variant-numeric: tabular-nums; color: var(--faint); text-align: right; }

.mobile-dock { display: none; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 12px; background: var(--n5); box-shadow: var(--specular), var(--shadow); font-size: 13px; z-index: 50; animation: rise .32s var(--spring); }
.toast.error { background: oklch(0.32 0.07 25); }
.toast.ok { background: oklch(0.30 0.05 155); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
.palette { width: min(92vw, 520px); padding: 8px; border: 0; border-radius: 16px; background: var(--n3); color: var(--text); box-shadow: var(--specular), var(--shadow); }
.palette::backdrop { background: oklch(0 0 0 / 0.5); }
/* palette field */
.palette input{width:100%;min-height:40px;padding:8px 12px;border:0;border-radius:10px;background:var(--well);box-shadow:var(--inset);font-size:13px;outline:none}
.palette input:focus-visible{box-shadow:var(--inset),0 0 0 2px var(--accent)}
.palette ul { list-style: none; margin: 6px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.palette li { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 10px; font-size: 13px; cursor: pointer; }
.palette li[aria-selected="true"], .palette li:hover { background: var(--accent-soft); }
.palette kbd { font: 400 11px var(--mono); color: var(--muted); }

@media (max-width: 1180px) { .shell { grid-template-columns: 240px minmax(0, 1fr) 290px; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 48px minmax(0, 1fr) auto 64px; grid-template-areas: "bar" "stage" "tray" "dock"; gap: 8px; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
  .hide-sm, .hint, .seg-group[aria-label="Preview zoom"] { display: none !important; }
  .sample-pill { font-size: 10px; padding: 2px 7px; }
  .tray { padding: 8px; gap: 6px; }
  .tray .pane-head { display: none; }
  .photo-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; flex: none; gap: 6px; }
  .photo { grid-template-columns: 1fr; padding: 3px; position: relative; flex: none; }
  .photo .meta, .photo button { display: none; }
  .photo canvas { width: 52px; height: 52px; }
  .photo .num { position: absolute; left: 6px; top: 5px; color: #fff; text-shadow: 0 1px 2px #000; text-align: left; }
  /* Keep the input in the render tree for programmatic .click() from the dock, but out of sight. */
  .dropzone { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; opacity: 0; pointer-events: none; }
  .viewport { padding: 10px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .mobile-dock { grid-area: dock; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .mobile-dock button { min-height: 56px; flex-direction: column; gap: 3px; font-size: 11px; background: var(--surface); }
  .inspector { position: fixed; left: 0; right: 0; bottom: 0; max-height: 72dvh; z-index: 40; border-radius: 20px 20px 0 0; padding: 4px 14px max(14px, env(safe-area-inset-bottom)); box-shadow: var(--specular), 0 -18px 44px oklch(0 0 0 / 0.5); transform: translateY(calc(100% + 24px)); visibility: hidden; transition: transform .42s var(--spring), visibility .42s; }
  .inspector.open { transform: none; visibility: visible; transition: transform .42s var(--spring), visibility 0s; }
  .grab { display: flex; min-height: 28px; background: transparent; box-shadow: none; }
  .grab span { width: 40px; height: 5px; border-radius: 99px; background: var(--n5); }
  .stats { font-size: 11px; gap: 2px 10px; }
}
