:root {
    --bg:        #111214;
    --surface:   #1a1c20;
    --surface2:  #22252b;
    --border:    #2e3138;
    --border2:   #3d424e;
    --amber:     #f5a623;
    --amber-dim: #9b6a16;
    --amber-glow:#f5a62340;
    --green:     #3ddc84;
    --red:       #ff4757;
    --text:      #d8dce8;
    --text-dim:  #6b7280;
    --text-mono: #a8b2c8;
    --radius:    6px;
    --track-h:   4px;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Barlow', sans-serif;
    font-weight: 400;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* ── HEADER ─────────────────────────────────────────── */
  header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .logo-mark {
    width: 300px; height: 30px;
    color: var(--amber);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .logo-mark svg { 
	width: 250px;
	fill: var(--amber);
  }
  .logo-text {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 1.35rem;
    letter-spacing: 0.35em;
    color: #fff;
    text-transform: uppercase;
  }
  .logo-text span { color: var(--amber); }
  .header-tag {
    margin-left: auto;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 3px;
  }

  /* ── MAIN LAYOUT ─────────────────────────────────────── */

  html, body { height: 100%; overflow: hidden; }

  body {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  /* header stays fixed at top naturally as first flex child */

  main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    gap: 0;
  }

  /* Canvas pane — does NOT scroll, shrinks to its content */
  .stage-wrapper {
    flex-shrink: 0;
  }

  /* Controls pane — scrolls independently */
  .controls-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 24px 40px;
    min-height: 0;
  }

  /* ── CANVAS STAGE ────────────────────────────────────── */
  .stage-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-right: none;
    padding: 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .stage-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
  .stage-dims {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.72rem;
    color: var(--amber);
    background: var(--amber-glow);
    border: 1px solid var(--amber-dim);
    padding: 2px 10px;
    border-radius: 3px;
    letter-spacing: 0.06em;
  }

  /* scrollable container for the canvas */
  .canvas-scroll {
    width: 100%;
    overflow: auto;
    background:
      linear-gradient(var(--border) 1px, transparent 1px),
      linear-gradient(90deg, var(--border) 1px, transparent 1px);
    /* background-size and background-position set dynamically by JS */
    background-color: #0d0f11;
    border: 1px solid var(--border2);
    border-radius: 4px;
    /* height is set dynamically by JS */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
  }

  /* simple centering wrapper — no transform needed */
  .canvas-scale-wrapper {
    flex-shrink: 0;
    line-height: 0;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #labelCanvas {
    display: block;
    background: #fff;
    box-shadow:
      0 0 0 1px var(--amber-dim),
      0 0 30px rgba(245,166,35,0.15),
      0 8px 32px rgba(0,0,0,0.6);
  }

  /* ── CONTROL PANEL ───────────────────────────────────── */
  .control-panel {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
  @media (max-width: 900px) {
    .control-panel { grid-template-columns: 1fr 1fr; }
  }
  @media (max-width: 580px) {
    .control-panel { grid-template-columns: 1fr; }
  }

  .ctrl-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .ctrl-card-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 7px;
  }
  .ctrl-card-title::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--amber);
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  }

  /* dimension control row */
  .dim-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .dim-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .dim-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
  }
  .dim-input {
    width: 70px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--amber);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    text-align: right;
    padding: 3px 7px;
    outline: none;
    transition: border-color .15s;
  }
  .dim-input:focus { border-color: var(--amber); }
  .dim-input-suffix {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-left: 3px;
  }
  .dim-input-wrap { display: flex; align-items: center; gap: 0; }

  /* custom slider */
  input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    height: var(--track-h);
    border-radius: 2px;
    background: var(--border2);
    outline: none;
    cursor: pointer;
    transition: background .2s;
  }
  input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    background: var(--amber);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(245,166,35,0.5);
    transition: transform .15s, box-shadow .15s;
  }
  input[type=range]:hover::-webkit-slider-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 14px rgba(245,166,35,0.7);
  }
  input[type=range]::-moz-range-thumb {
    width: 16px; height: 16px;
    background: var(--amber);
    border: none;
    border-radius: 50%;
    cursor: pointer;
  }
  input[type=range]::-webkit-slider-runnable-track {
    height: var(--track-h);
    border-radius: 2px;
  }

  /* ── IMAGE UPLOAD ────────────────────────────────────── */
  .img-upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .img-slot {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .img-slot-label {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 500;
    letter-spacing: 0.04em;
  }
  .img-drop-zone {
    border: 1.5px dashed var(--border2);
    border-radius: 5px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    position: relative;
    overflow: hidden;
    background: var(--surface2);
  }
  .img-drop-zone:hover, .img-drop-zone.drag-over {
    border-color: var(--amber);
    background: var(--amber-glow);
  }
  .img-drop-zone input[type=file] {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer; width: 100%; height: 100%;
  }
  .img-drop-icon {
    width: 28px; height: 28px;
    color: var(--text-dim);
    pointer-events: none;
  }
  .img-drop-text {
    font-size: 0.68rem;
    color: var(--text-dim);
    text-align: center;
    pointer-events: none;
    line-height: 1.4;
  }
  .img-preview-wrap {
    position: relative;
    width: 100%; height: 100%;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .img-preview {
    max-width: 100%; max-height: 80px;
    object-fit: contain;
    pointer-events: none;
  }
  .img-clear-btn {
    position: absolute; top: 4px; right: 4px;
    background: rgba(0,0,0,0.7);
    border: 1px solid var(--border2);
    color: var(--red);
    border-radius: 3px;
    width: 20px; height: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    transition: background .15s;
    z-index: 2;
  }
  .img-clear-btn:hover { background: rgba(255,71,87,0.25); }
  .img-filename {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.6rem;
    color: var(--green);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    pointer-events: none;
  }

  /* ── STATUS BAR ─────────────────────────────────────── */
  .status-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
  }
  .status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.68rem;
    color: var(--text-dim);
  }
  .status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    flex-shrink: 0;
  }
  .status-val { color: var(--text-mono); }

  /* ── TEXT FIELDS PANEL ───────────────────────────── */
  .text-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .text-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .text-panel-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
  .text-fields-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  @media (max-width: 820px) {
    .text-fields-grid { grid-template-columns: 1fr; }
  }
  .text-field-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color .2s;
  }
  .text-field-card:focus-within {
    border-color: var(--amber-dim);
  }
  .text-field-card-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .text-field-card-title::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    background: var(--amber);
    border-radius: 50%;
    flex-shrink: 0;
  }
  .text-input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text);
    font-family: 'Barlow', sans-serif;
    font-size: 0.85rem;
    padding: 7px 10px;
    outline: none;
    transition: border-color .15s;
  }
  .text-input:focus { border-color: var(--amber); }
  .text-input::placeholder { color: var(--text-dim); font-size: .8rem; }

  /* sub-row inside a text card */
  .txt-ctrl-row {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .txt-ctrl-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 56px;
  }
  /* font size number input */
  .txt-size-input {
    width: 52px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--amber);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    text-align: right;
    padding: 3px 6px;
    outline: none;
    flex-shrink: 0;
    transition: border-color .15s;
  }
  .txt-size-input:focus { border-color: var(--amber); }
  .txt-size-suffix {
    font-size: 0.68rem;
    color: var(--text-dim);
  }
  /* justify buttons */
  .just-group {
    display: flex;
    gap: 3px;
  }
  .just-btn {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text-dim);
    width: 30px; height: 26px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s, color .15s;
    padding: 0;
    flex-shrink: 0;
  }
  .just-btn svg { width: 14px; height: 14px; pointer-events: none; }
  .just-btn:hover { border-color: var(--amber-dim); color: var(--amber); }
  .just-btn.active {
    background: var(--amber-glow);
    border-color: var(--amber);
    color: var(--amber);
  }
  /* y-offset display */
  .yoff-val {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.72rem;
    color: var(--amber);
    min-width: 52px;
    text-align: right;
  }

  /* font selector */
  .font-select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.82rem;
    padding: 5px 8px;
    outline: none;
    cursor: pointer;
    transition: border-color .15s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
  }
  .font-select:focus { border-color: var(--amber); }
  .font-select option { background: #1a1c20; }

  /* BIU style buttons — same base as just-btn but with text labels */
  .biu-btn {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text-dim);
    width: 26px; height: 26px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s, color .15s;
    padding: 0; flex-shrink: 0;
    font-size: 0.82rem; line-height: 1;
  }
  .biu-btn:hover { border-color: var(--amber-dim); color: var(--amber); }
  .biu-btn.active {
    background: var(--amber-glow);
    border-color: var(--amber);
    color: var(--amber);
  }
  .biu-btn.b-btn { font-weight: 800; font-family: 'Barlow Condensed', sans-serif; }
  .biu-btn.i-btn { font-style: italic; font-family: 'Barlow Condensed', sans-serif; }
  .biu-btn.u-btn { text-decoration: underline; font-family: 'Barlow Condensed', sans-serif; }

  /* rotate buttons */
  .rot-group { display: flex; align-items: center; gap: 4px; }
  .rot-btn {
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 4px; color: var(--text-dim);
    width: 26px; height: 26px; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; transition: all .15s; flex-shrink: 0;
  }
  .rot-btn:hover { border-color: var(--amber-dim); color: var(--amber); }
  .rot-val {
    font-family: 'Share Tech Mono', monospace; font-size: 0.7rem;
    color: var(--amber); min-width: 36px; text-align: center;
  }

  /* ── ICON PICKER MODAL ───────────────────────────── */
  .icon-modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.75);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
  }
  .icon-modal {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 8px;
    width: min(720px, 95vw);
    max-height: 88vh;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,0.7);
    overflow: hidden;
  }
  .icon-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .icon-modal-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700; font-size: 1rem;
    letter-spacing: 0.12em; text-transform: uppercase;
  }
  .icon-slot-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.72rem; color: var(--text-dim);
  }
  .slot-pill {
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 3px; padding: 3px 10px; cursor: pointer;
    font-family: 'Share Tech Mono', monospace; font-size: 0.7rem;
    color: var(--text-dim); transition: all .15s;
  }
  .slot-pill.active, .slot-pill:hover {
    border-color: var(--amber); color: var(--amber);
    background: var(--amber-glow);
  }
  .icon-modal-close {
    background: none; border: none; color: var(--text-dim);
    font-size: 1.1rem; cursor: pointer; padding: 4px 8px;
    border-radius: 4px; transition: color .15s;
  }
  .icon-modal-close:hover { color: var(--red); }
  .icon-cat-tabs {
    display: flex; gap: 2px; padding: 10px 18px 0;
    flex-shrink: 0; flex-wrap: wrap;
  }
  .cat-tab {
    background: none; border: 1px solid transparent;
    border-bottom: none; border-radius: 4px 4px 0 0;
    color: var(--text-dim); font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600; font-size: 0.72rem; letter-spacing: 0.1em;
    text-transform: uppercase; padding: 5px 12px; cursor: pointer;
    transition: color .15s, background .15s;
  }
  .cat-tab:hover { color: var(--text); background: var(--surface2); }
  .cat-tab.active {
    border-color: var(--border2); color: var(--amber);
    background: var(--surface2);
  }
  .icon-grid-wrap {
    overflow-y: auto; padding: 14px 18px 18px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
    flex: 1;
  }
  .icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
  }
  .icon-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; cursor: pointer; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface);
    padding: 10px 6px 8px; transition: border-color .15s, background .15s;
  }
  .icon-item:hover {
    border-color: var(--amber); background: var(--amber-glow);
  }
  .icon-item svg { width: 48px; height: 48px; display: block; }
  .icon-item-label {
    font-size: 0.6rem; color: var(--text-dim); text-align: center;
    line-height: 1.3; font-family: 'Barlow Condensed', sans-serif;
    letter-spacing: 0.04em;
  }
  /* NFPA form */
  .nfpa-form {
    padding: 20px; display: flex; flex-direction: column; gap: 16px;
  }
  .nfpa-inputs {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  }
  .nfpa-field { display: flex; flex-direction: column; gap: 5px; }
  .nfpa-field label {
    font-size: 0.7rem; color: var(--text-dim);
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  }
  .nfpa-field input, .nfpa-field select {
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: 4px; color: var(--text);
    font-family: 'Share Tech Mono', monospace; font-size: 0.9rem;
    padding: 6px 10px; outline: none; transition: border-color .15s;
  }
  .nfpa-field input:focus, .nfpa-field select:focus { border-color: var(--amber); }
  .nfpa-preview-wrap {
    display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  }
  #nfpaPreviewSvg { width: 100px; height: 100px; }
  /* Insert icon button in graphics card */
  .insert-icon-btn {
    width: 100%; margin-top: 8px;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    background: var(--surface2); border: 1px dashed var(--border2);
    border-radius: 4px; padding: 7px; cursor: pointer;
    color: var(--text-dim); font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600; font-size: 0.72rem; letter-spacing: 0.1em;
    text-transform: uppercase; transition: all .15s;
  }
  .insert-icon-btn:hover {
    border-color: var(--amber); color: var(--amber);
    background: var(--amber-glow);
  }
  .insert-icon-btn svg { width: 14px; height: 14px; }

  /* ── GRAPHIC PLACEMENT PANEL ────────────────────── */
  .placement-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    grid-column: 1 / -1; /* full width below the three cards */
  }
  .placement-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }
  @media (max-width: 580px) {
    .placement-grid { grid-template-columns: 1fr; }
  }
  .placement-slot {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    border-right: 1px solid var(--border);
  }
  .placement-slot:last-child { border-right: none; }
  .placement-slot-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600; font-size: 0.68rem;
    letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--text-dim);
    display: flex; align-items: center; gap: 6px;
  }
  .placement-slot-title::before {
    content: ''; display: inline-block;
    width: 6px; height: 6px;
    background: var(--amber); border-radius: 50%;
  }
  .placement-slot.empty { opacity: 0.4; pointer-events: none; }
  .place-row {
    display: flex; align-items: center; gap: 7px;
  }
  .place-label {
    font-size: 0.7rem; color: var(--text-dim);
    white-space: nowrap; min-width: 20px;
  }
  .place-val {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem; color: var(--amber);
    min-width: 48px; text-align: right;
  }
  .center-btn {
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 4px; color: var(--text-dim);
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600; font-size: 0.65rem;
    letter-spacing: 0.08em; text-transform: uppercase;
    padding: 3px 8px; cursor: pointer; white-space: nowrap;
    transition: all .15s; flex-shrink: 0;
  }
  .center-btn:hover {
    border-color: var(--amber); color: var(--amber);
    background: var(--amber-glow);
  }
  /* drag cursor on canvas when over an image */
  #labelCanvas { cursor: default; }
  #labelCanvas.drag-active { cursor: grabbing; }
  #labelCanvas.drag-hover  { cursor: grab; }

  /* ── HAZARD BORDER CONTROLS ──────────────────────── */
  .border-card-body { display: flex; flex-direction: column; gap: 9px; }
  .toggle-row { display: flex; align-items: center; gap: 10px; }
  .toggle-switch {
    position: relative; width: 36px; height: 20px; flex-shrink: 0;
  }
  .toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
  .toggle-track {
    position: absolute; inset: 0; background: var(--border2);
    border-radius: 20px; cursor: pointer; transition: background .2s;
  }
  .toggle-track::after {
    content: ''; position: absolute;
    width: 14px; height: 14px; background: var(--text-dim);
    border-radius: 50%; top: 3px; left: 3px;
    transition: transform .2s, background .2s;
  }
  .toggle-switch input:checked + .toggle-track {
    background: var(--amber-glow); border: 1px solid var(--amber-dim);
  }
  .toggle-switch input:checked + .toggle-track::after {
    transform: translateX(16px); background: var(--amber);
  }
  .toggle-label { font-size: 0.78rem; font-weight: 500; color: var(--text); }

  /* ── QUICK FILL ───────────────────────────────────── */
  .qf-card { display: flex; flex-direction: column; gap: 10px; }
  .qf-paste {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.82rem;
    padding: 8px 10px;
    outline: none;
    resize: none;
    min-height: 52px;
    transition: border-color .15s;
  }
  .qf-paste:focus { border-color: var(--amber); }
  .qf-delim-row {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  }
  .qf-delim-btn {
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 4px; color: var(--text-dim);
    font-family: 'Share Tech Mono', monospace; font-size: 0.72rem;
    padding: 3px 9px; cursor: pointer;
    transition: all .15s;
  }
  .qf-delim-btn:hover, .qf-delim-btn.active {
    border-color: var(--amber); color: var(--amber); background: var(--amber-glow);
  }
  .qf-custom-delim {
    width: 44px;
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 4px; color: var(--amber);
    font-family: 'Share Tech Mono', monospace; font-size: 0.78rem;
    padding: 3px 6px; outline: none; text-align: center;
    transition: border-color .15s;
  }
  .qf-custom-delim:focus { border-color: var(--amber); }
  .qf-tokens {
    display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px;
  }
  .qf-token {
    display: flex; align-items: stretch;
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 4px; overflow: hidden;
    font-family: 'Share Tech Mono', monospace; font-size: 0.72rem;
  }
  .qf-token-text {
    padding: 4px 8px; color: var(--text); border-right: 1px solid var(--border2);
    max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .qf-token-dest {
    background: none; border: none; cursor: pointer;
    color: var(--text-dim); font-family: 'Share Tech Mono', monospace;
    font-size: 0.68rem; padding: 4px 7px;
    transition: color .15s, background .15s;
  }
  .qf-token-dest:hover { background: var(--amber-glow); color: var(--amber); }
  .qf-token-dest.assigned { color: var(--amber); font-weight: 700; }
  .qf-apply-row { display: flex; gap: 8px; align-items: center; }
  .qf-hint {
    font-size: 0.68rem; color: var(--text-dim);
    font-family: 'Barlow Condensed', sans-serif; letter-spacing: .04em;
  }
  /* batch nav */
  .qf-batch-bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 4px; padding: 6px 10px;
  }
  .qf-nav-btn {
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: 4px; color: var(--text); cursor: pointer;
    font-size: 1rem; line-height: 1; padding: 2px 10px;
    transition: all .15s;
  }
  .qf-nav-btn:hover:not(:disabled) { border-color: var(--amber); color: var(--amber); background: var(--amber-glow); }
  .qf-nav-btn:disabled { opacity: 0.3; cursor: default; }
  .qf-record-counter {
    font-family: 'Share Tech Mono', monospace; font-size: 0.8rem;
    color: var(--amber); min-width: 64px; text-align: center;
  }
  .qf-batch-load {
    border: 1.5px dashed var(--border2); border-radius: 4px;
    padding: 7px 12px; cursor: pointer; position: relative;
    display: flex; align-items: center; gap: 7px;
    color: var(--text-dim); font-size: 0.72rem;
    font-family: 'Barlow Condensed', sans-serif; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    transition: all .15s;
  }
  .qf-batch-load:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-glow); }
  .qf-batch-load input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
  .save-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .save-bar-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-right: 4px;
  }
  .tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text);
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 14px;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
  }
  .tool-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
  .tool-btn:hover {
    border-color: var(--amber-dim);
    background: var(--amber-glow);
    color: var(--amber);
  }
  .tool-btn.primary {
    border-color: var(--amber-dim);
    background: var(--amber-glow);
    color: var(--amber);
  }
  .tool-btn.primary:hover {
    background: rgba(245,166,35,0.2);
    border-color: var(--amber);
  }
  .save-status {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.68rem;
    color: var(--green);
    opacity: 0;
    transition: opacity .3s;
    margin-left: 4px;
  }
  .save-status.show { opacity: 1; }

  /* ── OUTPUT / PRINT PANEL ────────────────────────── */
  .media-btns { display: flex; flex-wrap: wrap; gap: 5px; }
  .media-btn {
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 4px; color: var(--text-dim);
    font-family: 'Share Tech Mono', monospace; font-size: 0.72rem;
    padding: 4px 10px; cursor: pointer; transition: all .15s;
  }
  .media-btn:hover, .media-btn.active {
    border-color: var(--amber); color: var(--amber); background: var(--amber-glow);
  }
  .rotate-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-family: 'Share Tech Mono', monospace; font-size: 0.7rem;
    padding: 3px 10px; border-radius: 3px;
    background: var(--amber-glow); border: 1px solid var(--amber-dim);
    color: var(--amber);
  }
  .output-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .out-btn {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 18px; border-radius: 4px; cursor: pointer;
    font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
    font-size: 0.85rem; letter-spacing: 0.1em; text-transform: uppercase;
    transition: all .15s; border: none;
  }
  .out-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
  .out-btn-pdf {
    background: #1a1a2e; border: 2px solid #c00; color: #ff4444;
    box-shadow: 0 0 12px rgba(200,0,0,0.25);
  }
  .out-btn-pdf:hover { background: #2a0a0a; box-shadow: 0 0 20px rgba(200,0,0,0.45); }
  .out-btn-print {
    background: var(--amber-glow); border: 2px solid var(--amber);
    color: var(--amber);
  }
  .out-btn-print:hover { background: rgba(245,166,35,0.25); }
  .out-status {
    font-family: 'Share Tech Mono', monospace; font-size: 0.7rem;
    color: var(--green); opacity: 0; transition: opacity .3s;
  }
  .out-status.show { opacity: 1; }