:root {
  --line: #1a1a1a;
  --line-muted: #888;
  --bg: #fafaf7;
  --card: #ffffff;
  --accent: #5a4a3a;
  --frame-fill: #f0ece4;
  --section-fill: #ffffff;
  --section-stroke: #b9b3a5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--line);
  line-height: 1.5;
}

header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #e0dccf;
  background: #fff;
}
header h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }
header .subtitle { color: #777; font-size: 0.95rem; margin-top: 0.25rem; }
header nav { margin-top: 0.75rem; }
header nav a {
  color: var(--accent);
  text-decoration: none;
  margin-right: 1rem;
  font-size: 0.9rem;
}
header nav a:hover { text-decoration: underline; }

main {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Kategorilista (index) */
.category-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.category-list li a,
.category-list li span {
  display: block;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid #e0dccf;
  border-radius: 6px;
  text-decoration: none;
  color: var(--line);
  font-weight: 500;
}
.category-list li a:hover { border-color: var(--accent); }
.category-list li span { color: #aaa; cursor: not-allowed; }
.category-list li .badge,
.category-list li .count {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  background: #eee;
  color: #777;
  padding: 0.1rem 0.55rem;
  border-radius: 10px;
  font-weight: normal;
  min-width: 1.5rem;
  text-align: center;
}
.category-list li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Variantgalleri */
.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1.5rem;
}

.variant {
  background: var(--card);
  border: 1px solid #e0dccf;
  border-radius: 6px;
  padding: 1rem;
}
.variant h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}
.variant h3 .code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  background: #f3efe7;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85rem;
  margin-right: 0.25rem;
}
.variant-svg {
  width: 100%;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 0.5rem;
}
.variant-svg {
  display: flex;
  justify-content: center;
}
.variant-svg svg {
  display: block;
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
}
.variant-meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}
.variant-meta dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.75rem;
}
.variant-meta dt { color: #777; font-weight: 500; }
.variant-meta dd { margin: 0; }
.variant-ref {
  max-width: 100%;
  height: auto;
  border: 1px solid #eee;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

/* SVG-stilar för ritningarna */
.cabinet-svg .cabinet-body {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.5;
}
.cabinet-svg .sockel {
  fill: #ededed;
  stroke: #888;
  stroke-width: 1;
  stroke-dasharray: 4 3;
}
.cabinet-svg .frame {
  fill: var(--frame-fill);
  stroke: var(--line);
  stroke-width: 1.5;
}
.cabinet-svg .chamfer-line {
  stroke: #8a7d68;
  stroke-width: 0.6;
  fill: none;
  opacity: 0.6;
}
.cabinet-svg .section {
  fill: var(--section-fill);
  stroke: var(--section-stroke);
  stroke-width: 0.75;
  stroke-dasharray: 3 2;
}
.cabinet-svg .section-låda {
  fill: #fbfaf6;
}
.cabinet-svg .section-lucka {
  fill: #ffffff;
}
/* Blindfront: fejkad lådfront utan låda bakom — dämpad fyllning, inget handtag. */
.cabinet-svg .section-blindfront {
  fill: #e7e1d4;
}
.cabinet-svg .section-label {
  fill: #999;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 18px;
  letter-spacing: 1px;
}
/* Underetikett i en sektion — t.ex. "INBYGGD KYL/FRYS" under LUCKA */
.cabinet-svg .section-sublabel {
  fill: #b0a890;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px;
  letter-spacing: 1.5px;
}
.cabinet-svg .open-mark {
  stroke: #cfc8b8;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.cabinet-svg .open-label {
  fill: #b0a890;
  font-size: 22px;
  letter-spacing: 2px;
}
.cabinet-svg .hidden-badge {
  fill: var(--accent);
  stroke: none;
  opacity: 0.85;
}
.cabinet-svg .hidden-badge-text {
  fill: #fff;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
}
.cabinet-svg .hidden-drawer-line {
  stroke: #8a7a55;
  stroke-width: 0.8;
  stroke-dasharray: 5 3;
  fill: none;
  opacity: 0.7;
}
.cabinet-svg .hidden-zone {
  fill: url(#hidden-hatch);
  stroke: #888;
  stroke-width: 1.2;
  stroke-dasharray: 6 3;
  opacity: 0.85;
}
.cabinet-svg .hidden-zone-label {
  fill: #555;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
}
.cabinet-svg .hidden-zone-sublabel {
  fill: #777;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
}
.cabinet-svg .hinge-line {
  stroke: #6a5a44;
  stroke-width: 0.8;
  stroke-dasharray: 4 3;
  fill: none;
  opacity: 0.7;
}
.cabinet-svg .shelf {
  fill: #e8d9b8;
  fill-opacity: 0.55;
  stroke: #8a7a55;
  stroke-width: 0.8;
  stroke-dasharray: 4 2;
}
.cabinet-svg .loose-bottom {
  fill: #d8c9a8;
  fill-opacity: 0.7;
  stroke: #6b4f2a;
  stroke-width: 1;
}
.cabinet-svg .loose-bottom-label {
  fill: #4a3820;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 600;
}
.cabinet-svg .appliance-slot {
  fill: #fafafa;
  stroke: #555;
  stroke-width: 1;
  stroke-dasharray: 6 3;
}
.cabinet-svg .appliance-label {
  fill: #444;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 22px;
  letter-spacing: 3px;
  font-weight: 600;
}
.readonly-output {
  display: inline-block;
  padding: 0.4rem 0.5rem;
  background: #fafaf7;
  border: 1px solid #e8e4d8;
  border-radius: 3px;
  font-size: 0.9rem;
}
.readonly-output .ok { color: #2a6b3f; }
.readonly-output .error-inline { color: #b14242; }
.bottom-front-editor {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #ddd;
}
.bottom-front-editor strong {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: #555;
}

/* ─── Stommesammanfattning (startsidan) ───────────────────── */
.stomme-summary { margin-top: 2.5rem; }
.stomme-summary h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 0.75rem; }
.table-wrap { overflow-x: auto; }
.stomme-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid #e0dccf;
  border-radius: 6px;
  font-size: 0.9rem;
}
.stomme-table th, .stomme-table td {
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #f0ece4;
  vertical-align: top;
}
.stomme-table th {
  background: #fafaf7;
  color: #777;
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stomme-table tr:last-child td { border-bottom: none; }
.stomme-table tbody tr:hover { background: #fafaf7; }

/* ─── Beslutssida ─────────────────────────────────────────── */
.beslut-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 820px;
  counter-reset: beslut;
}
.beslut {
  background: var(--card);
  border: 1px solid #e0dccf;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  counter-increment: beslut;
}
.beslut h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--accent); }
.beslut h3::before { content: counter(beslut) ". "; color: #b0a890; }
.beslut p { margin: 0; font-size: 0.92rem; }
.beslut-date { margin-top: 0.5rem; font-size: 0.75rem; color: #999; }

/* ─── Sökruta ─────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin-top: 0.75rem;
  max-width: 480px;
}
#search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
#search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.search-results li { border-bottom: 1px solid #f0ece4; }
.search-results li:last-child { border-bottom: none; }
.search-results a {
  display: grid;
  grid-template-columns: max-content 1fr;
  grid-template-rows: auto auto;
  gap: 0.1rem 0.6rem;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--line);
}
.search-results a:hover { background: #fafaf7; }
.search-results li.active > a { background: #f3efe7; }
.search-code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  background: #f3efe7;
  color: var(--accent);
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85rem;
  grid-row: 1 / 3;
  align-self: center;
}
.search-desc { font-size: 0.9rem; }
.search-meta { font-size: 0.75rem; color: #888; }
.search-empty { padding: 0.6rem 0.75rem; color: #999; font-size: 0.9rem; }

/* ─── Zondata — härledd beskrivning av frontens zoner ─────────
   Text + JSON per stomme så att AI-verktyg kan läsa hur skåpet
   fungerar utan att tolka SVG-ritningen. */
.zone-data {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}
.zone-data summary {
  cursor: pointer;
  color: #777;
  user-select: none;
}
.zone-data summary:hover { color: var(--accent); }
.zone-json {
  margin: 0.4rem 0 0;
  padding: 0.6rem 0.75rem;
  background: #fafaf7;
  border: 1px solid #e8e4d8;
  border-radius: 4px;
  overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre;
  cursor: text;
}

/* Fallback i katalogkortet när en stomme inte kan ritas (skyddar mot blank sida). */
.render-error {
  padding: 1rem;
  color: #a33;
  background: #fdf3f1;
  border: 1px dashed #e0b4ad;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ─── Filter-bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #e0dccf;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.filter-bar label { display: flex; align-items: center; gap: 0.4rem; color: #555; }
.filter-bar label.check { gap: 0.3rem; cursor: pointer; }
.filter-bar input[type="number"] {
  width: 90px;
  padding: 0.3rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  font: inherit;
}

/* ─── Sidebar thumbnail ───────────────────────────────────── */
.sidebar-item {
  align-items: stretch;
}
.sidebar-thumb {
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-thumb svg {
  width: 100%;
  height: 60px;
  display: block;
}
.sidebar-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.sidebar-text .sidebar-code { font-size: 0.75rem; }
.sidebar-text .sidebar-desc {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Versionsstämpel ─────────────────────────────────────── */
.updated-note {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  color: #999;
}

/* ─── PDF / utskrift ──────────────────────────────────────── */
@media print {
  header nav, .filter-bar, .search-wrap, .variant-hint,
  #btn-new, #btn-export, .sidebar, .modal-footer, .zone-data,
  button { display: none !important; }
  body { background: #fff; }
  header { border-bottom: 1px solid #888; padding: 0.5rem 1rem; }
  header h1 { font-size: 1rem; }
  header .subtitle { display: none; }
  .variant-grid {
    display: block;
  }
  .variant {
    page-break-after: always;
    break-after: page;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0;
  }
  .variant:last-child { page-break-after: auto; }
  .variant-svg svg { max-height: none; max-width: 100%; }
  .heritage-banner {
    background: transparent !important;
    border-left: 2px solid #444 !important;
  }
}

/* ─── Inredning ───────────────────────────────────────────── */
.inredning-card .inredning-meta dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 0.9rem;
  margin: 0;
  font-size: 0.9rem;
}
.inredning-card .inredning-meta dt {
  color: #888;
  font-weight: 500;
}
.inredning-card .inredning-meta dd { margin: 0; }
.inredning-card .size-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.inredning-card .size-list li {
  background: #fafaf7;
  border: 1px solid #eee;
  border-radius: 3px;
  padding: 0.35rem 0.55rem;
}
.stomme-link {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  background: #f3efe7;
  color: var(--accent);
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  text-decoration: none;
  font-size: 0.85rem;
}
.stomme-link:hover { text-decoration: underline; }
.style-tag {
  display: inline-block;
  background: #e8e4d8;
  color: #555;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-size: 0.8rem;
  margin-right: 0.25rem;
}
.detail-svg .wood-profile {
  fill: #e8d9b8;
  stroke: #6b4f2a;
  stroke-width: 1.5;
}
.detail-svg .face-label {
  fill: #555;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px;
  letter-spacing: 1.5px;
}
.detail-svg .angle-arc {
  fill: none;
  stroke: #c44;
  stroke-width: 1;
}
.detail-svg .angle-label {
  fill: #c44;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
}

/* ─── Editor ──────────────────────────────────────────────── */
.editor-main {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  max-width: 1600px;
}
.sidebar {
  background: #fff;
  border: 1px solid #e0dccf;
  border-radius: 6px;
  padding: 1rem;
  align-self: start;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.publish-status {
  font-size: 0.85rem;
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}
.publish-status.pending { background: #fff3cd; color: #856404; }
.publish-status.ok      { background: #d4edda; color: #155724; }
.publish-status.muted   { background: #eef0f3; color: #555; }
.publish-status.error   { background: #fbecec; color: #b14242; }
.sidebar-group h4 {
  margin: 1rem 0 0.4rem 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
}
.sidebar-group ul { list-style: none; padding: 0; margin: 0; }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.sidebar-item:hover { background: #f3efe7; }
.sidebar-item.active { background: var(--accent); color: #fff; }
.sidebar-item.active .sidebar-code { color: #fff; }
.sidebar-code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}
.sidebar-desc {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag {
  font-size: 0.65rem;
  padding: 0.05rem 0.4rem;
  border-radius: 8px;
  text-transform: uppercase;
  font-weight: 600;
}
.tag-new { background: #d4edda; color: #155724; }
.tag-edited { background: #fff3cd; color: #856404; }
.sidebar-item.active .tag { background: rgba(255,255,255,0.25); color: #fff; }

.editor-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.editor-form {
  background: #fff;
  border: 1px solid #e0dccf;
  border-radius: 6px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.editor-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: #555;
  flex: 1;
}
.editor-form label.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}
.editor-form label.full { flex: 1 1 100%; }
.editor-form input,
.editor-form select,
.editor-form textarea {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
.editor-form input:focus,
.editor-form select:focus,
.editor-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.form-row { display: flex; gap: 0.75rem; }
.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  border-top: 1px solid #eee;
  padding-top: 0.75rem;
}

button {
  font: inherit;
  padding: 0.5rem 0.9rem;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  color: var(--line);
}
button:hover { background: #f3efe7; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: #6b5848; }
button.danger { color: #b14242; border-color: #d8b8b8; }
button.danger:hover { background: #fbecec; }
button.small { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
button.mini { font-size: 0.75rem; padding: 0.2rem 0.5rem; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.front-builder {
  border: 1px solid #e0dccf;
  border-radius: 4px;
  padding: 0.75rem;
}
.front-builder legend {
  font-size: 0.85rem;
  color: #555;
  padding: 0 0.4rem;
}
.rows-editor { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.row-editor {
  background: #fafaf7;
  border: 1px solid #e8e4d8;
  border-radius: 4px;
  padding: 0.5rem;
}
.row-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.cols { display: flex; flex-direction: column; gap: 0.3rem; }
.col-editor {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 3px;
}
.add-row {
  align-self: flex-start;
  border: 1px dashed #aaa;
  background: transparent;
  font-size: 0.85rem;
}
.hint { font-size: 0.8rem; color: #888; margin: 0.25rem 0 0 0; }

.preview {
  background: #fff;
  border: 1px solid #e0dccf;
  border-radius: 6px;
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
}
.preview h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  color: var(--accent);
}
#preview-svg {
  display: flex;
  justify-content: center;
}
#preview-svg svg {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
}
.error {
  background: #fbecec;
  color: #b14242;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}
.muted { color: #999; }

#export-dialog {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 1.5rem;
  max-width: 700px;
}
#export-dialog::backdrop { background: rgba(0,0,0,0.4); }
#export-text {
  width: 100%;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.8rem;
}
#export-dialog menu {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0;
  margin: 1rem 0 0 0;
}

@media (max-width: 1100px) {
  .editor-main { grid-template-columns: 1fr; }
  .editor-pane { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
}

/* ─── Cabinet popup-modal ─────────────────────────────────── */
.cabinet-modal {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 0;
  width: min(1100px, 95vw);
  max-height: 90vh;
}
.cabinet-modal::backdrop { background: rgba(20, 20, 20, 0.55); }
.modal-form {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #eee;
  background: #fafaf7;
  border-radius: 8px 8px 0 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}
.modal-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  padding: 0 0.4rem;
  cursor: pointer;
  color: #777;
}
.modal-close:hover { color: var(--line); }

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}
.modal-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.modal-preview {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 0.5rem;
  position: sticky;
  top: 0;
  align-self: start;
  text-align: center;
  min-height: 200px;
}
.zoom-toolbar {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  user-select: none;
}
.zoom-toolbar button {
  width: 2rem;
  height: 1.75rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  background: #f4f4f4;
  border: 1px solid #ccc;
  border-radius: 3px;
}
.zoom-toolbar button:hover { background: #e8e8e8; }
.zoom-toolbar .zoom-level {
  min-width: 3.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: #555;
}
.zoom-viewport {
  overflow: auto;
  height: 70vh;
  cursor: grab;
  touch-action: none;
}
.zoom-viewport.dragging { cursor: grabbing; }
.zoom-viewport svg.cabinet-svg {
  display: block;
  width: calc(100% * var(--zoom, 1));
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0 auto;
  pointer-events: none;
}
.modal-preview svg {
  display: inline-block;
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
}
.modal-error {
  background: #fbecec;
  color: #b14242;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
}
.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #eee;
  background: #fafaf7;
  border-radius: 0 0 8px 8px;
}
.modal-footer .spacer { flex: 1; }

.modal-readonly {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 0.75rem;
  margin: 0.75rem 0 0 0;
  padding: 0.75rem;
  background: #fafaf7;
  border: 1px solid #eee;
  border-radius: 4px;
  font-size: 0.85rem;
}
.modal-readonly dt { color: #888; }
.modal-readonly dd { margin: 0; }

@media (max-width: 800px) {
  .modal-body { grid-template-columns: 1fr; }
}

/* Variant card hover-affordance */
.variant {
  cursor: pointer;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.variant:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.variant-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #aaa;
  text-align: right;
  font-style: italic;
}

/* Heritage-banner — lyfter fram Prodboard-mappningen */
.heritage-banner {
  background: #f3efe7;
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  border-radius: 0 3px 3px 0;
}
.heritage-label { color: #777; font-size: 0.8rem; margin-right: 0.25rem; }

/* Editor status */
.editor-status { margin-bottom: 0.5rem; }
.status {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-saved { background: #d4edda; color: #155724; }
.status-dirty { background: #fff3cd; color: #856404; }
.status-new   { background: #cfe2ff; color: #084298; }
.editor-error {
  background: #fbecec;
  color: #b14242;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}
.cabinet-svg .handle-hint {
  stroke: #999;
  stroke-width: 1.2;
}
.cabinet-svg .dim-line,
.cabinet-svg .dim-tick {
  stroke: #555;
  stroke-width: 0.6;
  fill: none;
  color: #555;
}
.cabinet-svg .dim-text {
  fill: #333;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.cabinet-svg .dim {
  color: #555;
}
