/* Breaker Label Maker
 * A drafting bench: steel rails around a millimetre graph-paper worktop.
 * The label typeface (Roboto Condensed) is also used for headings, so the
 * interface and the printed labels speak the same language.
 */

@font-face { font-family: 'BLM Condensed'; font-weight: 400; font-display: swap;
  src: url('../fonts/RobotoCondensed-Regular.ttf') format('truetype'); }
@font-face { font-family: 'BLM Condensed'; font-weight: 700; font-display: swap;
  src: url('../fonts/RobotoCondensed-Bold.ttf') format('truetype'); }
@font-face { font-family: 'BLM Sans'; font-weight: 400; font-display: swap;
  src: url('../fonts/Roboto-Regular.ttf') format('truetype'); }
@font-face { font-family: 'BLM Sans'; font-weight: 700; font-display: swap;
  src: url('../fonts/Roboto-Bold.ttf') format('truetype'); }

:root {
  --steel: #232a30;
  --steel-2: #46515a;
  --steel-3: #6b7780;
  --rail: #eef0f2;
  --bench: #e6eaed;
  --bar: #d3d9de;
  --rule: #b4bcc3;
  --paper: #ffffff;
  --conductor: #1b62c4;
  --conductor-soft: #dbe7f8;
  --warn: #b3301b;
  --warn-soft: #fbe6e1;
  --caution-soft: #fff1c9;
  --caution-line: #dcb640;
  --romex: #f2c12e;
  --romex-deep: #dba911;
  --go: #1f8a4c;
  --go-deep: #16703c;
  --ui: 'BLM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --narrow: 'BLM Condensed', 'Roboto Condensed', 'Arial Narrow', var(--ui);
  --topbar: 52px;
  --mm: 3.78;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 var(--ui); color: var(--steel); background: var(--bench); }
h1, h2, h3 { font-family: var(--narrow); font-weight: 700; margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--conductor); outline-offset: 1px; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

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

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; min-height: var(--topbar);
  padding: 6px 14px; background: var(--steel); color: #e9edf0; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none;
  font: 700 19px var(--narrow); }
