:root {
  color-scheme: light;
  --paper: #f7f4ec;
  --paper-strong: #fffdf8;
  --panel: #ffffff;
  --ink: #172033;
  --ink-soft: #3d4960;
  --muted: #6e7789;
  --line: #d8dbe0;
  --line-strong: #aab0ba;
  --blue: #2364d2;
  --blue-dark: #174999;
  --blue-pale: #eaf1ff;
  --signal: #ffb000;
  --signal-pale: #fff3ce;
  --danger: #bd2d2d;
  --success: #187455;
  --shadow: 0 14px 34px rgba(23, 32, 51, .09);
}

* { box-sizing: border-box; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
html { min-height: 100%; overflow-x: hidden; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background-color: #edf0f3;
  background-image:
    linear-gradient(rgba(66, 79, 101, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(66, 79, 101, .045) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: "Montserrat", "DejaVu Sans", sans-serif;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(24px, 2.4vw, 34px); line-height: 1.04; letter-spacing: -.035em; }
h2 { margin-bottom: 10px; font-size: 16px; line-height: 1.2; letter-spacing: -.015em; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  grid-template-rows: 68px 1fr;
}

.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 2000;
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
  padding: 10px 18px;
  color: white;
  background:
    linear-gradient(105deg, rgba(255, 176, 0, .13), transparent 31%),
    #172033;
  box-shadow: 0 5px 20px rgba(12, 18, 30, .25);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.brand-mark {
  width: 43px;
  height: 43px;
  padding: 4px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 50%;
  background: var(--signal);
  box-shadow: inset 0 0 0 4px var(--ink);
}
.brand-mark span { font-size: 12px; font-weight: 900; color: var(--ink); }
.brand strong, .brand > div > span { display: block; }
.brand strong { font-size: 16px; letter-spacing: -.02em; }
.brand > div > span { margin-top: 1px; color: #aeb7c8; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }

.project-name-wrap { min-width: 180px; display: grid; gap: 3px; }
.project-name-wrap > span { color: var(--muted); font-size: 8px; font-weight: 900; white-space: nowrap; text-transform: uppercase; letter-spacing: .08em; }
.project-name-wrap input {
  width: min(26vw, 280px);
  min-width: 180px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
  background: white;
}
.project-name-wrap input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(35, 100, 210, .1); }
.top-actions { min-width: 0; margin-left: auto; display: flex; align-items: center; gap: 7px; }
.save-status { max-width: 170px; margin-right: 4px; overflow: hidden; color: #aeb7c8; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.sidebar {
  z-index: 10;
  height: calc(100vh - 68px);
  padding: 18px;
  overflow-y: auto;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(12px);
}
.left-sidebar { grid-column: 1; grid-row: 2; position: sticky; top: 68px; border-right: 1px solid var(--line); }
.left-sidebar { padding: 14px 10px; }
.left-sidebar > .eyebrow { margin: 2px 0 12px; text-align: center; }
.tool-button {
  width: 100%;
  min-height: 66px;
  margin-bottom: 8px;
  padding: 8px 4px;
  display: grid;
  place-items: center;
  gap: 4px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  font-size: 9px;
  font-weight: 900;
}
.tool-button:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-pale); }
.tool-button-primary { color: var(--ink); border-color: #e5a000; background: var(--signal); box-shadow: 0 7px 18px rgba(255,176,0,.25); }
.tool-button-primary:hover { color: var(--ink); border-color: #c98d00; background: #ffc23d; }
.tool-icon { font-size: 24px; line-height: 1; }
.sidebar-version { display: block; margin-top: 16px; overflow: hidden; color: var(--muted); font-size: 7px; text-align: center; text-overflow: ellipsis; }
.panel-section { margin-bottom: 19px; padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.panel-section:last-child { margin-bottom: 0; border-bottom: 0; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.hint, .workspace-toolbar p { margin-bottom: 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }

.btn, .icon-btn {
  padding: 8px 12px;
  color: var(--ink);
  border: 1px solid #c6cbd3;
  border-radius: 7px;
  background: white;
  font-size: 12px;
  font-weight: 800;
  transition: border-color .16s, background .16s, color .16s, transform .16s;
}
.btn:hover, .icon-btn:hover { border-color: #929baa; background: #f8f9fb; }
.btn:active, .icon-btn:active { transform: translateY(1px); }
.btn.primary { color: white; border-color: var(--blue); background: var(--blue); }
.btn.primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #efc2c2; background: #fff8f7; }
.icon-btn { min-width: 32px; padding: 6px 8px; }
.topbar .btn { color: white; border-color: #4b5870; background: #222d42; }
.topbar .btn:hover { border-color: #77839a; background: #2b374d; }
.topbar .btn.primary { color: var(--ink); border-color: var(--signal); background: var(--signal); }
.topbar .btn.primary:hover { background: #ffc23d; }

.projects-list { display: grid; gap: 7px; max-height: 205px; overflow: auto; }
.projects-menu-wrap { position: relative; z-index: 1; }
.projects-menu-panel { position: absolute; top: calc(100% + 9px); right: 0; z-index: 2; width: 300px; padding: 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 9px; background: white; box-shadow: 0 18px 45px rgba(12,18,30,.3); }
.projects-menu-panel .section-title-row { margin-bottom: 9px; }
.module-quick-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 9px; }
.module-quick-pick button { padding: 8px 0; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 6px; background: white; font-weight: 900; }
.module-quick-pick button.active { color: white; border-color: var(--blue); background: var(--blue); box-shadow: 0 0 0 2px rgba(35,100,210,.13); }
.project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.project-item.active { border-color: var(--blue); box-shadow: inset 3px 0 var(--blue); }
.project-item-main { min-width: 0; cursor: pointer; }
.project-item strong, .project-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item strong { font-size: 12px; }
.project-item small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.project-menu { padding: 4px; color: var(--muted); border: 0; background: none; }
.catalog-open-btn { width: 100%; }
.refresh-application-btn { width: 100%; margin-top: 8px; }
.app-version-line { margin: 5px 0 0; text-align: center; }

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.palette-item {
  min-height: 60px;
  padding: 9px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8fa;
}
.palette-item:hover { border-color: var(--blue); background: var(--blue-pale); }
.palette-item > .palette-item-head { display: flex; align-items: center; gap: 7px; margin: 0; color: inherit; }
.palette-glyph { width: 22px; height: 22px; flex: 0 0 22px; display: block; color: var(--blue); }
.palette-glyph svg { width: 100%; height: 100%; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.palette-item strong { display: block; font-size: 11px; line-height: 1.2; }
.palette-item > span:last-child { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.compact-grid, .properties-form { display: grid; gap: 11px; }
.group-width-settings { padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px; background: #f8f9fb; }
.group-width-settings summary { cursor: pointer; font-size: 10px; font-weight: 900; }
.group-width-settings .hint { margin: 7px 0; font-size: 9px; }
.group-width-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.group-width-grid label { grid-template-columns: minmax(0, 1fr) 52px; align-items: center; gap: 5px; }
.group-width-grid label > span { display: flex; align-items: center; gap: 5px; overflow: hidden; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.group-width-grid i { width: 8px; height: 8px; flex: 0 0 8px; border: 1px solid rgba(0,0,0,.14); border-radius: 50%; background: var(--group-color); }
.group-width-grid input { padding: 5px 4px; font-size: 9px; text-align: center; }

label { display: grid; gap: 5px; }
label > span, .field-label { color: var(--muted); font-size: 10px; font-weight: 800; }
label > small { margin-top: -1px; color: #9097a4; font-size: 9px; line-height: 1.35; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
  color: var(--ink);
  border: 1px solid #c8cdd5;
  border-radius: 6px;
  outline: none;
  background: white;
}
textarea { resize: vertical; }
input[type="color"] { height: 38px; padding: 4px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(35, 100, 210, .1); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; accent-color: var(--blue); }
.checkbox-row span { color: var(--ink); font-size: 11px; }

.app-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: white;
  box-shadow: 0 28px 80px rgba(15,23,42,.32);
}
.settings-dialog { width: min(520px, calc(100vw - 28px)); }
.new-project-dialog { width: min(480px, calc(100vw - 28px)); }
.new-project-form { padding: 17px; display: grid; gap: 11px; overflow-y: auto; }
.new-project-form > label { display: grid; gap: 5px; }
.new-project-field-label { margin-bottom: -6px; color: var(--muted); font-size: 9px; font-weight: 800; }
.new-project-warning { margin: 2px 0 0; padding: 9px 10px; color: var(--muted); border-radius: 7px; background: #f2f4f7; font-size: 9px; line-height: 1.45; }
.settings-form { padding: 17px; display: grid; grid-template-columns: 1fr; gap: 18px; overflow-y: auto; }
.settings-form section { display: grid; align-content: start; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: #f8f9fb; }
.settings-form h3 { margin: 0 0 2px; font-size: 12px; }
.settings-actions { grid-column: 1 / -1; }
.dialog-rail-width-picker .rail-width-options {
  position: static;
  width: 100%;
  max-height: 240px;
  margin-top: 5px;
  box-shadow: 0 8px 22px rgba(23,32,51,.12);
}
.catalog-footer { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 16px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }
.catalog-footer-copy { min-width: 0; display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.catalog-footer-copy strong { flex: 0 0 auto; color: var(--ink); font-size: 11px; }
.catalog-footer-copy span { min-width: 0; color: var(--success); font-size: 10px; font-weight: 800; white-space: normal; }
#finishAddingDevicesBtn { flex: 0 0 auto; white-space: nowrap; }
.app-dialog::backdrop { background: rgba(15,23,42,.48); backdrop-filter: blur(3px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.app-dialog .dialog-header[data-dialog-drag-handle] { cursor: move; touch-action: none; }
.app-dialog.dragging { user-select: none; }
.dialog-header h2 { margin: 0; }
.dialog-close { width: 34px; height: 34px; color: var(--muted); border: 0; border-radius: 50%; background: #f2f4f7; font-size: 23px; }
.catalog-toolbar { padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f8f9fb; }
.catalog-toolbar .module-quick-pick { margin: 0; }
.catalog-scroll-region { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; overscroll-behavior: contain; }
.catalog-search-row { padding: 12px 16px 0; }
.catalog-search-row input { width: 100%; }
.catalog-palette { min-height: 0; flex: 1 1 auto; max-height: none; padding: 12px 16px 18px; overflow-y: auto; grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.catalog-palette .palette-item { min-height: 54px; }
.rail-settings-dialog { width: min(450px, calc(100vw - 28px)); }
.rail-settings-dialog form { padding: 16px; }
.auth-dialog { width: min(410px, calc(100vw - 28px)); }
.auth-dialog form { padding: 16px; }
.profile-dialog { width: min(520px, calc(100vw - 28px)); }
.print-dialog {
  width: min(1180px, calc(100vw - 28px));
  height: calc(100dvh - 28px);
  max-height: calc(100dvh - 28px);
  display: none;
  flex-direction: column;
}
.print-dialog[open] { display: flex; }
.print-form {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(500px, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 9px;
  padding: 12px;
  overflow: hidden;
}
.print-form section {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8f9fb;
}
.print-settings-column {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  align-content: start;
  gap: 9px;
  overflow-y: auto;
  padding-right: 3px;
}
.print-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}
.print-section-heading strong { display: block; margin-top: 2px; font-size: 12px; }
.print-profile-limit {
  padding: 3px 6px;
  color: var(--muted);
  border-radius: 999px;
  background: #e9edf3;
  font-size: 8px;
  font-weight: 900;
}
.print-split-summary {
  padding: 7px 9px;
  color: var(--ink-soft);
  border: 1px solid #b9cce9;
  border-radius: 8px;
  background: var(--blue-pale);
  font-size: 10px;
  line-height: 1.35;
}
.print-choice-field { display: grid; gap: 5px; }
.print-choice-field > span { color: var(--muted); font-size: 8px; font-weight: 900; }
.print-choice-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.print-choice-grid button {
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 8px;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  font-size: 8px;
  font-weight: 900;
}
.print-choice-grid button:hover:not(:disabled) { border-color: var(--blue); }
.print-choice-grid button.active { color: var(--blue); border-color: var(--blue); background: var(--blue-pale); box-shadow: inset 0 0 0 1px var(--blue); }
.print-choice-grid button:disabled { opacity: .38; cursor: not-allowed; }
.print-format-buttons button { flex: 1 1 38px; padding-inline: 5px; }
.paper-format-icon { width: 9px; height: 12px; border: 1.5px solid currentColor; border-radius: 1px; }
.paper-orientation-icon { width: 13px; height: 9px; border: 1.5px solid currentColor; border-radius: 1px; }
.paper-orientation-icon.portrait { width: 9px; height: 13px; }
.cut-mode-icon { position: relative; width: 17px; height: 12px; border: 1px solid #b4bdca; background: #fff; }
.cut-mode-icon.corners { border-style: dashed; }
.cut-mode-icon.full { border-color: currentColor; }
.cut-mode-icon.off::after { content: ''; position: absolute; left: 1px; right: 1px; top: 5px; border-top: 1.5px solid currentColor; transform: rotate(-30deg); }
.print-preview-page-count {
  padding: 4px 7px;
  color: var(--muted);
  border-radius: 999px;
  background: #e9edf3;
  font-size: 8px;
  font-weight: 900;
}
.print-preview-tools { display: flex; align-items: center; gap: 6px; }
.print-preview-zoom { display: flex; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 6px; background: white; }
.print-preview-zoom button { min-width: 27px; height: 25px; padding: 0 6px; color: var(--ink-soft); border: 0; border-right: 1px solid var(--line); background: white; font-size: 11px; font-weight: 900; }
.print-preview-zoom button:last-child { border-right: 0; }
.print-preview-zoom button:disabled { opacity: .35; }
#printPreviewZoomReset { min-width: 48px; font-size: 8px; }
.print-preview-panel {
  grid-column: 2;
  grid-row: 1;
  align-self: stretch;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
}
.print-preview-panel .print-section-heading { align-items: center; }
.print-preview-panel .btn { padding: 6px 8px; font-size: 8px; }
.print-preview-hint { margin: -2px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.print-preview-frame-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #dfe3e8;
}
.print-preview-pages {
  min-height: 100%;
  display: grid;
  align-content: start;
  justify-items: center;
  padding: 14px;
}
.print-preview-page { width: 100%; max-width: 920px; margin: 0; }
.print-preview-page img {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
  box-shadow: 0 2px 9px rgba(15,23,42,.18);
}
.print-preview-page figcaption {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  color: #687385;
  font-size: 8px;
  font-weight: 900;
  white-space: nowrap;
}
.print-preview-page figcaption::before,
.print-preview-page figcaption::after { content: ''; flex: 1; border-top: 1px dashed #7d8795; }
.print-preview-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--ink-soft);
  background: rgba(247,248,250,.94);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
.print-preview-frame-wrap.ready .print-preview-state { display: none; }
.print-preview-frame-wrap.refreshing .print-preview-state {
  inset: 10px 10px auto auto;
  display: block;
  padding: 6px 9px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(15,23,42,.14);
  font-size: 8px;
}
.print-preview-frame-wrap.error .print-preview-state { color: var(--danger); }
.three-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.print-actions {
  position: sticky;
  z-index: 2;
  bottom: -16px;
  grid-column: 1 / -1;
  align-items: center;
  padding: 11px 0 2px;
  background: #fff;
  box-shadow: 0 -10px 18px rgba(255,255,255,.96);
}
.print-actions #deletePrintProfileBtn { margin-right: auto; }

@media (max-width: 900px) {
  .print-dialog { display: none; height: auto; }
  .print-dialog[open] { display: block; overflow-y: auto; }
  .print-form { display: grid; grid-template-columns: 1fr; grid-template-rows: auto; overflow: visible; }
  .print-settings-column,
  .print-preview-panel, .print-actions { grid-column: 1; grid-row: auto; }
  .print-preview-panel { min-height: 430px; }
  .print-preview-frame-wrap { min-height: 350px; height: 60dvh; }
}
.profile-content { display: grid; gap: 15px; padding: 16px; }
.profile-identity { display: grid; gap: 3px; padding: 11px 12px; border-radius: 8px; background: #f3f5f7; }
.profile-identity strong { font-size: 14px; }
.profile-identity span { color: var(--muted); font-size: 10px; }
.profile-groups-list { display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.profile-group-item { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px; }
.profile-group-item i { width: 14px; height: 14px; border: 1px solid rgba(0,0,0,.16); border-radius: 50%; background: var(--group-color); }
.profile-group-item span, .profile-group-item strong, .profile-group-item small { display: block; min-width: 0; }
.profile-group-item strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.profile-group-item small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 7px; background: #eef0f3; }
.auth-tabs button { padding: 7px; color: var(--muted); border: 0; border-radius: 5px; background: transparent; font-weight: 900; }
.auth-tabs button.active { color: var(--ink); background: white; box-shadow: 0 2px 7px rgba(15,23,42,.12); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; margin-top: 5px; }
.properties-dialog {
  position: fixed;
  z-index: 60;
  inset: 50% auto auto 50%;
  width: min(460px, calc(100vw - 24px));
  height: fit-content;
  max-height: calc(100dvh - 24px);
  margin: 0;
  overflow: hidden;
  transform: translate(-50%, -50%);
}
.properties-dialog[open] { display: flex; flex-direction: column; }
.properties-dialog.mobile-inline-editor {
  position: relative;
  z-index: 12;
  inset: auto;
  grid-column: 1 / -1;
  width: 100%;
  height: auto;
  max-height: none;
  margin: 0;
  transform: none;
  box-shadow: 0 12px 32px rgba(23,32,51,.16);
}
.properties-dialog.mobile-inline-editor .panel-section {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
  overscroll-behavior: auto;
}
.properties-dialog.mobile-inline-editor .properties-add-tab {
  flex: 0 0 auto;
  overflow: visible;
}
.properties-dialog.mobile-inline-editor .catalog-palette {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
}
.properties-dialog.mobile-inline-editor::backdrop {
  background: transparent;
  backdrop-filter: none;
}
.properties-dialog .dialog-header { flex: 0 0 auto; }
.properties-dialog .dialog-header { padding: 9px 12px; }
.properties-dialog .dialog-header h2 { font-size: 15px; }
.properties-dialog .dialog-close { width: 29px; height: 29px; font-size: 19px; }
.properties-tabs { flex: 0 0 auto; display: grid; grid-template-columns: 31px repeat(3, minmax(0, 1fr)) 31px; gap: 3px; padding: 6px 9px; border-bottom: 1px solid var(--line); background: #f3f5f8; }
.properties-tabs button { padding: 7px 10px; color: var(--muted); border: 0; border-radius: 6px; background: transparent; font-size: 10px; font-weight: 900; }
.properties-tabs button.active { color: white; background: var(--blue); box-shadow: 0 2px 8px rgba(35,100,210,.22); }
.properties-tabs .properties-tab-shift {
  width: 31px;
  height: 31px;
  padding: 6px;
  display: grid;
  place-items: center;
  color: var(--blue);
  border: 1px solid #c7ced8;
  background: #fff;
}
.properties-tabs .properties-tab-shift svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}
.properties-tabs .properties-tab-shift:disabled {
  opacity: .35;
  color: #7d8795;
  background: #f4f5f7;
}
.editor-command-bar {
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.editor-command-group { display: flex; align-items: center; gap: 5px; }
.mobile-device-order { display: none; }
.editor-command-separator { width: 1px; height: 22px; margin: 0 2px; background: var(--line); }
.icon-action-btn {
  width: 31px;
  height: 31px;
  padding: 6px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--blue);
  border: 1px solid #c7ced8;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.icon-action-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}
.icon-action-btn:hover,
.icon-action-btn:focus-visible {
  border-color: var(--blue);
  background: var(--blue-pale);
  outline: none;
}
.icon-action-btn.primary { color: #fff; border-color: var(--blue); background: var(--blue); }
.icon-action-btn.navigation {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: 0 2px 7px rgba(35,100,210,.24);
}
.icon-action-btn.navigation:hover,
.icon-action-btn.navigation:focus-visible { color: #fff; background: #194fae; }
.icon-action-btn.danger { color: var(--danger); }
.icon-action-btn.danger:hover,
.icon-action-btn.danger:focus-visible { border-color: var(--danger); background: #fff0f1; }
.icon-action-btn:disabled {
  opacity: .35;
  color: #7d8795;
  border-color: #cfd4dc;
  background: #f4f5f7;
  cursor: not-allowed;
}
.icon-action-btn.navigation:disabled {
  opacity: 1;
  color: #8ba6d5;
  border-color: #bfd0ed;
  background: #e8effa;
  box-shadow: none;
}
.properties-add-tab { display: none; min-height: 0; flex: 1 1 auto; flex-direction: column; overflow: hidden; }
.properties-dialog.add-mode .properties-add-tab { display: flex; }
.properties-dialog.add-mode .properties-edit-tab { display: none !important; }
.properties-dialog.add-mode .dialog-header[data-dialog-drag-handle] { cursor: default !important; }
.properties-dialog.add-mode .catalog-toolbar { grid-template-columns: 1fr; }
.properties-dialog.add-mode .catalog-palette { flex: 1 1 auto; max-height: none; grid-template-columns: repeat(2, minmax(120px, 1fr)); }
.detached-properties-placeholder {
  margin: 14px;
  padding: 22px 14px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8f9fb;
  font-size: 10px;
  text-align: center;
}
.detached-properties-dialog {
  z-index: 90;
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
}
.detached-properties-dialog[open] { display: flex; flex-direction: column; }
.detached-properties-dialog .panel-section { max-height: calc(100dvh - 112px); }
@media (min-width: 851px) and (max-width: 1100px) {
  .properties-dialog.add-mode {
    inset: 68px 0 0 auto !important;
    width: min(420px, calc(100vw - 92px));
    height: calc(100vh - 68px);
    max-height: none;
    border-width: 0 0 0 1px;
    border-radius: 0;
    transform: none !important;
  }
}
.properties-dialog .panel-section { flex: 0 1 auto; min-height: 0; max-height: calc(100dvh - 178px); margin: 0; padding: 8px; overflow-y: auto; overscroll-behavior: contain; border: 0; }
.properties-dialog .properties-form { grid-template-columns: 1fr; align-items: start; gap: 7px; margin: 0; }
.properties-dialog .property-group { gap: 7px; margin: 0; padding: 8px 9px; }
.properties-dialog .property-group-title { margin-bottom: 1px; }
.properties-dialog input,
.properties-dialog select,
.properties-dialog textarea { padding: 5px 7px; font-size: 11px; }
.properties-dialog input[type="color"] { height: 30px; padding: 3px; }
.properties-dialog .input-with-action button { min-height: 28px; }
.properties-dialog .two-cols { gap: 6px; }
.properties-dialog .geometry-summary { grid-column: 1 / -1; }
.properties-dialog.device-mode .properties-label-tab { display: none !important; }
.properties-dialog.label-mode .properties-device-tab,
.properties-dialog.label-mode .properties-device-action { display: none !important; }
.properties-dialog.label-mode .properties-label-tab { grid-template-columns: 1fr; margin: 0; padding: 8px 9px; }
.properties-dialog.label-mode .property-group-title,
.properties-dialog.label-mode .label-wide { grid-column: auto; }
.properties-dialog.label-mode .group-swatches { grid-template-columns: repeat(10, 28px); }
.properties-dialog.label-mode .group-swatch { width: 28px; }
.label-affixes-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 52px;
  gap: 6px;
}
.label-affixes-row label,
.label-fill-field {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.label-affixes-row label > span,
.label-fill-field > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}
.properties-dialog .label-affixes-row input {
  width: 100%;
  height: 30px;
  min-width: 0;
}
.label-fill-field .label-fill-toggle { width: 100%; }
.label-numbering-row {
  display: grid;
  grid-template-columns: max-content minmax(36px, 1fr) 30px;
  align-items: center;
  gap: 4px;
}
.label-fill-toggle,
.label-groups-settings {
  width: 30px;
  height: 30px;
  padding: 0;
  color: #68707c;
  border: 1px solid #c8cdd5;
  border-radius: 5px;
  background: white;
  font-size: 16px;
  font-weight: 900;
}
.label-fill-toggle.active { color: white; border-color: var(--blue); background: var(--blue); }
.label-fill-toggle svg {
  width: 17px;
  height: 17px;
  display: block;
  margin: auto;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.2;
}
.label-number-preview {
  width: max-content;
  max-width: 100%;
  height: 30px;
  min-width: 0;
  padding: 2px 3px;
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow: hidden;
  border: 1px solid #b7bec8;
  border-radius: 5px;
  background: white;
}
.label-number-preview button {
  min-width: 24px;
  max-width: 48px;
  padding: 2px 4px;
  display: block;
  overflow: hidden;
  color: #a9afb8;
  border: 0;
  border-radius: 3px;
  background: #eef0f2;
  font-size: 10px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.label-number-preview .number-part-label {
  flex: 0 1 auto;
  overflow: hidden;
  color: #626b78;
  font-size: 7px;
  font-weight: 800;
  line-height: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.label-number-preview button strong {
  font-size: 10px;
  line-height: 20px;
}
.label-number-preview button.active { color: white; background: var(--blue); box-shadow: 0 1px 3px rgba(35,100,210,.28); }
.properties-dialog .compact-group-select {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 3px 26px 3px 8px;
  appearance: none;
  color: var(--selected-group-contrast);
  border: 2px solid color-mix(in srgb, var(--selected-group-contrast) 62%, #89919c);
  background-color: var(--selected-group-color);
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
  box-shadow:
    0 1px 3px rgba(23,32,51,.18),
    inset 0 0 0 1px color-mix(in srgb, var(--selected-group-contrast) 24%, transparent);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--selected-group-contrast) 50%),
    linear-gradient(135deg, var(--selected-group-contrast) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 12px,
    calc(100% - 9px) 12px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.properties-dialog .compact-group-select:focus {
  border-color: color-mix(in srgb, var(--selected-group-contrast) 62%, #89919c);
  outline: none;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--selected-group-contrast) 38%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--selected-group-contrast) 32%, transparent);
}
.properties-dialog .compact-group-select option {
  font-size: 9px;
}
.bracket-checkbox { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.device-geometry-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  align-items: end;
  gap: 8px;
}
.device-geometry-row label,
.module-dimensions-stack {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.module-dimensions-stack { gap: 7px; }
.device-geometry-row label > span:first-child {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.module-cross {
  min-width: 0;
  display: grid;
  grid-template-columns: 25px 48px 25px;
  grid-template-rows: 25px 39px 25px;
}
.module-cross input {
  z-index: 1;
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  height: 39px;
  padding-inline: 2px;
  border-radius: 4px;
  text-align: center;
  appearance: textfield;
}
.module-cross input::-webkit-inner-spin-button,
.module-cross input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.module-cross button {
  padding: 0;
  color: var(--blue);
  border: 1px solid #c8cdd5;
  background: white;
  font-size: 9px;
  font-weight: 900;
}
.module-cross button:hover { z-index: 2; color: white; border-color: var(--blue); background: var(--blue); }
.module-cross-quarter-up { grid-column: 2; grid-row: 1; border-radius: 5px 5px 0 0; border-bottom: 0 !important; }
.module-cross-quarter-down { grid-column: 2; grid-row: 3; border-radius: 0 0 5px 5px; border-top: 0 !important; }
.module-cross-whole-left { grid-column: 1; grid-row: 2; border-radius: 5px 0 0 5px; border-right: 0 !important; }
.module-cross-whole-right { grid-column: 3; grid-row: 2; border-radius: 0 5px 5px 0; border-left: 0 !important; }
.properties-dialog .module-preset-field select,
.properties-dialog .device-total-width-field input {
  width: 100%;
  min-width: 0;
  height: 34px;
}
.properties-dialog .module-preset-field select {
  overflow: hidden;
  padding-right: 22px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.properties-dialog .module-preset-field option {
  max-width: 360px;
  font-weight: 700;
  white-space: normal;
}
.device-characteristics-group > div:not(.property-group-title) {
  min-width: 0;
  display: grid;
  gap: 7px;
}
.device-characteristics-group > div.hidden { display: none; }
.device-characteristics-group label {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.current-section-controls {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr);
  align-items: end;
  gap: 5px;
}
.current-section-link {
  width: 30px;
  height: 30px;
  padding: 6px;
  color: #768090;
  border: 1px solid #c7ced8;
  border-radius: 6px;
  background: #fff;
}
.current-section-link svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}
.current-section-link.active {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: 0 2px 7px rgba(35,100,210,.24);
}
.properties-form input.replace-ready,
.properties-form textarea.replace-ready {
  border-color: var(--blue);
  background: linear-gradient(rgba(35, 100, 210, .13), rgba(35, 100, 210, .13)), #fff;
  box-shadow: 0 0 0 2px rgba(35, 100, 210, .18);
}
.properties-dialog .geometry-summary { padding: 7px 8px; }
.properties-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 5px; padding: 8px 10px; border-top: 1px solid var(--line); background: #fff; box-shadow: 0 -8px 22px rgba(23,32,51,.08); }
.properties-actions .btn { padding: 6px 8px; font-size: 9px; }
.properties-actions-spacer { flex: 1; }
.properties-form .mixed { color: #8b93a1; border-color: #cfd3da; background: #f4f5f7; }
@media (min-width: 561px) {
  .properties-dialog .properties-form > label:not(.checkbox-row),
  .properties-dialog .property-group > label:not(.checkbox-row) {
    grid-template-columns: 108px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
  }
  .properties-dialog .icon-picker-field {
    grid-template-columns: 108px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
  }
  .properties-dialog .icon-picker-panel { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .label-affixes-row { gap: 5px; }
  .label-numbering-row { grid-template-columns: max-content minmax(36px, 1fr) 30px; }
}
.selection-context-menu { position: fixed; z-index: 80; width: 235px; padding: 6px; border: 1px solid #aeb6c2; border-radius: 9px; background: rgba(255,255,255,.98); box-shadow: 0 18px 48px rgba(23,32,51,.24); backdrop-filter: blur(12px); }
.selection-context-heading { padding: 7px 8px 9px; border-bottom: 1px solid var(--line); }
.selection-context-heading strong, .selection-context-heading span { display: block; }
.selection-context-heading strong { font-size: 11px; }
.selection-context-heading span { margin-top: 3px; color: var(--muted); font-size: 8px; }
.selection-context-menu > button { width: 100%; padding: 8px; display: flex; justify-content: space-between; gap: 10px; color: var(--ink); border: 0; border-radius: 6px; background: transparent; font-size: 10px; font-weight: 800; text-align: left; }
.selection-context-menu > button:hover { color: var(--blue); background: var(--blue-pale); }
.selection-context-menu > button.danger { color: var(--danger); }
.selection-context-menu > button:disabled { color: #aeb4bd; cursor: not-allowed; background: transparent; }
.selection-context-menu kbd { color: var(--muted); font: 7px/1.4 inherit; }
.selection-bar {
  position: fixed;
  left: 50%;
  top: auto;
  bottom: 22px;
  z-index: 45;
  width: min(650px, calc(100vw - 150px));
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px;
  border: 1px solid #aeb6c2;
  border-radius: 11px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 14px 42px rgba(23,32,51,.24);
  backdrop-filter: blur(12px);
  translate: -50% 0;
}
.selection-bar-copy { min-width: 0; flex: 1 1 100%; }
.selection-bar-copy strong, .selection-bar-copy span { display: block; }
.selection-bar-copy strong { font-size: 11px; }
.selection-bar-copy span { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.selection-mobile-primary-actions {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.selection-mobile-primary-actions .selection-primary-action {
  width: 100%;
  height: 40px;
  padding: 5px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.selection-primary-action span {
  display: block;
  overflow: hidden;
  font-size: 8px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selection-primary-action svg { width: 15px; height: 15px; }
.selection-bar-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr) 31px;
  align-items: center;
  gap: 6px;
  padding-bottom: 2px;
}
.selection-bar-action-center {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}
.selection-bar .icon-action-btn { flex: 0 0 auto; }
@media (min-width: 851px) {
  .selection-bar {
    width: min(980px, calc(100vw - 48px));
    max-width: calc(100vw - 32px);
    min-height: 48px;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 7px 10px 7px 14px;
    border-radius: 8px;
    box-shadow: 0 9px 28px rgba(23,32,51,.18);
  }
  .selection-bar-copy { flex: 1 1 auto; }
  .selection-mobile-primary-actions {
    width: auto;
    align-self: center;
    display: flex;
    justify-content: center;
  }
  .selection-mobile-primary-actions .selection-primary-action {
    width: auto;
    min-width: 0;
    padding-inline: 12px;
  }
  .selection-bar-actions {
    width: auto;
    flex: 0 0 auto;
    grid-template-columns: 31px minmax(0, auto) 31px;
    padding-bottom: 0;
  }
  .selection-bar.selection-empty .selection-mobile-primary-actions,
  .selection-bar.selection-empty .selection-bar-actions { display: none; }
}
.confirmation-dialog { width: min(430px, calc(100vw - 28px)); }
.confirmation-content { padding: 16px; }
.confirmation-content p { margin: 0 0 16px; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.confirmation-content .dialog-actions { margin: 0; }

.workspace { grid-column: 2; grid-row: 2; min-width: 0; padding: 24px; overflow: auto; }
.workspace-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.workspace-toolbar h1 { margin-bottom: 0; white-space: nowrap; }
.workspace-toolbar-actions { display: flex; align-items: end; justify-content: flex-end; gap: 8px; }
.project-settings-button {
  min-height: 35px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: white;
}
.project-settings-button:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-pale); }
.project-settings-button span { font-size: 15px; line-height: 1; }
.project-settings-button strong { font-size: 9px; text-transform: uppercase; }
.add-rail-btn { flex: 0 0 auto; }
.rail-width-picker { position: relative; z-index: 20; }
.rail-width-picker[open] { z-index: 45; }
.rail-width-picker summary,
.rail-width-option {
  display: grid;
  align-items: center;
  gap: 9px;
}
.rail-width-picker summary { grid-template-columns: minmax(82px, .8fr) minmax(58px, .55fr); }
.rail-width-option { grid-template-columns: minmax(82px, .8fr) minmax(58px, .55fr) minmax(80px, 1fr); }
.rail-width-picker summary {
  position: relative;
  min-height: 45px;
  padding: 7px 38px 7px 11px;
  list-style: none;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(23,32,51,.05);
}
.rail-width-picker summary::-webkit-details-marker { display: none; }
.rail-width-picker summary:hover,
.rail-width-picker[open] summary { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(35,100,210,.09); }
.rail-width-picker-chevron {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform .15s ease;
}
.rail-width-picker[open] .rail-width-picker-chevron { transform: translateY(-25%) rotate(225deg); }
.rail-width-options {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  width: min(430px, calc(100vw - 42px));
  max-height: min(520px, calc(100vh - 150px));
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(23,32,51,.24);
}
.rail-width-option {
  width: 100%;
  min-height: 45px;
  padding: 6px 10px;
  color: var(--ink);
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}
.rail-width-option:hover { background: #f2f5fa; }
.rail-width-option.selected { color: var(--blue-dark); background: var(--blue-pale); }
.rail-width-option-size { display: flex; align-items: baseline; gap: 5px; }
.rail-width-option-size strong { display: inline !important; margin: 0 !important; font-size: 17px !important; line-height: 1; }
.rail-width-option-size small { color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.rail-width-option-mm { color: var(--ink-soft); font-size: 10px; font-weight: 800; white-space: nowrap; }
.paper-fit-badge {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  padding: 4px 7px;
  color: #687386;
  border: 1px solid #dfe3e9;
  border-radius: 999px;
  background: #f5f6f8;
  white-space: nowrap;
}
.paper-fit-badge strong { display: inline !important; margin: 0 !important; color: #4c5668; font-size: 9px !important; }
.paper-fit-badge.compact { gap: 4px; padding: 2px 5px; }
.paper-fit-badge.unavailable { font-size: 7px; }
.paper-orientation-icon {
  display: inline-block;
  border: 1.5px solid #7e8999;
  border-radius: 1px;
  background: #fff;
}
.paper-orientation-icon.portrait { width: 9px; height: 13px; }
.paper-orientation-icon.landscape { width: 13px; height: 9px; }
.rails-container { display: grid; gap: 17px; }
.mobile-editor-host { min-width: 0; min-height: 0; }
.mobile-editor-host:empty { display: none; }
.add-rail-bottom {
  width: 100%;
  margin: 14px 0 20px;
  padding: 12px;
  color: var(--blue);
  border: 1px dashed #8eacd9;
  background: rgba(255,255,255,.72);
  font-size: 11px;
}
.add-rail-bottom:hover { border-style: solid; background: var(--blue-pale); }

.rail-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
}
.rail-content { min-width: 0; }
.rail-tools { padding: 9px 7px; display: flex; flex-direction: column; align-items: stretch; gap: 7px; border-right: 1px solid var(--line); background: #fff; }
.rail-tools.compact { align-items: center; justify-content: center; gap: 8px; padding: 7px 5px; }
.rail-drag-handle, .rail-height-cycle, .rail-layout-cycle, .rail-action-button {
  width: 38px;
  min-height: 30px;
  padding: 4px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-weight: 900;
}
.rail-drag-handle { display: grid; place-items: center; cursor: grab; font-size: 18px; line-height: 1; }
.rail-drag-handle:active { cursor: grabbing; }
.rail-height-cycle { color: var(--ink); border-color: var(--line); background: #f8f9fb; font-size: 11px; }
.rail-height-cycle small { display: block; color: var(--muted); font-size: 7px; }
.rail-layout-cycle { color: var(--ink); border-color: var(--line); background: #f8f9fb; }
.rail-layout-cycle span { display: block; font-size: 14px; line-height: 12px; }
.rail-layout-cycle small { display: block; color: var(--muted); font-size: 6px; }
.rail-action-button { display: grid; place-items: center; }
.rail-action-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-action-button.danger { color: var(--danger); }
.rail-drag-handle:hover, .rail-height-cycle:hover, .rail-layout-cycle:hover, .rail-action-button:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-pale); }
.rail-action-button.danger:hover { color: var(--danger); border-color: #e4a099; background: #fff1ee; }
.rail-tools .rail-index { align-self: center; }
.rail-tools label { gap: 2px; }
.rail-tools label span { color: var(--muted); font-size: 7px; font-weight: 900; letter-spacing: .05em; text-align: center; text-transform: uppercase; }
.rail-tools input { padding: 5px 3px; font-size: 10px; text-align: center; }
.rail-tool-btn { padding: 6px 3px; border: 1px solid var(--line); border-radius: 5px; background: #f8f9fb; font-size: 8px; font-weight: 900; }
.rail-tool-btn:hover { color: var(--blue); border-color: var(--blue); }
.rail-tool-btn.add-device { color: #145e48; border-color: #9fd1c0; background: #edf9f4; }
.rail-tool-btn.danger { color: var(--danger); }
.rail-meta { min-height: 40px; padding: 7px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; border-bottom: 1px solid var(--line); background: white; }
.rail-card.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(35, 100, 210, .1), var(--shadow); }
.rail-card.has-overflow { border-color: #d25a42; }
.rail-card.rail-drop-before { transform: translateY(8px); border-top: 3px solid var(--blue); }
.rail-card.rail-drop-after { transform: translateY(-8px); border-bottom: 3px solid var(--blue); }
.rail-card.rail-dragging { opacity: .38; }
.rail-card { transition: transform .18s ease, opacity .14s ease, border-color .14s ease; }
.rail-header { padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fff; }
.rail-header-main { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.rail-title-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rail-index {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: white;
  border-radius: 50%;
  background: var(--ink);
  font-size: 10px;
  font-weight: 900;
}
.rail-name { min-width: 90px; padding: 5px 4px; border-color: transparent; background: transparent; font-weight: 900; }
.rail-name:hover, .rail-name:focus { border-color: var(--line); background: white; }
.rail-actions { display: flex; gap: 6px; }
.rail-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 9px 18px; margin-top: 10px; }
.rail-field { display: grid; grid-template-columns: auto 66px auto; align-items: center; gap: 6px; }
.rail-field.wide { grid-template-columns: auto 90px auto; }
.rail-field.with-action { grid-template-columns: auto 90px auto auto; }
.rail-field span { color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.rail-field input { padding: 5px 7px; font-size: 11px; }
.rail-auto-width {
  align-self: stretch;
  padding: 3px 7px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #f7f8fa;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.rail-auto-width:hover { color: var(--blue); border-color: #9cb8e7; background: var(--blue-pale); }
.rail-auto-width.active { color: #145e48; border-color: #9fd1c0; background: #e9f7f2; }
.rail-measure-row { position: relative; min-height: 52px; padding: 6px 68px 6px 8px; display: flex; align-items: center; gap: 7px; border-bottom: 1px solid var(--line); background: white; cursor: grab; }
.rail-measure-row:active { cursor: grabbing; }
.rail-length-control { position: absolute; left: 50%; display: flex; align-items: center; gap: 7px; transform: translateX(-50%); }
.rail-measure-row label { display: flex; align-items: center; gap: 5px; }
.rail-measure-row input,
.rail-measure-row select,
.rail-measure-row button { cursor: pointer; }
.rail-measure-row label span, .rail-measure-row label small { color: var(--muted); font-size: 8px; font-weight: 900; text-transform: uppercase; }
.rail-measure-row input { width: 76px; height: 25px; padding: 4px 6px; border-radius: 6px; text-align: center; font-size: 11px; font-weight: 900; }
.rail-total-length { color: var(--muted); font-size: 9px; font-weight: 800; white-space: nowrap; }
.rail-total-length strong { color: var(--ink-soft); }
.rail-measure-row .rail-auto-width { align-self: auto; height: 25px; }
.rail-metrics { display: flex; flex: 1; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.rail-metrics.floating { position: absolute; top: 5px; right: 14px; z-index: 4; pointer-events: none; }
.metric-chip { padding: 5px 7px; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 99px; background: #f7f8fa; font-size: 9px; white-space: nowrap; }
.metric-chip strong { color: var(--ink); }
.metric-chip.gap { color: #145e48; border-color: #b7dfd1; background: #edf9f4; }
.metric-chip.error { color: #9c2f1d; border-color: #f1b8ad; background: #fff1ee; }
.din-capacity-control {
  min-height: 40px;
  display: grid;
  grid-template-columns: auto minmax(205px, 260px);
  align-items: center;
  gap: 10px;
  padding: 4px 5px 4px 9px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  margin-left: auto;
}
.din-capacity-usage { display: flex; align-items: center; }
.din-capacity-usage > strong { color: var(--ink); font-size: 13px; line-height: 1.1; white-space: nowrap; }
.din-capacity-usage > strong small { color: var(--ink-soft); font-size: 9px; font-weight: 800; }
.rail-width-picker.compact { z-index: 30; }
.rail-width-picker.compact summary {
  min-height: 32px;
  padding: 4px 29px 4px 8px;
  border-radius: 6px;
  box-shadow: none;
}
.rail-width-picker.compact summary { display: flex; align-items: center; min-width: 126px; }
.rail-width-picker.compact .rail-width-option.modules-only { display: flex; align-items: center; }
.rail-width-picker.compact .rail-width-option-size strong { font-size: 13px !important; }
.rail-width-picker.compact .rail-width-option-size small { font-size: 6px; }
.rail-width-picker.compact .rail-width-option-mm { font-size: 8px; }
.rail-width-picker.compact .paper-fit-badge { gap: 4px; padding: 2px 5px; }
.rail-width-picker.compact .paper-fit-badge strong { font-size: 8px !important; }
.rail-width-picker.compact .paper-orientation-icon.portrait { width: 7px; height: 10px; }
.rail-width-picker.compact .paper-orientation-icon.landscape { width: 10px; height: 7px; }
.rail-width-picker.compact .rail-width-options {
  right: 0;
  width: min(190px, calc(100vw - 42px));
}
.rail-card:has(.rail-width-picker.compact[open]) { z-index: 35; overflow: visible; }
.din-capacity-control.error { color: #9c2f1d; border-left-color: #e7a092; background: #fff8f6; }
.rail-order-controls {
  position: absolute;
  top: 4px;
  right: 7px;
  display: flex;
  gap: 4px;
}
.rail-order-controls button {
  width: 26px;
  height: 26px;
  padding: 5px;
  color: var(--blue);
  border: 1px solid #c7ced8;
  border-radius: 6px;
  background: #fff;
}
.rail-order-controls button:hover { border-color: var(--blue); background: var(--blue-pale); }
.rail-order-controls button:disabled { opacity: .32; }
.rail-order-controls svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.rail-stage-wrap { position: relative; padding: 13px 14px 16px; overflow-x: auto; background: var(--paper); }
.rail-ruler {
  position: relative;
  height: 21px;
  border-bottom: 1px solid #aab0ba;
  background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(var(--ten-mm) - 1px), #8f97a4 calc(var(--ten-mm) - 1px), #8f97a4 var(--ten-mm));
}
.rail-ruler::before { content: "0"; position: absolute; left: 0; bottom: 3px; color: var(--muted); font-size: 8px; }
.rail-ruler::after { content: attr(data-length); position: absolute; right: 0; bottom: 3px; padding-left: 5px; color: var(--muted); background: var(--paper); font-size: 8px; }
.rail-stage {
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: flex-end;
  gap: var(--device-gap, 0px);
  width: max-content;
  min-height: calc(var(--device-shell-height, 112px) + var(--rail-label-height, 75px) + 9px);
  padding: 9px var(--edge-padding, 0) 0;
  border-radius: var(--corner-radius, 0) var(--corner-radius, 0) 0 0;
  border-bottom: 0;
  background: #f5f4ef;
  transition: background-color .16s;
}
.din-rail-profile {
  position: absolute;
  right: var(--edge-padding, 0);
  bottom: calc(var(--rail-label-height, 75px) + 1px);
  left: var(--edge-padding, 0);
  z-index: 0;
  height: 94px;
  overflow: hidden;
  border: 1px solid #727272;
  border-radius: 0;
  background: linear-gradient(
    to bottom,
    #707070 0,
    #a1a1a1 2%,
    #9d9d9d 14%,
    #f0f0f0 15%,
    #c5c5c5 18%,
    #ececec 21%,
    #9b9b9b 24%,
    #c5c5c5 29%,
    #d2d2d2 50%,
    #cecece 71%,
    #fafafa 74%,
    #b8b8b8 77%,
    #efefef 80%,
    #929292 84%,
    #9e9e9e 98%,
    #666 100%
  );
  box-shadow:
    0 5px 9px rgba(23,32,51,.3),
    0 2px 4px rgba(0,0,0,.35) inset,
    0 -2px 4px rgba(0,0,0,.3) inset;
}
.din-rail-profile::before {
  content: "";
  position: absolute;
  inset: 23px 0 20px;
  border-top: 1px solid rgba(85,85,85,.32);
  border-bottom: 1px solid rgba(255,255,255,.9);
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,.24),
    rgba(255,255,255,.04) 24%,
    rgba(0,0,0,.025) 72%,
    rgba(0,0,0,.1)
  );
  box-shadow:
    0 5px 7px rgba(0,0,0,.17) inset,
    0 -4px 6px rgba(255,255,255,.55) inset;
}
.din-rail-profile::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, transparent 13%, rgba(255,255,255,.8) 15%, transparent 18% 80%, rgba(255,255,255,.72) 81%, transparent 84%),
    linear-gradient(90deg, rgba(255,255,255,.16), transparent 4% 96%, rgba(0,0,0,.12));
  pointer-events: none;
}
.rail-stage.labels-above .din-rail-profile { bottom: 1px; }
.device-card { z-index: 1; }
.rail-stage.font-gost-a { font-family: "DejaVu Sans Condensed", sans-serif; }
.rail-stage.font-gost-b, .rail-stage.font-sans { font-family: "DejaVu Sans", sans-serif; }
.rail-stage.font-calibri { font-family: Calibri, Carlito, "Liberation Sans", sans-serif; }
.rail-stage.font-serif { font-family: "DejaVu Serif", serif; }
.rail-stage.font-mono { font-family: "DejaVu Sans Mono", monospace; }
.rail-stage.over { background-color: var(--blue-pale); }
.rail-stage.overflow { border-color: var(--danger); }
.target-marker { position: absolute; top: 0; bottom: 0; z-index: 5; width: 0; border-left: 2px dashed var(--danger); pointer-events: none; }
.target-marker span { position: absolute; top: 4px; right: 4px; padding: 2px 5px; color: white; border-radius: 3px; background: var(--danger); font-size: 8px; white-space: nowrap; }
.empty-rail { position: absolute; inset: 32px 12px 22px; display: grid; place-items: center; padding: 20px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 7px; background: rgba(255,255,255,.55); font-size: 11px; text-align: center; pointer-events: none; }
.rail-add-device-module {
  position: relative;
  box-sizing: border-box;
  z-index: 2;
  flex: 0 0 var(--module-size);
  width: var(--module-size);
  height: calc(var(--device-shell-height, 112px) + var(--rail-label-height));
  margin: 0 0 0 calc(-1 * var(--device-gap, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 4px;
  color: var(--blue);
  border: 1px dashed #6f94ca;
  border-radius: 7px;
  background: #fff;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
}
.rail-add-device-module span { font-size: 20px; line-height: 1; }
.rail-add-device-module strong { font-size: 8px; line-height: 1.2; }
.rail-add-device-module:hover { border-style: solid; background: var(--blue-pale); }

.device-card {
  --device-width: 61.2px;
  --accent: #64748b;
  flex: 0 0 var(--device-width);
  width: var(--device-width);
  min-width: 3px;
  position: relative;
  display: grid;
  grid-template-rows: var(--device-shell-height, 112px) var(--label-height);
  user-select: none;
  cursor: grab;
}
.device-card { -webkit-touch-callout: none; }
.device-multi-select-mode .device-card { cursor: cell; }
.device-multi-select-mode .device-card.selected { box-shadow: 0 0 0 3px rgba(35,100,210,.28); }
.device-card:active { cursor: grabbing; }
.device-card.dragging { opacity: .28; }
.device-card { transition: transform .2s cubic-bezier(.2,.8,.2,1), opacity .12s ease; }
.device-card.drop-shift { transform: translateX(22px); }
.device-card.drop-anchor::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 0;
  bottom: 0;
  width: 3px;
  z-index: 20;
  border-radius: 3px;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(35,100,210,.14);
}
.rail-stage.drop-at-end::after {
  content: "";
  align-self: stretch;
  flex: 0 0 18px;
  margin-left: 4px;
  border-left: 3px solid var(--blue);
  border-radius: 3px;
  box-shadow: -3px 0 0 1px rgba(35,100,210,.12);
}
.device-card.selected { z-index: 8; }
.device-card.selected .device-shell, .device-card.selected .device-label { outline: 3px solid var(--blue); outline-offset: -2px; }
.device-shell {
  position: relative;
  box-sizing: border-box;
  grid-row: 1;
  height: var(--device-shell-height, 112px);
  overflow: hidden;
  border: 1px solid #9ca3ad;
  border-bottom: 0;
  background: linear-gradient(90deg, #d7d9dc 0, #f4f4f2 12%, #e7e7e5 82%, #c8cbd0 100%);
  box-shadow: inset 0 8px 10px rgba(255,255,255,.7), inset 0 -7px 9px rgba(28,36,49,.12);
  background-position: center;
  background-size: cover;
}
.device-shell::before {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 25px;
  height: 17px;
  border: 1px solid #3c4149;
  border-radius: 2px;
  background: linear-gradient(#80858c, #262a2f);
  box-shadow: 0 4px 4px rgba(0,0,0,.25);
}
.device-shell::after { content: ""; position: absolute; inset: 8px 0 auto; height: 5px; background: var(--accent); opacity: .8; }
.device-type-code { position: absolute; left: 4px; top: 15px; max-width: calc(100% - 8px); overflow: hidden; color: #343b47; font-size: 7px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.device-pole-mark, .device-pole-seams, .device-lever-bank, .device-lever-bar, .device-state-window { display: none; }
.device-card[data-type="switch"] .device-shell::before { background: linear-gradient(#f27373, #b51f2b); }
.device-card[data-type="meter"] .device-shell::before { left: 12%; right: 12%; top: 20px; height: 28px; background: #303b47; }
.device-card[data-appearance="terminal"] .device-shell { border-color: #9c7d32; background: linear-gradient(90deg, #e8b930, #ffd95d 46%, #d69d16); box-shadow: inset 0 5px 6px rgba(255,255,255,.4); }
.device-card[data-appearance="terminal"] .device-shell::before { left: 20%; right: 20%; top: 12px; height: 21px; border: 3px solid #8a6b28; border-radius: 50%; background: #d7d9dc; box-shadow: inset 0 0 0 3px #6d737b; }
.device-card[data-appearance="terminal"] .device-shell::after { display: none; }
.device-card[data-appearance="meter"] .device-shell::before,
.device-card[data-appearance="display"] .device-shell::before { left: 13%; right: 13%; top: 18px; height: 27px; border-radius: 3px; background: linear-gradient(#b9d2c1, #617a6a); box-shadow: inset 0 0 0 3px #27352f; }
.device-card[data-appearance="relay"] .device-shell::before { left: 25%; right: 25%; top: 24px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 42% 38%, #f8f8f5 0 12%, #6c747b 14% 27%, #22272b 30%); }
.device-card[data-appearance="indicator"] .device-shell::before { left: 30%; right: 30%; top: 24px; height: auto; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff 0 8%, var(--accent) 15% 55%, #252a30 58%); }
.device-card[data-appearance="contactor"] .device-shell::before,
.device-card[data-appearance="vented"] .device-shell::before { left: 12%; right: 12%; top: 22px; height: 30px; border: 0; background: repeating-linear-gradient(90deg, #40464d 0 3px, #c4c7c8 3px 6px); box-shadow: none; }
.device-card[data-appearance="socket"] .device-shell::before { left: 20%; right: 20%; top: 20px; height: auto; aspect-ratio: 1; border: 2px solid #555c64; border-radius: 50%; background: radial-gradient(circle at 35% 45%, #222 0 5%, transparent 6%), radial-gradient(circle at 65% 45%, #222 0 5%, transparent 6%), #eee; }
.device-card[data-appearance="fuse"] .device-shell::before { left: 38%; right: 38%; top: 16px; height: 39px; border-radius: 9px; background: linear-gradient(90deg, #8a8f94, #fff 38% 62%, #8a8f94); }
.device-card[data-type="spacer"] .device-shell { border-style: dashed; background: rgba(255,255,255,.4); box-shadow: none; }
.device-card[data-type="spacer"] .device-shell::before, .device-card[data-type="spacer"] .device-shell::after { display: none; }
.device-card:not([data-type="spacer"]) .device-shell .device-type-code {
  top: 14px;
  left: 4px;
  z-index: 6;
  max-width: calc(100% - 8px);
  padding: 1px 3px;
  color: #171b21;
  border: 1px solid #9d8500;
  border-radius: 3px;
  background: #ffe31f;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  font-size: 7px;
  line-height: 10px;
}
.device-card[data-type="spacer"] .device-label { border-style: dashed; background: repeating-linear-gradient(135deg, #f3f5f7 0 7px, #fff 7px 14px); }
.device-card[data-type="spacer"] .device-number, .device-card[data-type="spacer"] .label-content { display: none; }
.device-card[data-type="spacer"] .device-label::after {
  content: "ОТСТУП";
  position: absolute;
  inset: 50% auto auto 50%;
  color: var(--muted);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: .08em;
  translate: -50% -50%;
  writing-mode: vertical-rl;
}

.device-label {
  position: relative;
  box-sizing: border-box;
  grid-row: 2;
  height: var(--label-height, 75px);
  overflow: hidden;
  border: var(--label-separator-width, 1px) solid #111827;
  background: white;
  box-shadow: inset 0 1px rgba(255,255,255,.8);
}
.rail-stage.labels-above .device-card { grid-template-rows: var(--label-height) var(--device-shell-height, 112px); }
.rail-stage.labels-above .device-label { grid-row: 1; }
.rail-stage.labels-above .device-shell { grid-row: 2; }
.device-card.full-fill .device-label { color: var(--accent-contrast); background: var(--accent); }
.device-number {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: var(--label-accent-height, 16px);
  padding: 2px 3px;
  overflow: hidden;
  color: var(--accent-contrast, white);
  background: var(--accent);
  font-size: var(--label-number-size, 8px);
  font-weight: 900;
  line-height: 12px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-number.off { color: transparent; background: var(--accent); }
.device-card.full-fill .device-number { border-bottom: 1px solid color-mix(in srgb, var(--accent-contrast) 28%, transparent); }
.device-card.full-fill .device-number.off { background: var(--accent); }
.rail-stage.labels-above .device-number { inset: auto 0 0; }
.label-content {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: calc(var(--label-accent-height, 16px) + var(--label-content-inset, 3px)) var(--label-content-inset, 3px) var(--label-content-inset, 3px);
  display: grid;
  grid-template-rows: var(--label-icon-zone-height, 34px) minmax(0, 1fr);
  align-content: start;
  justify-items: center;
}
.rail-stage.labels-above .label-content { padding: var(--label-content-inset, 3px) var(--label-content-inset, 3px) calc(var(--label-accent-height, 16px) + var(--label-content-inset, 3px)); }
.device-icon { grid-row: 1; width: var(--label-icon-size, 20px); height: var(--label-icon-size, 20px); align-self: center; display: grid; place-items: center; color: #101827; }
.device-card.full-fill .device-icon, .device-card.full-fill .label-title { color: var(--accent-contrast); }
.device-icon svg { width: 100%; height: 100%; display: block; fill: none; stroke: currentColor; stroke-width: var(--pictogram-stroke-width, 1.7); stroke-linecap: round; stroke-linejoin: round; }
.device-text { display: contents; text-align: center; }
.label-title, .label-title-line, .device-room { display: block; overflow: hidden; text-overflow: ellipsis; }
.label-title { grid-row: 2; align-self: end; width: 100%; font-size: var(--device-title-size, var(--label-title-size, 8px)); font-weight: 400; line-height: 1.1; }
.label-title-line, .device-room { white-space: nowrap; }
.device-room { grid-row: 3; align-self: start; width: 100%; color: var(--muted); font-size: var(--label-subtitle-size, 6.7px); line-height: 1.15; }
.device-card.full-fill .device-room { color: color-mix(in srgb, var(--accent-contrast) 78%, transparent); }
.device-card.narrow .device-type-code, .device-card.narrow .device-room { display: none; }
.device-card.narrow .device-icon { max-width: calc(100% - 5px); }
.rail-stage.label-height-20 .device-icon { display: none; }
.rail-stage.label-height-20 .label-content { grid-template-rows: 0 minmax(0, 1fr); }
.device-card.bracketed-label .label-title { visibility: hidden; }
.device-card.bracketed-label .device-room { display: none; }
.rail-stage.no-device-separators .device-label {
  border-color: #cbd1d9 transparent;
}
.label-bracket-overlay {
  position: absolute;
  bottom: var(--bracket-below-bottom, 20px);
  z-index: 7;
  height: auto;
  display: flex;
  align-items: flex-start;
  pointer-events: none;
}
.rail-stage.labels-above .label-bracket-overlay {
  bottom: var(--bracket-above-bottom, 112px);
}
.label-bracket-overlay i {
  flex: 1 1 auto;
  min-width: 5px;
  height: calc(var(--device-title-size, var(--label-bracket-size, 7px)) * .7);
  border-bottom: var(--label-separator-width, 1px) solid #111827;
}
.label-bracket-overlay i:first-child {
  border-left: var(--label-separator-width, 1px) solid #111827;
  border-radius: 0 0 0 7px;
}
.label-bracket-overlay i:last-child {
  border-right: var(--label-separator-width, 1px) solid #111827;
  border-radius: 0 0 7px 0;
}
.label-bracket-overlay span {
  flex: 0 1 auto;
  max-width: calc(100% - 14px);
  padding: 0 5px;
  background: white;
  font-size: var(--device-title-size, var(--label-bracket-size, 7px));
  font-weight: 400;
  line-height: 1.1;
  text-align: center;
}
.label-bracket-line { display: block; font: inherit; white-space: nowrap; }

.legend-preview { margin-top: 20px; padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.legend-preview h2 { margin-bottom: 3px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th, td { padding: 8px 9px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; color: var(--ink-soft); background: #f3f5f7; font-size: 9px; letter-spacing: .03em; text-transform: uppercase; }
td:first-child { font-weight: 900; }

.properties-form { margin-top: 12px; }
.hidden { display: none !important; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.property-group { display: grid; gap: 9px; margin-inline: -8px; padding: 10px 8px; border: 1px solid #e0e3e8; border-radius: 8px; background: #f8f9fb; }
.property-group-title { color: var(--ink); font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.group-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.group-swatch {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 2px solid white;
  border-radius: 50%;
  outline: 1px solid #bcc2cc;
  background: var(--swatch);
}
.group-swatch:hover, .group-swatch.active { outline: 3px solid var(--blue); outline-offset: 1px; }
.fill-checkbox { padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.icon-picker-field { position: relative; display: grid; gap: 5px; }
.icon-picker-toggle {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  border: 1px solid #c8cdd5;
  border-radius: 6px;
  background: white;
  text-align: left;
}
.selected-icon-preview { width: 28px; height: 28px; display: grid; place-items: center; color: var(--blue); }
.selected-icon-preview svg, .icon-choice svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: var(--pictogram-stroke-width, 1.7); stroke-linecap: round; stroke-linejoin: round; }
.icon-picker-panel {
  max-height: 410px;
  padding: 9px;
  overflow: auto;
  border: 1px solid #bfc6d0;
  border-radius: 7px;
  background: white;
  box-shadow: 0 15px 35px rgba(23,32,51,.17);
}
.icon-categories { display: grid; gap: 12px; margin-top: 9px; }
.icon-category { display: grid; gap: 6px; }
.icon-category h3 { margin: 0; color: var(--muted); font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
.icon-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.icon-choice {
  min-width: 0;
  aspect-ratio: 1;
  padding: 6px;
  color: var(--ink-soft);
  border: 1px solid #d8dce3;
  border-radius: 6px;
  background: #f8f9fb;
}
.icon-choice:hover, .icon-choice.active { color: var(--blue); border-color: var(--blue); background: var(--blue-pale); }
.icon-empty { padding: 12px; color: var(--muted); font-size: 10px; text-align: center; }
.input-with-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.input-with-action input { border-radius: 6px 0 0 6px; }
.input-with-action button { padding: 0 7px; color: var(--blue); border: 1px solid #c8cdd5; border-left: 0; border-radius: 0 6px 6px 0; background: white; font-size: 8px; font-weight: 900; }
.geometry-summary { padding: 9px; color: var(--ink-soft); border-left: 3px solid var(--blue); background: var(--blue-pale); font-size: 9px; line-height: 1.45; }
.form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.empty-state { padding: 18px; color: var(--muted); border: 1px dashed #bdc3cd; border-radius: 8px; background: #f8f9fb; font-size: 11px; line-height: 1.5; text-align: center; }
.print-help { border: 1px solid #e2c66d; border-radius: 8px; padding: 12px; background: #fffbec; }
.print-help p { margin-bottom: 0; }

.toast {
  position: fixed;
  top: 82px;
  right: auto;
  left: 50%;
  bottom: auto;
  z-index: 1000;
  max-width: min(520px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 15px;
  opacity: 0;
  pointer-events: none;
  color: white;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  box-shadow: 0 14px 38px rgba(15,23,42,.28);
  translate: -50% -18px;
  transition: opacity .2s, translate .2s;
  font-size: 11px;
}
.toast.show { opacity: 1; translate: -50% 0; }
.toast.in-dialog {
  position: absolute;
  top: 54px;
  bottom: auto;
  max-width: calc(100% - 32px);
}

@media (max-width: 1280px) {
  .app-shell { grid-template-columns: 100px minmax(0, 1fr); }
  .brand { min-width: 212px; }
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 92px minmax(0, 1fr); grid-template-rows: 68px auto auto; }
  .left-sidebar { grid-column: 1; grid-row: 2 / 4; }
  .workspace { grid-column: 2; grid-row: 2; }
}

@media (max-width: 850px) {
  .app-shell { display: block; }
  .topbar {
    position: static;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: auto auto auto;
    gap: 9px;
    padding: 10px 14px 12px;
  }
  .brand {
    grid-column: 1 / 3;
    grid-row: 1;
    min-width: 0;
  }
  .project-name-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
  }
  .project-name-wrap input { width: 100%; min-width: 0; max-width: none; }
  .top-actions { display: contents; }
  #profileBtn {
    grid-column: 3 / 5;
    grid-row: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .projects-menu-wrap { grid-column: 1; grid-row: 3; min-width: 0; }
  #newProjectBtn { grid-column: 2; grid-row: 3; }
  #saveProjectBtn { grid-column: 3; grid-row: 3; }
  #exportPdfBtn { grid-column: 4; grid-row: 3; }
  .projects-menu-wrap > .btn,
  #newProjectBtn,
  #saveProjectBtn,
  #exportPdfBtn {
    width: 100%;
    min-width: 0;
    height: 38px;
    padding-inline: 7px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .save-status {
    display: block;
    grid-column: 1 / -1;
    grid-row: 4;
    max-width: none;
    margin: -2px 0 0;
    overflow: hidden;
    color: #687386;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sidebar, .left-sidebar { width: auto; height: auto; margin: 0; border-radius: 0; }
  .left-sidebar {
    position: sticky;
    top: 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 7px;
    padding: 8px 10px;
    overflow: visible;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.96);
    box-shadow: 0 5px 16px rgba(23,32,51,.09);
  }
  .left-sidebar > .eyebrow, .sidebar-version { display: none; }
  .tool-button {
    min-width: 0;
    min-height: 46px;
    margin: 0;
    padding: 6px 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 8px;
    font-size: 9px;
  }
  .tool-icon { flex: 0 0 auto; font-size: 18px; }
  .mobile-device-order { display: inline-grid; }
  .editor-command-bar {
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }
  .editor-command-group { min-width: max-content; }
  .selection-bar {
    padding: 9px;
  }
  .workspace { padding: 13px; }
  .workspace-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .workspace-toolbar-actions { width: 100%; align-items: center; justify-content: flex-start; }
  .workspace-toolbar-actions .project-name-wrap { flex: 1; }
  .rail-header-main { align-items: flex-start; }
  .rail-metrics { flex-basis: 100%; justify-content: flex-start; }
  .selection-bar { left: 50%; width: calc(100vw - 28px); }
  .rail-length-control { position: static; transform: none; }

  body.editor-inline-open {
    height: 100dvh;
    overflow: hidden;
    background: #fff;
  }
  body.editor-inline-open .app-shell {
    height: 100dvh;
    min-height: 0;
  }
  body.editor-inline-open .topbar,
  body.editor-inline-open .left-sidebar,
  body.editor-inline-open .workspace-toolbar,
  body.editor-inline-open .add-rail-bottom,
  body.editor-inline-open .legend-preview {
    display: none;
  }
  body.editor-inline-open .workspace {
    position: fixed;
    z-index: 70;
    inset: 0;
    height: 100dvh;
    padding: 0;
    display: grid;
    grid-template-rows: clamp(190px, 26dvh, 220px) minmax(0, 1fr);
    overflow: hidden;
    background: #edf0f3;
  }
  body.editor-inline-open .rails-container {
    min-width: 0;
    min-height: 0;
    display: block;
    overflow: hidden;
  }
  body.editor-inline-open .rail-card:not(.selected) { display: none; }
  body.editor-inline-open .rail-card.selected {
    height: 100%;
    display: block;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: var(--paper);
    box-shadow: none;
  }
  body.editor-inline-open .rail-tools,
  body.editor-inline-open .rail-measure-row,
  body.editor-inline-open .empty-rail {
    display: none;
  }
  body.editor-inline-open .rail-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    overflow: hidden;
  }
  body.editor-inline-open .rail-stage-wrap {
    width: 100%;
    padding: 9px 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  body.editor-inline-open .mobile-editor-host {
    min-width: 0;
    min-height: 0;
    display: block;
    overflow: hidden;
    background: #fff;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor {
    width: 100%;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    border-width: 1px 0 0;
    border-radius: 0;
    box-shadow: 0 -8px 24px rgba(23,32,51,.12);
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .dialog-header {
    flex: 0 0 52px;
    min-height: 52px;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .properties-tabs {
    flex: 0 0 41px;
    min-height: 41px;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .editor-command-bar {
    height: 45px;
    min-height: 45px;
    flex: 0 0 45px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .panel-section {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .properties-add-tab {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .catalog-toolbar,
  body.editor-inline-open .properties-dialog.mobile-inline-editor .catalog-footer {
    flex: 0 0 auto;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .catalog-footer {
    display: none;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .catalog-scroll-region {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  body.editor-inline-open .properties-dialog.mobile-inline-editor .catalog-palette {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 9px 10px 10px; }
  .brand { gap: 8px; }
  .brand-mark { width: 37px; height: 37px; padding: 3px; }
  .brand-mark span { font-size: 10px; }
  .brand strong { font-size: 14px; }
  .brand > div:last-child span { display: none; }
  .project-name-wrap > span { display: none; }
  .project-name-wrap input { height: 39px; padding: 7px 10px; font-size: 14px; }
  #profileBtn { height: 37px; padding-inline: 7px; font-size: 10px; }
  .projects-menu-wrap > .btn,
  #newProjectBtn,
  #saveProjectBtn,
  #exportPdfBtn {
    height: 36px;
    padding-inline: 4px;
    font-size: 8.5px;
  }
  .checkbox-row span { min-width: 0; }
  .left-sidebar { gap: 5px; padding: 7px 8px; }
  .tool-button { min-height: 43px; gap: 5px; padding-inline: 3px; font-size: 8px; }
  .tool-icon { font-size: 16px; }
  .workspace-toolbar-actions { gap: 5px; }
  .workspace-toolbar-actions .project-name-wrap { min-width: 0; }
  .project-settings-button { min-width: 38px; justify-content: center; }
  .project-settings-button strong { display: none; }
  .rail-header-main { display: block; }
  .rail-actions { margin-top: 8px; }
  .rail-controls { gap: 8px; }
  .rail-field, .rail-field.wide { grid-template-columns: auto minmax(65px, 1fr) auto; flex: 1 1 100%; }
  .rail-field.with-action { grid-template-columns: auto minmax(65px, 1fr) auto auto; }
  .two-cols { grid-template-columns: 1fr; }
  .three-cols { grid-template-columns: 1fr; }
  .print-form { grid-template-columns: 1fr; }
  .print-finishing-panel { grid-column: auto; }
  .print-actions { grid-column: auto; }
  .print-actions #deletePrintProfileBtn { margin-right: 0; }
  .properties-dialog .properties-form { grid-template-columns: 1fr; }
  .properties-actions { padding: 9px; }
  .properties-actions .btn { flex: 1 1 auto; padding-inline: 7px; font-size: 9px; }
  .properties-actions-spacer { display: none; }
  .catalog-toolbar { grid-template-columns: 1fr; }
  .catalog-palette { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-form { grid-template-columns: 1fr; }
  .selection-bar { bottom: 10px; width: calc(100vw - 16px); }
  .settings-actions { grid-column: 1; }
  .legend-preview { padding: 11px; }
  .rail-card { grid-template-columns: 48px minmax(0, 1fr); }
  .rail-tools { padding-inline: 5px; }
  .rail-measure-row { flex-wrap: wrap; justify-content: flex-start; padding-left: 5px; padding-right: 66px; }
  .rail-measure-row label > span,
  .rail-total-length { display: none; }
  .rail-measure-row input { width: 50px; }
  .din-capacity-control { grid-template-columns: auto minmax(190px, 1fr); border-left: 0; }
  .projects-menu-panel { position: fixed; top: 146px; right: 10px; left: 10px; z-index: 60; width: auto; }
}

@media (min-width: 1101px) {
  body.editor-docked { height: 100vh; overflow: hidden; }
  body.editor-docked .app-shell {
    height: 100vh;
    min-height: 0;
    grid-template-columns: 112px minmax(0, 1fr) 420px;
    grid-template-rows: 68px minmax(0, 1fr);
  }
  body.editor-docked .workspace {
    grid-column: 2;
    grid-row: 2;
    height: calc(100vh - 68px);
    overflow: auto;
    overscroll-behavior: contain;
  }
  body.editor-docked .left-sidebar {
    height: calc(100vh - 68px);
    overflow-y: auto;
  }
  body.editor-docked #devicePropertiesDialog {
    position: relative;
    inset: auto !important;
    grid-column: 3;
    grid-row: 2;
    width: 100%;
    height: calc(100vh - 68px);
    max-height: none;
    margin: 0;
    border-width: 0 0 0 1px;
    border-radius: 0;
    transform: none !important;
    box-shadow: -12px 0 28px rgba(23,32,51,.1);
  }
  body.editor-docked #devicePropertiesDialog .dialog-close { display: none; }
  body.editor-docked #devicePropertiesDialog .panel-section { max-height: none; }
}

@media (min-width: 1101px) and (max-width: 1280px) {
  body.editor-docked .app-shell { grid-template-columns: 100px minmax(0, 1fr) 400px; }
}
