:root {
  color-scheme: dark;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav: #172833;
  --page: #243744;
  --panel: #314652;
  --header: #3c505c;
  --border: #526774;
  --text: #f1f6f9;
  --muted: #c0cdd5;
  --lime: #a4dd63;
  --blue: #007b9f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; background: var(--page); color: var(--text); }
.topbar { background: var(--nav); border-bottom: 1px solid #455b68; }
.topbar-content { max-width: 1520px; margin: auto; padding: 12px clamp(14px, 3vw, 40px); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-size: 1.15rem; font-weight: 750; }
.brand svg { flex: none; margin-right: 4px; }
.brand span { color: var(--lime); font-size: .82rem; letter-spacing: .12em; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: #9dafbb; }
.status[data-connected] i { background: var(--lime); }
main { max-width: 1520px; margin: 0 auto; padding: 24px clamp(14px, 3vw, 40px) 36px; }
.intro { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 22px; }
.eyebrow { color: var(--lime); font-size: .69rem; letter-spacing: .14em; font-weight: 750; }
h1 { font-size: clamp(1.8rem, 4vw, 2.55rem); line-height: 1.13; margin: 5px 0 8px; letter-spacing: -.035em; }
p { margin: 0; color: var(--muted); }
button, input, select { font: inherit; }
button { cursor: pointer; border-radius: 4px; font-weight: 700; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid #64cbed; outline-offset: 2px; }
.secondary { border: 1px solid #718794; color: var(--text); background: #304653; padding: 8px 14px; }
.secondary:hover { background: #405b6a; }
.workspace { display: grid; grid-template-columns: minmax(290px, 352px) minmax(0, 1fr); gap: 18px; align-items: start; }
.setup { display: grid; gap: 12px; }
.panel { border: 1px solid var(--border); border-radius: 6px; background: var(--panel); overflow: hidden; }
.panel-head { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; background: var(--header); border-bottom: 1px solid var(--border); }
h2 { font-size: .98rem; font-weight: 750; margin: 0; }
.tag { color: var(--lime); background: #253b39; border: 1px solid #587557; border-radius: 3px; padding: 2px 7px; font-size: .65rem; font-weight: 750; letter-spacing: .06em; }
.form-body { padding: 12px 14px; }
label, legend { font-size: .8rem; font-weight: 550; }
.fields { display: grid; gap: 9px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
label .measure { color: var(--muted); margin-left: 2px; font-size: .72rem; }
input:not([type=radio]), select { display: block; width: 100%; min-width: 0; height: 33px; margin-top: 3px; padding: 4px 7px; background: #fbfdff; color: #172833; border: 1px solid #a9bac5; border-radius: 3px; }
.import-panel { margin-bottom: 16px; }
.import-panel summary { display: list-item; cursor: pointer; }
.import-panel summary .tag { float: right; }
.import-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 9px; align-items: end; }
.import-fields + .import-fields, #import-message { margin-top: 10px; }
#quote-selection { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto auto; }
#import-message { font-size: .8rem; }
button:disabled { cursor: wait; opacity: .65; }
.orientation { display: block; margin-top: 9px; }
fieldset { margin: 0; padding: 0; min-width: 0; border: 0; }
legend { padding: 0; margin-bottom: 4px; }
.medium-switch { display: flex; gap: 4px; margin-bottom: 10px; }
.medium-switch label { flex: 1; position: relative; cursor: pointer; }
.medium-switch input { position: absolute; opacity: 0; }
.medium-switch span { display: block; text-align: center; border: 1px solid #708591; border-radius: 3px; padding: 5px; color: var(--muted); }
.medium-switch input:checked + span { background: var(--blue); border-color: #54b9d6; color: white; }
.medium-switch input:focus-visible + span { outline: 2px solid #64cbed; outline-offset: 2px; }
.edge-fields { display: grid; gap: 10px; }
.edge-fields label { color: var(--muted); font-size: .73rem; }
.edge-fields legend { font-weight: 700; }
.primary { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 9px 14px; color: #18280f; background: #9ad34f; border: 1px solid #b1eb6b; }
.primary:hover { background: #b0e671; }
.notice { padding: 10px 14px; color: #ffe7bd; background: #44372b; border: 1px solid #9a7047; border-radius: 4px; margin-bottom: 12px; }
.results > .notice { margin: 14px; }
.metrics { display: grid; grid-template-columns: 1.2fr .85fr 1fr; background: var(--nav); border-bottom: 1px solid var(--border); }
.metrics div { display: grid; gap: 3px; min-width: 0; padding: 13px clamp(8px, 1.8vw, 20px); }
.metrics div + div { border-left: 1px solid var(--border); }
.metrics span { color: var(--muted); font-size: .74rem; }
.metrics strong { font-size: clamp(1rem, 2.1vw, 1.65rem); line-height: 1.2; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metrics div:first-child strong { color: var(--lime); }
.legend { display: flex; gap: 8px 16px; flex-wrap: wrap; padding: 12px 14px 0; color: var(--muted); font-size: .75rem; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid #8da0ac; }
.legend .piece { background: #47733c; border-color: #a4dd63; }
.legend .bleed { background: #7fa65b; }
.legend .margin { background: #344752; border-style: dashed; }
.previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: 12px; padding: 12px 14px; }
.preview { margin: 0; min-width: 0; background: var(--nav); border: 1px solid #586d79; border-radius: 4px; }
.preview figcaption { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 10px; padding: 8px 11px; background: #283d49; font-size: .82rem; font-weight: 700; }
.preview small { color: var(--muted); font-size: .71rem; font-weight: 500; }
.canvas { display: grid; place-items: start center; padding: 12px; min-height: 140px; }
.canvas svg { display: block; width: 100%; height: auto; max-height: 405px; }
.layout-note { font-size: .76rem; padding: 0 14px 13px; }
@media (max-width: 740px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .intro { align-items: start; }
  .import-fields, #quote-selection { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .intro { flex-direction: column; }
}
