/* The modern dialogs (.ux-*: sign-in, plans) and the type editor of every module (.te-*:
   typeshell.js, facilityeditor.js, cost.js). Loaded by the modeller and the viewer. */
.ux-dialog {
  --ux-radius: 14px;
  --ux-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  --ux-card: var(--panel);
  --ux-field: color-mix(in srgb, var(--panel) 92%, var(--text) 8%);
  --ux-shadow: 0 24px 64px rgba(15, 23, 42, .22), 0 2px 8px rgba(15, 23, 42, .08);
  border: 0; padding: 0; background: transparent; color: var(--text); max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow: visible;
  font-size: 14px; line-height: 1.45;
}
.ux-dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); }
.ux-dialog[open] .ux-card { animation: ux-in .18s ease-out; }
@keyframes ux-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ux-dialog[open] .ux-card { animation: none; } }
.ux-card { position: relative; background: var(--ux-card); border: 1px solid var(--line); border-radius: var(--ux-radius); box-shadow: var(--ux-shadow); padding: 32px; max-height: calc(100vh - 24px); overflow: auto; box-sizing: border-box; }
.ux-sm .ux-card { width: 420px; max-width: 100%; }
.ux-xl .ux-card { width: 1000px; max-width: 100%; padding: 36px 32px 28px; }
.ux-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.ux-close:hover { background: var(--hover); color: var(--text); }
.ux-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ux-brand { width: 18px; height: 18px; flex: none; }
.ux-dialog h2 { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
.ux-dialog h3 { margin: 0; font-size: 16px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.ux-sub { margin: 6px 0 0; color: var(--muted); }
.ux-muted { color: var(--muted); }
.ux-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.ux-link:hover { text-decoration: underline; }

/* buttons */
.ux-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); background: var(--ux-field); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; box-sizing: border-box; }
.ux-btn:focus-visible { outline: none; box-shadow: var(--ux-ring); }
.ux-btn:active:not(:disabled) { transform: translateY(1px); }
.ux-btn:disabled { opacity: .55; cursor: default; }
.ux-btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.ux-btn-primary:hover:not(:disabled) { background: var(--accent-fill-hover); }
.ux-btn-dark { background: var(--text); color: var(--panel); }
.ux-btn-dark:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 85%, var(--panel)); }
.ux-btn-ghost { background: var(--ux-card); border-color: var(--line); }
.ux-btn-ghost:hover:not(:disabled) { background: var(--hover); border-color: color-mix(in srgb, var(--line) 60%, var(--text)); }
.ux-block { width: 100%; }
.ux-btn.busy { color: transparent; position: relative; }
.ux-btn.busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .7s linear infinite; }
.ux-btn-ghost.busy::after, .ux-btn-dark.busy::after { border-color: var(--line); border-top-color: var(--accent); }

.ux-callout { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 13px; }
.ux-callout.warn { background: color-mix(in srgb, #f59e0b 14%, var(--panel)); border: 1px solid color-mix(in srgb, #f59e0b 40%, transparent); }
.ux-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }

.ux-segment { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--ux-field); border: 1px solid var(--line); }
.ux-segment button { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.ux-segment button.on { background: var(--ux-card); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .14); }
.ux-segment button:focus-visible { outline: none; box-shadow: var(--ux-ring); }