.brand-mark { width: 24px; height: 24px; }
.name-field input { min-width: 200px; max-width: 34vw; height: 32px; padding: 0 9px; border-radius: 3px;
  border: 1px solid transparent; background: transparent; color: #fff; font-weight: 700; }
.name-field input::placeholder { color: #94a0a9; font-weight: 400; }
.name-field input:hover { border-color: #56626b; }
.name-field input:focus { border-color: var(--romex); background: #2c353c; outline: none; }
.save-state { font-size: 12.5px; color: #a9b4bc; min-width: 9em; }
.actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- buttons ---------- */
.btn { height: 32px; padding: 0 13px; border-radius: 3px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--steel-3); background: var(--paper); color: var(--steel); font-weight: 600; }
.btn:hover { background: #f4f6f7; }
.btn:active { background: #e6eaed; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--steel-2); }
.btn-quiet:hover { background: #dfe4e8; }
.btn-danger { border-color: var(--warn); color: var(--warn); }
.btn-danger:hover { background: var(--warn-soft); }
.btn-success { background: var(--go); border-color: var(--go); color: #fff; }
.btn-success:hover { background: var(--go-deep); }
.topbar .back-link { color: #a9b4bc; }
.topbar .btn { background: transparent; color: #e9edf0; border-color: #56626b; }
.topbar .btn:hover { background: #2f3941; }
.topbar .btn-primary, .btn-primary { background: var(--romex); border-color: var(--romex); color: #1b1e21; }
.topbar .btn-primary:hover, .btn-primary:hover { background: #f6cd52; }

/* ---------- workspace ---------- */
.workspace { flex: 1; min-height: 0; height: calc(100vh - var(--topbar));
  display: grid; grid-template-columns: 312px minmax(0, 1fr) 410px; }
.rail { background: var(--rail); overflow-y: auto; min-height: 0; }
.rail-setup { border-right: 1px solid var(--rule); }
.rail-labels { border-left: 1px solid var(--rule); display: flex; flex-direction: column; overflow: hidden; }

.panel { padding: 14px 16px; border-bottom: 1px solid var(--rule); }
.panel h2, .panel > summary { font: 700 15px var(--narrow); margin-bottom: 9px; }
.panel > summary { cursor: pointer; margin-bottom: 0; padding: 2px 0; list-style-position: inside; }
.panel[open] > summary { margin-bottom: 11px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span:first-child { font-size: 12.5px; font-weight: 600; color: var(--steel-2); }
.field input, .field select, .row-inline select, .cell-size input, .cell-field-picker select {
  width: 100%; height: 30px; padding: 0 8px; border: 1px solid var(--rule); border-radius: 3px; background: #fff; }
.field input:focus, .field select:focus { border-color: var(--conductor); }
.input-unit { display: flex; align-items: center; gap: 6px; }
.unit { font-size: 12px; color: var(--steel-3); }
.hint { font-size: 11.5px; color: var(--steel-3); min-height: 1em; }
.hint-text { margin: 8px 0 0; font-size: 12.5px; color: var(--steel-2); max-width: 56ch; }
.hint-text.pad { margin: 0; padding: 0 16px 10px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--conductor); }
.row-inline { display: flex; gap: 6px; align-items: center; }
.row-inline select { flex: 1; min-width: 0; }
.panel .row-inline + .hint-text { margin-top: 8px; }

.only-vertical, .only-two-cols, .only-custom { display: flex; }
.app[data-orient="horizontal"] .only-vertical,
.app[data-cols="1"] .only-two-cols,
.app:not([data-paper="custom"]) .only-custom { display: none; }

.tabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.tab { height: 28px; max-width: 100%; padding: 0 10px; border-radius: 3px; cursor: pointer; overflow: hidden;
  text-overflow: ellipsis; border: 1px solid var(--rule); background: #fff; font-size: 13px; font-weight: 600; }
.tab.is-active { background: var(--steel); border-color: var(--steel); color: #fff; }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: var(--bar);
  border-bottom: 1px solid var(--rule); }
.seg { display: inline-flex; border: 1px solid var(--steel-3); border-radius: 3px; overflow: hidden; }
.seg-btn { height: 28px; padding: 0 14px; border: 0; background: #fff; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--steel-3); }
.seg-btn.is-active { background: var(--steel); color: #fff; }
.page-info { font-size: 13px; color: var(--steel-2); }
.zoom { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.zoom input[type=range] { width: 130px; accent-color: var(--steel); }
.zoom output { width: 3.4em; text-align: right; font: 600 13px var(--narrow); }

.warnings { margin: 0; padding: 9px 16px 9px 32px; list-style: disc; font-size: 13px;
  background: var(--caution-soft); border-bottom: 1px solid var(--caution-line); color: #4d3a00; }
.warnings li + li { margin-top: 3px; }

/* the worktop: 10 mm lines, heavier every 50 mm, scaled with the zoom via --mm */
.canvas { flex: 1; min-height: 0; overflow: auto; padding: 26px; background-color: #e9edf0;
  background-attachment: local;
  background-image:
    linear-gradient(to right, rgba(27, 98, 196, .20) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(27, 98, 196, .20) 1px, transparent 1px),
    linear-gradient(to right, rgba(27, 98, 196, .09) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(27, 98, 196, .09) 1px, transparent 1px);
  background-size:
    calc(var(--mm) * 50px) calc(var(--mm) * 50px),
    calc(var(--mm) * 50px) calc(var(--mm) * 50px),
    calc(var(--mm) * 10px) calc(var(--mm) * 10px),
    calc(var(--mm) * 10px) calc(var(--mm) * 10px); }
.sheet { display: inline-block; min-width: 100%; }
.sheet .loading { margin: 40px 0; text-align: center; color: var(--steel-2); }
.strip-svg, .page-svg { display: block; overflow: visible; }
.page-svg { margin: 0 auto; border: 1px solid var(--steel-3); background: #fff; }
.page-caption { margin: 6px 0 22px; text-align: center; font: 600 13px var(--narrow); color: var(--steel-2); }
.margin-guide { fill: none; stroke: #8fa6c4; stroke-width: .25; stroke-dasharray: 1.4 1; }

.cell-hit { fill: transparent; cursor: pointer; }
.cell-hit:hover { fill: rgba(27, 98, 196, .09); }
.cell-hit.is-selected { fill: rgba(27, 98, 196, .13); stroke: var(--conductor); stroke-width: .5; }
.cell-hit.has-overflow { stroke: var(--warn); stroke-width: .45; stroke-dasharray: 1.3 .8; }
.dim line { stroke: var(--steel-2); stroke-width: .18; }
.dim text { font: 3.1px 'BLM Sans', Arial, sans-serif; fill: var(--steel-2); }

/* ---------- labels rail ---------- */
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 6px; }
.rail-head h2 { font-size: 15px; }
.slot-table { flex: 1; min-height: 0; overflow-y: auto; }
.slot-row { border-left: 3px solid transparent; border-bottom: 1px solid #dfe3e6; padding: 6px 14px 8px 10px; cursor: pointer; }
.slot-row.is-selected { background: var(--conductor-soft); border-left-color: var(--conductor); cursor: default; }
.slot-row.is-covered { color: var(--steel-3); background: #e8ebed; cursor: default; }
.slot-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.slot-no { font: 700 13px var(--narrow); color: var(--steel-2); flex-shrink: 0; }
.slot-summary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--steel-3); }
.slot-row.is-selected .slot-summary { display: none; }
.slot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; }
.slot-row:not(.is-selected) .slot-grid { display: none; }
.slot-field { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.slot-field-wide { grid-column: 1 / -1; }
.slot-field-span { width: 62px; }
.slot-field-cap { font: 600 10px var(--narrow); text-transform: uppercase; letter-spacing: .02em; color: var(--steel-3); }
.slot-row input { width: 100%; height: 27px; padding: 0 7px; border: 1px solid transparent; border-radius: 3px;
  background: #fff; font-size: 13px; }
.slot-row input:hover { border-color: var(--rule); }
.slot-row input:focus { border-color: var(--conductor); outline: none; }
.slot-row input:disabled { background: transparent; }
.slot-row .slot-span { padding: 0 2px 0 6px; }

.cell-options h3 { font-size: 14px; margin-bottom: 8px; }
.cell-options .dialog-actions { justify-content: flex-end; }
.cell-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.cell-label { font-size: 12.5px; font-weight: 600; color: var(--steel-2); }
.swatches { display: flex; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 3px; border: 1px solid var(--steel-3); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { outline: 2px solid var(--conductor); outline-offset: 1px; }
.swatch-none { background: linear-gradient(135deg, #fff 45%, var(--warn) 45%, var(--warn) 55%, #fff 55%); }
.cell-size { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--steel-2); }
.cell-size input { width: 66px; }
.cell-color { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--steel-2); }
.cell-color input { width: 32px; height: 26px; padding: 1px; border: 1px solid var(--steel-3); border-radius: 3px; background: none; cursor: pointer; }
.cell-field-picker { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--steel-2); flex: 1 1 100%; }
.cell-field-picker select { flex: 1; }

/* ---------- dialog and toast ---------- */
.dialog { width: min(520px, 92vw); padding: 20px 22px; border: 1px solid var(--steel-3); border-radius: 4px;
  background: var(--rail); color: var(--steel); }
.dialog::backdrop { background: rgba(35, 42, 48, .6); }
.dialog h2 { font-size: 19px; margin-bottom: 14px; }
.dialog .field + .field { margin-top: 14px; }
.copy-row { display: flex; gap: 6px; }
.dialog-actions { display: flex; justify-content: space-between; margin-top: 20px; }

.import-dialog { width: min(620px, 92vw); }
.import-map { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; max-height: 50vh; overflow-y: auto; }
.import-map-row { display: flex; align-items: center; gap: 10px; }
.import-map-row label { display: flex; flex-direction: column; gap: 3px; flex: 0 0 200px; font-size: 12.5px; font-weight: 600; color: var(--steel-2); }
.import-map-row label.is-required span::after { content: ' *'; color: var(--warn); }
.import-map-row select { padding: 6px 8px; border: 1px solid var(--steel-3); border-radius: 3px; background: #fff; font-size: 13px; }
.import-sample { flex: 1; min-width: 0; font-size: 12px; color: var(--steel-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-target { border: 1px solid var(--steel-3); border-radius: 3px; padding: 10px 12px; margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.import-target legend { font-size: 12.5px; font-weight: 600; color: var(--steel-2); padding: 0 4px; }

.template-dialog { width: min(560px, 92vw); }
.template-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; max-height: 40vh; overflow-y: auto; }
.template-list:empty::before { content: 'No saved templates yet.'; font-size: 12.5px; color: var(--steel-2); }
.template-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--steel-3); border-radius: 3px; flex-wrap: wrap; }
.template-row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.template-row-name { font-size: 13px; font-weight: 600; color: var(--steel); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-row-date { font-size: 11.5px; color: var(--steel-2); }
.template-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.template-save { margin-top: 16px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 20; max-width: min(560px, 92vw);
  padding: 10px 16px; border-radius: 3px; background: var(--steel); color: #fff; font-size: 13.5px; }
.toast.is-error { background: var(--warn); }

/* ---------- account pages (auth, dashboard, projects) ---------- */
.account-email { color: #c7cfd4; font-size: 13px; }
.content { max-width: 760px; margin: 0 auto; padding: 28px 16px; width: 100%; box-sizing: border-box; }
.center-page { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - var(--topbar)); }
.card { width: min(420px, 100%); background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 24px 26px; box-sizing: border-box; }
.card h1 { font-size: 20px; margin-bottom: 18px; }
.card .field + .field, .card .field + .btn, .card .field + .card-foot { margin-top: 14px; }
.card .btn { width: 100%; margin-top: 18px; }
.card-foot { margin-top: 16px; font-size: 13px; color: var(--steel-2); }
.card-foot a { color: var(--conductor); }
.error-text { color: var(--warn); font-size: 12.5px; margin-top: 4px; }
.status-text { color: var(--go-deep); font-size: 13px; margin-bottom: 14px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; }
.back-link { color: var(--steel-2); text-decoration: none; font-size: 13px; }
.back-link:hover { text-decoration: underline; }
.new-row { display: flex; gap: 8px; margin-bottom: 18px; }
.new-row input { flex: 1; height: 32px; padding: 0 9px; border-radius: 3px; border: 1px solid var(--rule); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); }
.list-row + .list-row { margin-top: 10px; }
.list-row a.list-title { color: var(--conductor); text-decoration: none; font-weight: 600; }
.list-row a.list-title:hover { text-decoration: underline; }
.list-meta { font-size: 12.5px; color: var(--steel-2); }
.list-actions { display: flex; gap: 6px; }
.empty-state { color: var(--steel-2); padding: 26px 0; text-align: center; }

/* ---------- narrower screens ---------- */
@media (max-width: 1120px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .stage { order: -1; min-height: 70vh; }
  .canvas { min-height: 60vh; }
  .rail-setup, .rail-labels { border: 0; border-top: 1px solid var(--rule); overflow: visible; }
  .slot-table { max-height: 60vh; }
  .name-field input { max-width: 100%; }
  .actions { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print { .topbar, .rail, .stage-bar { display: none; } }