/* ------------------------------------------------ type editor (typeshell.js): Edit Type, Road assemblies */
.te-dialog { font-size: 13px; }
.te-dialog .te-card { width: 1180px; max-width: 100%; height: min(780px, calc(100vh - 24px)); padding: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.te-dialog.te-narrow .te-card { width: 980px; }
.te-head { display: flex; align-items: center; gap: 14px; padding: 18px 64px 16px 24px; border-bottom: 1px solid var(--line-soft); }
.te-mark { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }
.te-mark svg { width: 26px; height: 26px; color: var(--accent); }
.te-mark:empty { display: none; }
.te-head-text { min-width: 0; }
.te-eyebrow { color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.te-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.te-dialog h2.te-title { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.te-pills { display: flex; gap: 6px; flex: none; }
.te-pill { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; font-size: 11px; }
.te-pill.qto { background: color-mix(in srgb, #16a34a 14%, var(--panel)); color: #15803d; }
.te-body { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 0; }
.with-preview .te-body { grid-template-columns: 250px minmax(0, 1fr) minmax(300px, 400px); }
.te-aside[hidden] { display: none; }

/* library */
.te-rail { display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 16px 12px 12px; border-right: 1px solid var(--line-soft); background: color-mix(in srgb, var(--panel) 96%, var(--text) 4%); }
.te-rail-label { padding: 2px 8px 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.te-list { flex: 1; min-height: 0; overflow: auto; display: grid; align-content: start; gap: 2px; }
.te-list-group { padding: 10px 8px 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
.te-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 6px 8px 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.te-item:hover { background: var(--hover); }
.te-item:focus-visible { outline: none; box-shadow: var(--ux-ring); }
.te-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.te-item-name { flex: 1; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.3; overflow-wrap: anywhere; }
.te-count { flex: none; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--line-soft); color: var(--muted); font-size: 11px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.te-item.on .te-count { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); color: var(--accent); }
.te-count.none { background: transparent; }
.te-item.sub { padding-left: 24px; min-height: 32px; }
.te-item.strong { font-weight: 650; }
.te-note { flex: none; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.te-item.on .te-note { color: var(--accent); }
.te-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #f59e0b; }
.te-rail-tools { display: flex; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.te-rail-tools .te-btn:first-child { flex: 1; }
.te-search-wrap { position: relative; }
.te-search-wrap > .ux-icon { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.te-dialog input.te-search { width: 100%; height: 34px; padding: 0 10px 0 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
.te-dialog input.te-search:focus { outline: none; border-color: var(--accent); box-shadow: var(--ux-ring); }
.te-find { max-width: 340px; }
.te-empty { padding: 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; }

/* settings */
.te-main { min-width: 0; overflow: auto; padding: 18px 22px 28px; display: grid; gap: 12px; align-content: start; scroll-padding: 20px; }
.te-section { padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.te-section[hidden] { display: none; }
.te-section-head { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.te-section-head h3 { flex: 1; font-size: 14px; }
.te-hint { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.te-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 14px; margin-top: 12px; }
.te-field { display: grid; gap: 5px; align-content: start; min-width: 0; }
.te-field[hidden] { display: none; }
.te-field.wide { grid-column: 1 / -1; max-width: 460px; }
.te-field > label { display: flex; align-items: center; gap: 6px; min-height: 20px; font-size: 12px; font-weight: 600; color: color-mix(in srgb, var(--text) 80%, var(--muted)); }
.te-label-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.te-field.changed > label::before { content: ''; width: 6px; height: 6px; flex: none; border-radius: 50%; background: #f59e0b; }
.te-dialog .te-field input[type=text], .te-dialog .te-field input[type=number], .te-dialog .te-field select {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; transition: border-color .15s, box-shadow .15s; }
.te-dialog .te-field select { padding-right: 6px; cursor: pointer; }
.te-dialog .te-field input:hover, .te-dialog .te-field select:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--text)); }
.te-dialog .te-field input:focus, .te-dialog .te-field select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ux-ring); }
.te-field.changed input[type=text], .te-field.changed select { border-color: color-mix(in srgb, #f59e0b 60%, var(--line)); }
.te-field.hl input, .te-field.hl select { border-color: var(--accent); }
.te-field.hl > label { color: var(--accent); }
.te-field.invalid input { border-color: #dc2626 !important; box-shadow: 0 0 0 3px color-mix(in srgb, #dc2626 18%, transparent) !important; }
.te-field.invalid::after { content: attr(data-error); color: #dc2626; font-size: 11px; }
.te-unit { position: relative; }
.te-unit input { padding-right: 40px !important; }
.te-dialog .te-field input.num { text-align: right; }
.te-unit.with-prefix input { padding-left: 34px !important; }
.te-dialog .te-unit.with-prefix:not(:has(.te-unit-text)) input { padding-right: 10px !important; text-align: left; }
.te-prefix-text { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
.te-unit-text { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
.te-readout { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 6px; height: 36px; padding: 0 10px; border-radius: 8px; background: var(--ux-field); color: var(--muted); font-variant-numeric: tabular-nums; }
.te-readout .te-unit-text { position: static; transform: none; }
.te-icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.te-icon-btn .ux-icon { width: 16px; height: 16px; }
.te-icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.te-icon-btn:focus-visible { outline: none; box-shadow: var(--ux-ring); }
.te-icon-btn:disabled { opacity: .35; cursor: default; }
.te-icon-btn.danger:hover:not(:disabled) { color: #dc2626; background: color-mix(in srgb, #dc2626 10%, var(--panel)); }
.te-rail-tools .te-icon-btn { width: 36px; height: 36px; border: 1px solid var(--line); }
.te-reset { width: 20px; height: 20px; margin-left: auto; border-radius: 6px; }
.te-reset .ux-icon { width: 13px; height: 13px; }
.te-switch { display: inline-flex; align-items: center; gap: 10px; height: 36px; cursor: pointer; font-weight: 500; }
.te-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.te-switch-track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--line); transition: background .15s; }
.te-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.te-switch input:checked + .te-switch-track { background: var(--accent-fill); }
.te-switch input:checked + .te-switch-track::after { transform: translateX(16px); }
.te-switch input:focus-visible + .te-switch-track { box-shadow: var(--ux-ring); }
.te-pset { margin-top: 12px; padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--panel) 96%, var(--text) 4%); }
.te-pset-head { display: flex; align-items: center; gap: 8px; }
.te-pset .te-fields { margin-top: 8px; }
.te-section .te-empty { margin-top: 12px; grid-column: 1 / -1; }
.te-btn { height: 36px; padding: 0 14px; border-radius: 9px; font-size: 13px; gap: 6px; }
.te-btn .ux-icon { width: 16px; height: 16px; }
.te-section-head .te-btn { height: 30px; padding: 0 10px; }

/* preview */
.te-aside { min-width: 0; overflow: auto; padding: 16px; border-left: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 10px; background: color-mix(in srgb, var(--panel) 96%, var(--text) 4%); }
.te-aside-head { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.te-diagram.td-diagram { position: static; padding: 0; border: 0; background: transparent; gap: 10px; }
.te-diagram .td-view { border-radius: 10px; border-color: var(--line); }

/* footer */
.te-foot { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-top: 1px solid var(--line-soft); }
.te-status { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.te-status.dirty { color: var(--text); }
.te-status.dirty::before { content: ''; width: 8px; height: 8px; flex: none; border-radius: 50%; background: #f59e0b; }
.te-status.warn { color: color-mix(in srgb, #b45309 85%, var(--text)); font-weight: 600; }
.te-status.error { color: #dc2626; font-weight: 600; }
.te-actions { display: flex; gap: 8px; }
.te-actions .te-btn { height: 38px; min-width: 84px; }
@media (max-width: 1080px) {
  .with-preview .te-body { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .with-preview .te-aside { display: none; }
}
@media (max-width: 720px) {
  .te-dialog .te-card { height: calc(100vh - 24px); }
  .te-body, .with-preview .te-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .te-rail { max-height: 34vh; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .te-main { padding: 16px; }
  .te-head { padding: 14px 56px 12px 16px; }
  .te-foot { flex-wrap: wrap; padding: 12px 16px; }
}

.te-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.te-section-head .te-inline .te-btn { height: 30px; padding: 0 10px; font-size: 12px; }
.te-road-head { grid-template-columns: minmax(0, 1fr); }
.te-road-preview .road-svg { border-radius: 10px; border-color: var(--line); }
.te-road-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.te-road-parts { display: grid; gap: 10px; margin-top: 12px; }
.te-part { padding: 10px 12px 12px; border-radius: 10px; background: color-mix(in srgb, var(--panel) 96%, var(--text) 4%); border: 1px solid var(--line-soft); }
.te-part-head { display: flex; align-items: center; gap: 8px; }
.te-part-no { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.te-part .te-fields { margin-top: 8px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.te-dialog select.te-add-part { height: 36px; padding: 0 10px; border: 1px dashed var(--line); border-radius: 8px; background: transparent; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.te-dialog select.te-add-part:hover { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 900px) { .te-road-sides { grid-template-columns: minmax(0, 1fr); } }

.te-fac-place { width: 100%; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
.te-fac-place[hidden] { display: none; }
.te-fac-section { display: grid; gap: 8px; }
.te-fac-section .road-svg { border-radius: 10px; border-color: var(--line); }
.te-fac-section .bridge-legend { margin-top: 0; font-size: 11px; gap: 4px 12px; }
.te-facts { margin-top: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
.te-facts .te-readout { justify-content: flex-start; color: var(--text); height: 32px; }
.te-fac-notes { display: grid; gap: 6px; }
.te-fac-notes .ux-callout { padding: 8px 10px; font-size: 12px; line-height: 1.4; }
.te-fac-notes:empty { display: none; }
.te-dialog .te-field input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.te-actions .te-btn .ux-icon { display: none; }


/* ------------------------------------------------ Bill of Quantities (cost.js) */
.te-head .te-segment { margin-left: auto; flex: none; }
.te-cost .te-head-text { flex: 1; min-width: 0; }
.te-segment button { height: 32px; font-size: 13px; }
.te-stats { display: grid; grid-template-columns: 2fr repeat(3, minmax(0, 1fr)); gap: 10px; }
.te-stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); min-width: 0; }
.te-stat.main { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.te-stat.warn { border-color: color-mix(in srgb, #f59e0b 50%, var(--line)); background: color-mix(in srgb, #f59e0b 8%, var(--panel)); }
.te-stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.te-stat-value { margin-top: 2px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.te-stat.main .te-stat-value { font-size: 24px; color: var(--accent); }
.te-subtotal { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.te-chapter { scroll-margin-top: 8px; }
.te-lines { display: grid; margin-top: 8px; }
.te-line { display: grid; grid-template-columns: minmax(0, 1fr) 130px 170px 130px 40px; align-items: center; gap: 12px; padding: 8px 8px; border-radius: 8px; cursor: pointer; }
.te-line + .te-line { border-top: 1px solid var(--line-soft); }
.te-line:hover { background: var(--hover); }
.te-line:focus-visible { outline: none; box-shadow: var(--ux-ring); }
.te-line.active { background: var(--accent-soft); }
.te-line-head { cursor: default; padding-top: 0; padding-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.te-line-head:hover { background: transparent; }
.te-line .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.te-line-text { display: grid; gap: 2px; min-width: 0; }
.te-line-code { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.te-line-desc { font-weight: 600; }
.te-line-split { margin-left: 8px; color: var(--muted); font-weight: 400; }
.te-line-srcs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.te-src { padding: 1px 8px; border-radius: 999px; background: var(--line-soft); color: var(--muted); font-size: 11px; font-weight: 600; }
.te-src.geo { background: color-mix(in srgb, #f59e0b 14%, var(--panel)); color: #a16207; }
.te-src.warn { background: color-mix(in srgb, #dc2626 12%, var(--panel)); color: #b91c1c; }
.te-u { color: var(--muted); }
.te-amount { font-weight: 650; }
.te-line-n { color: var(--muted); font-size: 12px; text-align: right; }
.te-boq-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.te-boq-bar .te-field { min-width: 220px; }
.te-line-code { display: flex; align-items: center; gap: 4px; }
.te-line-toggle { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-left: -4px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.te-line-toggle:hover { background: var(--line-soft); color: var(--text); }
.te-line-toggle .ux-icon { width: 14px; height: 14px; transform: rotate(-90deg); transition: transform .12s; }
.te-line-toggle.open .ux-icon { transform: none; }
.te-line.te-line-el { padding-top: 4px; padding-bottom: 4px; padding-left: 28px; font-size: 12px; }
.te-line + .te-line.te-line-el { border-top: 0; }
.te-line-el .te-line-text { color: var(--muted); }
.te-dialog .te-rate input { width: 100%; height: 34px; padding-left: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; text-align: right; font-variant-numeric: tabular-nums; }
.te-dialog .te-rate input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ux-ring); }
.te-rate .te-unit-text { font-size: 11px; }
.te-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.te-chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.te-chip-btn .ux-icon { width: 14px; height: 14px; color: var(--muted); }
.te-chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.te-warn-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 1px solid color-mix(in srgb, #f59e0b 45%, transparent); border-radius: 10px; background: color-mix(in srgb, #f59e0b 10%, var(--panel)); color: color-mix(in srgb, #b45309 85%, var(--text)); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.te-warn-btn .ux-icon { width: 16px; height: 16px; }
.te-prose { display: grid; gap: 8px; margin-top: 8px; color: var(--muted); }
.te-prose p { margin: 0; }
.te-cost .ux-error { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, #dc2626 10%, var(--panel)); color: #b91c1c; }
@media (max-width: 900px) {
  .te-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .te-line { grid-template-columns: minmax(0, 1fr) 110px 140px; }
  .te-line > :nth-child(4), .te-line > :nth-child(5) { display: none; }
}

/* Layered types: the stack in section and one row per layer (web/src/layers.js). */
.te-layer-summary { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.te-layer-pic-wrap { grid-column: 1 / -1; padding: 8px; border-radius: 10px; background: color-mix(in srgb, var(--panel) 94%, var(--text) 6%); color: var(--muted); }
.te-layer-pic { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; }
.te-layer-pic rect { transition: opacity .12s; }
.te-layer-pic rect.hl { stroke: var(--accent); stroke-width: 2.5; }
.te-layer-rows { grid-column: 1 / -1; display: grid; gap: 6px; }
.te-layer-row { display: grid; grid-template-columns: 18px minmax(140px, 1.6fr) minmax(92px, .7fr) minmax(110px, .9fr) auto; gap: 8px; align-items: center; }
.te-layer-row.head { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.te-layer-row select, .te-layer-row input { width: 100%; min-width: 0; }
.te-layer-row .te-unit input { padding-right: 2.6em !important; }
.te-swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--text) 30%, transparent); }
.te-layer-tools { display: flex; gap: 2px; }
.te-layer-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.te-layer-empty { grid-column: 1 / -1; }
.te-hatch-preview { display: block; width: 100%; max-width: 220px; margin: 8px auto; }
@media (max-width: 640px) {
  .te-layer-row { grid-template-columns: 18px 1fr 84px; }
  .te-layer-row > select:nth-of-type(2), .te-layer-row .te-layer-tools { grid-column: 2 / -1; }
  .te-layer-row.head { display: none; }
}
