/* RIP Map Gen — warm dark theme (research/webapp/ux.md design system) */
:root {
  --bg: #121110;
  --surface: #1a1816;
  --surface-2: #23201d;
  --surface-3: #2b2723;
  --border: #2e2a26;
  --border-strong: #403a34;
  --text: #ece7e1;
  --muted: #a39a90;
  --subtle: #7b7268;
  --accent: #ce422b;
  --accent-hover: #e0533a;
  --accent-soft: rgba(206, 66, 43, 0.14);
  --accent-text: #f0866f;
  --focus: #f08a4b;
  --success: #6bbf59;
  --success-soft: rgba(107, 191, 89, 0.13);
  --warning: #e3a33b;
  --warning-soft: rgba(227, 163, 59, 0.12);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.13);
  --info: #5a9bd5;
  --info-soft: rgba(90, 155, 213, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --ctl: 36px;
  --sidebar-w: 232px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/20px var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.small { font-size: 12.5px; line-height: 18px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.warn-text { color: var(--warning); }
.ok-text { color: var(--success); display: flex; align-items: center; gap: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(206, 66, 43, 0.4); }

.icon { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; }
.spinner {
  display: inline-block; width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid rgba(236, 231, 225, 0.2); border-top-color: var(--accent-text); animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 12px; height: 12px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } * { scroll-behavior: auto !important; } }

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 8px; }

/* ------------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, #161412 calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px) var(--sidebar-w), transparent var(--sidebar-w)); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: #161412; border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--text); font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--surface-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-link[aria-current="page"] .icon { color: var(--accent-text); }
.sidebar-foot { margin-top: auto; padding: 8px 10px 0; }
.server-line { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.server-line:hover { color: var(--text); text-decoration: none; }

.run-pill-slot:empty { display: none; }
.run-pill-slot { margin-top: 14px; }
.run-pill {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
}
.run-pill:hover { border-color: var(--accent); text-decoration: none; }
.run-pill-top { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--accent-text); text-transform: uppercase; letter-spacing: 0.04em; }
.run-pill-more { margin-left: auto; font-family: var(--mono); color: var(--muted); font-weight: 500; }
.run-pill-short { display: none; }
.run-pill-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-pill-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { padding: 32px 40px 64px; min-width: 0; outline: none; }
.main.has-gen-bar { padding-bottom: 120px; }
.page-head { margin-bottom: 24px; display: flex; flex-direction: column; gap: 6px; max-width: 1080px; }
.page-head.row { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .muted { max-width: 640px; }
.page-title { font-size: 24px; line-height: 32px; font-weight: 650; letter-spacing: -0.015em; }
.page-loading { display: flex; align-items: center; gap: 12px; padding: 40px 0; }
.page-loading.boot { justify-content: center; min-height: 80vh; }
.boot-error { max-width: 420px; margin: 20vh auto; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; padding: 0 16px; }
.noscript { padding: 40px; text-align: center; }

/* ------------------------------------------------------------------ cards / basic components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-title { font-size: 16px; line-height: 24px; font-weight: 600; }
.card-title.lg { font-size: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--ctl); padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-3); border-color: #4d463f; text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn[aria-disabled="true"]:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary.has-issues { background: var(--surface-3); border-color: var(--warning); color: var(--warning); }
.btn.primary.has-issues:hover { background: #352d22; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-fill:hover { background: #f05a5f; }
.btn.danger-text { color: #ff7b7f; }
.btn.danger-text:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn.icon-only { width: var(--ctl); padding: 0; }
.btn.roll .icon { animation: roll 0.45s ease; }
@keyframes roll { 50% { transform: rotate(180deg) scale(0.85); } 100% { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; flex: none;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 26px; height: 26px; }
.link-btn { background: none; border: none; padding: 0; color: var(--accent-text); cursor: pointer; font-weight: 550; }
.link-btn:hover { text-decoration: underline; }
.link-btn.sm { font-size: 12.5px; }
.link-btn.danger { color: #ff7b7f; }
.link { display: inline-flex; align-items: center; gap: 2px; font-weight: 550; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent; flex: none;
}
.badge-success { background: var(--success-soft); color: #8fd47f; }
.badge-info { background: var(--info-soft); color: #8cbbe6; }
.badge-warning { background: var(--warning-soft); color: #f0bd63; }
.badge-danger { background: var(--danger-soft); color: #ff8589; }
.badge-neutral { background: var(--surface-3); color: var(--muted); }
.badge-outline { border-color: var(--border-strong); color: var(--subtle); border-style: dashed; }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-link:hover { text-decoration: none; background: rgba(206, 66, 43, 0.25); }
.badge-try { background: var(--success-soft); color: #9bdc8c; }
.badge-try.badge-link:hover { background: rgba(107, 191, 89, 0.22); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--subtle); }
.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-danger { background: var(--danger); }
.dot-neutral { background: var(--subtle); }

.callout {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; border: 1px solid; line-height: 20px;
}
.callout > .icon { margin-top: 2px; }
.callout.small { padding: 10px 12px; font-size: 13px; line-height: 19px; }
.callout.info { background: var(--info-soft); border-color: rgba(90, 155, 213, 0.3); color: #c8def2; }
.callout.info > .icon { color: var(--info); }
.callout.warning { background: var(--warning-soft); border-color: rgba(227, 163, 59, 0.35); color: #f3dcb2; }
.callout.warning > .icon { color: var(--warning); }
.callout.danger { background: var(--danger-soft); border-color: rgba(229, 72, 77, 0.38); color: #f8c9cb; }
.callout.danger > .icon { color: var(--danger); }
.callout.neutral { background: var(--surface); border-color: var(--border-strong); }
.callout.big { padding: 20px; gap: 14px; max-width: 760px; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout a { color: inherit; text-decoration: underline; }
.callout-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.error-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; color: #ffd1d3; }

/* forms */
.label { display: block; font-weight: 550; margin-bottom: 6px; color: var(--text); }
.help { color: var(--muted); font-size: 12.5px; line-height: 18px; margin-top: 6px; }
.help.strong-help { color: #c9c0b5; font-size: 13px; }
.field-error { color: #ff8589; font-size: 12.5px; line-height: 18px; margin-top: 6px; }
.input {
  width: 100%; height: var(--ctl); padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: #141210; color: var(--text); font: inherit; transition: border-color 0.12s, box-shadow 0.12s;
}
.input.mono { font-family: var(--mono); font-size: 13.5px; }
.input::placeholder { color: var(--subtle); }
.input:hover { border-color: #4d463f; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(240, 138, 75, 0.2); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input.sm { height: 30px; font-size: 13px; }
select.input { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-addon { position: absolute; right: 3px; top: 2px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.input-unit { position: relative; max-width: 180px; }
.input-unit .input { padding-right: 32px; }
.input-unit .unit { position: absolute; right: 12px; top: 8px; color: var(--subtle); font-family: var(--mono); font-size: 13px; pointer-events: none; }
.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; margin: 12px 0; }
.check-row.small { margin: 0; font-size: 13px; color: var(--muted); }
.check-row.disabled { opacity: 0.5; cursor: not-allowed; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 550; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.chip:hover { color: var(--text); border-color: #554d45; }
.chip[aria-pressed="true"] { background: var(--surface-3); color: var(--text); border-color: var(--muted); }
.chip-try[aria-pressed="true"] { border-color: var(--success); color: #9bdc8c; background: var(--success-soft); }
.chip-avoid[aria-pressed="true"] { border-color: var(--danger); color: #ff8b8f; background: var(--danger-soft); }
.chip-count { font-family: var(--mono); font-size: 11.5px; color: var(--subtle); }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: #141210; border: 1px solid var(--border-strong); border-radius: 10px; flex: none; }
.seg-btn {
  height: 30px; padding: 0 14px; border-radius: 7px; border: none; background: transparent; color: var(--muted);
  font-weight: 550; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.seg-btn:hover { color: var(--text); background: var(--surface-2); }
.seg-btn[aria-checked="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 0 0 1px #4a433c; }
.seg.sm .seg-btn { height: 26px; padding: 0 10px; font-size: 13px; }
.seg.xs { padding: 2px; border-radius: 8px; }
.seg.xs .seg-btn { height: 24px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.seg-btn.seg-avoid[aria-checked="true"] { background: var(--danger-soft); color: #ff8b8f; box-shadow: inset 0 0 0 1px rgba(229, 72, 77, 0.55); }
.seg-btn.seg-try[aria-checked="true"] { background: var(--success-soft); color: #9bdc8c; box-shadow: inset 0 0 0 1px rgba(107, 191, 89, 0.55); }
/* Default + custom prefab = Try automatically: Default stays selected (outlined), Try is tinted and marked "auto" */
.seg.auto-try .seg-btn[aria-checked="true"]:not(.seg-try) { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px #4a433c; }
.seg.auto-try .seg-btn.seg-try { color: #9bdc8c; background: rgba(107, 191, 89, 0.08); box-shadow: inset 0 0 0 1px rgba(107, 191, 89, 0.4); gap: 5px; }
.seg.auto-try .seg-btn.seg-try::after { content: "auto"; }
.seg.auto-try .seg-btn.seg-try::after, .auto-mark {
  display: inline-block; padding: 0 4px; border-radius: 4px; background: rgba(107, 191, 89, 0.2); color: #b5e6a8;
  font-size: 9.5px; line-height: 14px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; vertical-align: 1px;
}
#f-flatten .seg-btn { min-width: 74px; justify-content: center; }

/* switch */
.switch {
  position: relative; width: 38px; height: 22px; border-radius: 999px; border: 1px solid var(--border-strong); background: #3a342e;
  cursor: pointer; padding: 0; flex: none; transition: background 0.15s;
}
.switch-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #d8d0c6; transition: transform 0.15s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(16px); background: #fff; }
.switch-wrap { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.switch-state { font-size: 12.5px; color: var(--muted); min-width: 26px; text-align: right; }

/* range */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; --c: var(--accent); }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--c); margin-top: -6px; border: 2px solid #fff3; box-shadow: 0 1px 3px #0008; }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 2px solid #fff3; }
.range:focus-visible { outline-offset: 0; }
.range.dim { opacity: 0.45; }
.range-wrap { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.range-val { min-width: 44px; text-align: right; color: var(--text); }

/* bars */
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; width: 100%; }
.bar.sm { height: 4px; }
.bar.lg { height: 10px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #e87a4a); border-radius: inherit; transition: width 0.6s ease; }
.mini-bar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--surface-3); width: 100%; }
.mini-bar.lg { height: 10px; }
.mini-bar span { height: 100%; }
.mini-bar span + span { box-shadow: -1px 0 0 var(--surface); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--surface-3);
  border: 1px solid var(--border-strong); font-family: var(--mono); font-size: 12px; color: #d6cec4;
}
.tag.removable { padding-right: 2px; }
.tag-x { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border: none; background: none; color: var(--muted); border-radius: 4px; cursor: pointer; }
.tag-x:hover { background: var(--danger-soft); color: #ff8b8f; }

/* ------------------------------------------------------------------ dialogs, sheet, menu, toasts */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(8, 7, 6, 0.66); backdrop-filter: blur(2px); }
.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 22px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--surface); box-shadow: var(--shadow);
}
.dialog-title { font-size: 17px; line-height: 24px; font-weight: 600; margin-bottom: 8px; }
.dialog-body { color: var(--muted); }
.dialog .input { margin-top: 2px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.dialog[open] { animation: pop 0.14s ease-out; }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } }

.sheet {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(620px, 100vw); padding: 0; border: none; border-left: 1px solid var(--border-strong);
  background: var(--surface); box-shadow: var(--shadow); display: none; flex-direction: column;
}
.sheet[open] { display: flex; animation: slidein 0.18s ease-out; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0.4; } }
.sheet-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.sheet-title { font-size: 17px; font-weight: 600; line-height: 24px; }
.sheet-body { flex: 1; overflow: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.sheet-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.sheet-tray { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; max-height: 180px; overflow: auto; flex: none; }
.tray-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-filters { display: grid; grid-template-columns: 1fr 210px; gap: 8px; flex: none; }
.list-meta { display: flex; justify-content: space-between; align-items: center; flex: none; }
.check-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex: none; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; cursor: pointer; border-top: 1px solid var(--border); }
.check-item:first-child { border-top: none; }
.check-item:hover { background: var(--surface-2); }
.check-item:has(input:checked) { background: rgba(229, 72, 77, 0.07); }
.check-main { display: flex; flex-direction: column; min-width: 0; }
.check-main .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu {
  position: absolute; z-index: 60; min-width: 220px; padding: 5px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 7px; border: none; background: none;
  color: var(--text); text-align: left; cursor: pointer; white-space: nowrap; font-size: 13.5px;
}
.menu-item .icon { color: var(--muted); }
.menu-item:hover, .menu-item:focus { background: var(--surface-3); outline: none; text-decoration: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.menu-item.danger, .menu-item.danger .icon { color: #ff7b7f; }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border-strong); margin: 4px 2px; }

.toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(460px, calc(100vw - 32px)); padding: 10px 8px 10px 14px;
  border-radius: 10px; background: #2d2925; border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  transform: translateY(8px); opacity: 0; transition: transform 0.18s, opacity 0.18s; line-height: 19px;
}
.toast.in { transform: none; opacity: 1; }
.toast > span:nth-child(2) { flex: 1; }
.toast-success > .icon { color: var(--success); }
.toast-error { border-color: rgba(229, 72, 77, 0.5); }
.toast-error > .icon { color: var(--danger); }
.toast-warning > .icon { color: var(--warning); }
.toast-info > .icon { color: var(--info); }

/* ------------------------------------------------------------------ login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(ellipse at 50% -10%, rgba(206, 66, 43, 0.14), transparent 55%), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px 24px; box-shadow: var(--shadow); }
.login-brand { margin-bottom: 18px; }
.login-brand img { border-radius: 10px; }
.login-title { font-size: 22px; font-weight: 650; letter-spacing: -0.015em; line-height: 30px; }
.login-sub { margin: 4px 0 22px; }
.login-card .callout { margin-bottom: 16px; }
.login-card .btn.block { margin-top: 4px; }
.login-note { margin-top: 18px; text-align: center; }

/* ------------------------------------------------------------------ generate */
.gen-layout { display: grid; grid-template-columns: minmax(0, 760px) 320px; gap: 24px; align-items: start; }
.gen-form, .gen-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.preset-bar { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.preset-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.preset-row-2 { justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--border); }
.preset-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--subtle); font-weight: 600; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.preset-chip { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; }
.preset-chip.active { border-color: var(--accent); background: var(--accent-soft); }
.preset-btn { height: 30px; padding: 0 12px; border: none; background: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 550; color: var(--muted); }
.preset-chip.active .preset-btn { color: var(--text); }
.preset-chip.active .preset-btn .icon { color: var(--accent-text); }
.preset-btn:hover { color: var(--text); }
.preset-del { height: 30px; width: 28px; border: none; background: none; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border-left: 1px solid rgba(206, 66, 43, 0.4); }
.preset-del:hover { color: #ff8b8f; background: var(--danger-soft); }
.dirty { display: inline-flex; align-items: center; gap: 8px; color: #f0c27a; font-size: 13px; flex-wrap: wrap; }
.dirty .link-btn { font-size: 13px; }
.dirty.loaded { color: #cfc6bb; }
.dirty.loaded .icon { color: var(--subtle); }

.essentials { display: flex; flex-direction: column; gap: 18px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; }
.field .chips { margin-top: 8px; }
.size-info { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.size-info > span { display: inline-flex; align-items: center; gap: 6px; }
.inline-warn { flex-basis: 100%; display: flex; gap: 6px; align-items: flex-start; color: var(--warning); }
.inline-warn .icon { margin-top: 2px; }

.section { padding: 0; overflow: hidden; }
.section.has-issue { border-color: rgba(227, 163, 59, 0.6); }
.section-head {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 20px; border: none; background: none; cursor: pointer; text-align: left;
}
.section-head:hover { background: rgba(255, 255, 255, 0.015); }
.section-head:focus-visible { outline-offset: -2px; border-radius: var(--radius); }
.section-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.section.open .section-icon { color: var(--accent-text); }
.section-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.section-title { font-size: 15.5px; font-weight: 600; line-height: 22px; }
.section-summary { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section.has-issue .section-summary { color: var(--warning); }
.section-chev { color: var(--subtle); transition: transform 0.15s; display: inline-flex; }
.section.open .section-chev { transform: rotate(180deg); }
.section-body { padding: 4px 20px 20px; border-top: 1px solid var(--border); }
.section-intro { margin: 14px 0 6px; font-size: 13px; }
.rows { display: flex; flex-direction: column; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 0; border-top: 1px solid var(--border); }
.rows > .toggle-row:first-child { border-top: none; }
.toggle-row.flush { border-top: none; padding-top: 4px; }
.toggle-row.wrap { flex-wrap: wrap; }
.row-text { min-width: 0; flex: 1 1 260px; }
.row-label { font-weight: 550; display: block; }
.row-help { color: var(--muted); font-size: 12.5px; line-height: 18px; margin-top: 2px; }
.ctl-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.amount-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.amount { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.amount .field-error { grid-column: 1 / -1; margin-top: 0; }
.amount-ctl { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.amt-meta { display: flex; gap: 8px; align-items: center; height: 16px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; background: #141210; overflow: hidden; }
.step-btn { width: 30px; height: 30px; border: none; background: none; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.step-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.step-btn:disabled { opacity: 0.35; cursor: default; }
.stepper-input { width: 42px; height: 30px; border: none; border-radius: 0; text-align: center; padding: 0; background: transparent; }
.stepper-input:focus { box-shadow: inset 0 0 0 2px var(--focus); }
.amt-tag { font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.amt-tag.is-vanilla { color: var(--subtle); }
.amt-tag.is-none { color: #ff8b8f; }
.amt-tag.is-changed { color: var(--accent-text); font-family: var(--mono); }
.amount.changed .row-label { color: #fff; }

details.advanced { margin-top: 10px; border-top: 1px solid var(--border); }
details.advanced > summary, details.history > summary, details.mon-index > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 14px 0 6px; font-weight: 550; color: var(--muted);
}
details > summary::-webkit-details-marker { display: none; }
details.advanced > summary:hover, details.history > summary:hover { color: var(--text); }
.adv-chev { transition: transform 0.15s; }
details[open] > summary .adv-chev { transform: rotate(90deg); }

.alloc-stack { display: flex; flex-direction: column; gap: 6px; }
.alloc-block { padding: 14px 0 6px; }
.alloc-block + .alloc-block { border-top: 1px solid var(--border); }
.vanilla-line { margin-top: -4px; }
.alloc-editor { background: #161412; border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-top: 6px; }
.alloc-bar { display: flex; height: 14px; border-radius: 6px; overflow: hidden; background: var(--surface-3); margin-bottom: 12px; }
.alloc-seg { height: 100%; transition: width 0.15s; }
.alloc-seg + .alloc-seg { box-shadow: -2px 0 0 #161412; }
.alloc-seg.empty { background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(227, 163, 59, 0.25) 5px 8px); }
.alloc-rows { display: flex; flex-direction: column; gap: 6px; }
.alloc-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 84px; align-items: center; gap: 14px; }
.alloc-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.pct-wrap { position: relative; }
.pct-input { height: 32px; padding-right: 26px; text-align: right; }
.pct-wrap .unit { position: absolute; right: 10px; top: 7px; color: var(--subtle); font-family: var(--mono); font-size: 13px; pointer-events: none; }
.alloc-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.alloc-actions { display: flex; gap: 12px; align-items: center; }
.alloc-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.alloc-status.ok { color: var(--success); }
.alloc-status.warn { color: var(--warning); }
.alloc-status.bad { color: #ff7b7f; }

.mon-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 8px; }
.mon-toolbar .input { width: 200px; flex: 1 1 160px; max-width: 260px; }
.mon-toolbar .btn { margin-left: auto; }
.mon-groups { display: flex; flex-direction: column; }
.mon-group { border-top: 1px solid var(--border); }
.group-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px 2px; background: none; border: none; cursor: pointer; text-align: left; }
.group-head:disabled { cursor: default; }
.group-head:disabled .group-chev { visibility: hidden; }
.group-chev { color: var(--subtle); display: inline-flex; transition: transform 0.15s; }
.group-head[aria-expanded="true"] .group-chev { transform: rotate(90deg); }
.group-title { font-weight: 600; }
.group-counts { margin-left: auto; display: flex; gap: 8px; font-size: 12.5px; font-weight: 600; }
.group-help { margin: -6px 0 6px 26px; }
.count-try { color: #8fd47f; }
.count-avoid { color: #ff8589; }
.mon-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; padding: 0 0 14px; }
/* When the name (at its narrowest: the custom-prefab badge or the longest word) and the control don't fit side by side,
   the control drops below the name, right-aligned, instead of painting over the badge. */
.mon-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; padding: 6px 6px 6px 12px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border); min-height: 40px;
}
.mon-row .seg { margin-left: auto; }
.mon-row.is-try { border-color: rgba(107, 191, 89, 0.45); background: linear-gradient(90deg, rgba(107, 191, 89, 0.09), var(--surface-2) 70%); }
.mon-row.is-avoid { border-color: rgba(229, 72, 77, 0.45); background: linear-gradient(90deg, rgba(229, 72, 77, 0.09), var(--surface-2) 70%); }
.mon-row.is-auto-try { border-color: rgba(107, 191, 89, 0.28); background: linear-gradient(90deg, rgba(107, 191, 89, 0.05), var(--surface-2) 70%); }
.mon-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1 1 0; min-width: min-content; }
.mon-label { font-weight: 500; font-size: 13.5px; }
.mon-row.is-avoid .mon-label { color: #f3c2c4; }
.mon-note { font-size: 11.5px; color: var(--warning); }
.mon-note:empty { display: none; }
.empty-inline { padding: 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }

.prefab-scope { display: flex; gap: 6px; align-items: flex-start; }
.prefab-scope .icon { margin-top: 2px; color: var(--subtle); }
.status-block { margin-top: 8px; }
.status-block .status-line { margin: 0 0 2px; }
.status-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 10px; }
.prefab-mini { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.prefab-mini li { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.prefab-mini li:first-child { border-top: none; }
.prefab-mini li > span:first-child { font-weight: 550; min-width: 140px; }
.prefab-mini li.warn { background: var(--warning-soft); }
.prefab-try-note { display: flex; gap: 6px; align-items: flex-start; margin: -2px 0 12px; }
.prefab-try-note .icon { margin-top: 2px; color: var(--subtle); }
.prefab-try-note strong { color: #9bdc8c; font-weight: 600; }
.block-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.block-summary .tags { flex: 1; min-width: 0; }

/* summary column */
.gen-summary { position: sticky; top: 24px; }
.summary-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.summary-body { display: flex; flex-direction: column; gap: 14px; }
.summary-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.summary-preset { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-name { font-weight: 600; font-size: 15px; margin-top: -6px; overflow-wrap: anywhere; }
.kv-list { margin: 0; display: flex; flex-direction: column; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-top: 1px dashed var(--border); min-height: 34px; }
.kv:first-child { border-top: none; }
.kv dt { color: var(--muted); font-size: 13px; flex: none; }
.kv dd { margin: 0; text-align: right; font-weight: 550; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.kv dd .mini-bar { width: 130px; }
.kv.mono-v dd { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.kv-list.wide .kv dt { min-width: 120px; }
.kv-list.wide .kv dd { text-align: left; flex: 1; }
.est { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); font-size: 13px; }
.est-row { display: flex; gap: 8px; align-items: flex-start; color: #cfc6bb; }
.est-row .icon { color: var(--subtle); margin-top: 1px; }
.est-row.warn, .est-row.warn .icon { color: var(--warning); }
.issue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.link-btn.issue { color: var(--warning); text-align: left; font-weight: 500; font-size: 13px; display: flex; gap: 6px; align-items: flex-start; line-height: 18px; }
.link-btn.issue .icon { margin-top: 2px; }

.gen-bar { display: none; }

/* ------------------------------------------------------------------ job page */
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 500; margin-bottom: 14px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.job-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: start; margin-bottom: 20px; max-width: 1180px; }
.job-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.job-title-row .page-title { overflow-wrap: anywhere; }
.job-meta { grid-column: 1; font-size: 13.5px; }
.job-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 8px; align-items: center; }
.job-body { max-width: 1180px; }
.progress-card { max-width: 760px; display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.progress-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.progress-step { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.progress-pct { font-size: 18px; font-weight: 600; }
.steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 0 10px; padding: 9px 0; position: relative; color: var(--subtle); }
.step::before { content: ""; position: absolute; left: 11px; top: -9px; height: 18px; width: 2px; background: var(--border-strong); }
.step:first-child::before { display: none; }
.step.done::before, .step.active::before { background: rgba(107, 191, 89, 0.5); }
.step-mark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; background: var(--surface); position: relative; z-index: 1; }
.step.done { color: var(--muted); }
.step.done .step-mark { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.step.active { color: var(--text); font-weight: 600; }
.step.active .step-mark { border-color: var(--accent); }
.step-detail { grid-column: 2; font-weight: 400; font-size: 12px; }
.step-detail:empty { display: none; }
.step-clock { grid-column: 3; grid-row: 1; font-weight: 400; }
.log-panel { margin-top: 20px; max-width: 1180px; padding: 0; overflow: hidden; }
.log-panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-weight: 550; }
.log-panel > summary:hover { background: var(--surface-2); }
.log-hint { margin-left: auto; }
.log {
  margin: 0; max-height: 460px; overflow: auto; padding: 14px 18px; background: #0c0b0a; border-top: 1px solid var(--border);
  font: 12px/18px var(--mono); color: #bdb4a9; white-space: pre-wrap; word-break: break-word;
}
.log-err { color: #ff8589; }
.log-warn { color: #f0bd63; }
.log-mod { color: #8cbbe6; }

.done-view { display: flex; flex-direction: column; gap: 16px; }
.result-actions-wrap { display: flex; flex-direction: column; gap: 12px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.result-secondary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; max-width: 1180px; }
.link-btn.quiet { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; font-size: 13px; }
.link-btn.quiet:hover { color: var(--text); }
.link-btn.quiet.danger { color: #e9898c; }
.link-btn.quiet.danger:hover { color: #ff9a9d; }
.result-delete { margin-left: auto; }
.verify-row {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
}
.verify-icon { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--surface-3); color: var(--subtle); }
.verify-ok .verify-icon { background: var(--success-soft); color: var(--success); }
.verify-problem { border-color: rgba(227, 163, 59, 0.35); background: var(--warning-soft); }
.verify-problem .verify-icon { background: rgba(227, 163, 59, 0.18); color: var(--warning); }
.verify-text { flex: 1; min-width: 0; }
.verify-title { font-weight: 550; font-size: 13.5px; }
.verify-detail { font-variant-numeric: tabular-nums; }
.verify-cats { font-size: 11.5px; line-height: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.verify-detail .link-btn { font-size: inherit; line-height: inherit; color: inherit; text-decoration: underline; font-weight: 550; text-align: left; }
.verify-problem .verify-detail { color: #e4cfa6; }
.done-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.preview-col, .stats-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.preview-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #0f1f24; aspect-ratio: 1; }
.preview-img { width: 100%; height: 100%; object-fit: cover; }
.preview-missing { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.markers { position: absolute; inset: 0; }
.marker {
  position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45);
}
.marker.feature { width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; background: #5a9bd5; border-width: 1.5px; }
.marker:hover, .marker:focus-visible, .marker.pinned, .marker.hl { z-index: 5; transform: scale(1.35); outline: none; }
.marker.hl { background: #ffd34d; }
.marker-tip {
  position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%) scale(0.75); white-space: nowrap; pointer-events: none;
  background: rgba(18, 17, 16, 0.94); color: var(--text); border: 1px solid var(--border-strong); padding: 3px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 550; opacity: 0; transition: opacity 0.1s;
}
.marker:hover .marker-tip, .marker:focus-visible .marker-tip, .marker.pinned .marker-tip, .marker.hl .marker-tip { transform: translateX(-50%); }
.marker.tip-below .marker-tip { bottom: auto; top: calc(100% + 7px); }
.marker:hover .marker-tip, .marker:focus-visible .marker-tip, .marker.pinned .marker-tip, .marker.hl .marker-tip { opacity: 1; }
.all-labels .marker:not(.feature) .marker-tip { opacity: 1; transform: translateX(-50%) scale(0.62); }
/* near the left/right edge the label grows inwards from the marker instead of centring on it */
.marker.tip-left .marker-tip { left: auto; right: -2px; transform-origin: right center; }
.marker.tip-right .marker-tip { left: -2px; transform-origin: left center; }
.markers .marker.tip-left .marker-tip, .markers .marker.tip-right .marker-tip { transform: scale(0.75); }
.markers .marker.tip-left:is(:hover, :focus-visible, .pinned, .hl) .marker-tip,
.markers .marker.tip-right:is(:hover, :focus-visible, .pinned, .hl) .marker-tip { transform: none; }
.all-labels .markers .marker.tip-left:not(.feature) .marker-tip,
.all-labels .markers .marker.tip-right:not(.feature) .marker-tip { transform: scale(0.62); }
/* offshore monuments beyond the preview's edge: pinned to the border as a hollow dashed ring */
.marker.offmap { background: rgba(206, 66, 43, 0.45); border: 2px dashed #fff; }
.marker.offmap.hl { background: #ffd34d; }
.preview-opts { display: flex; gap: 18px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-top: 12px; }
.stat { background: var(--surface); padding: 10px 12px; min-width: 0; }
.stat-k { font-size: 12px; color: var(--muted); }
.stat-v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-sub { font-size: 11.5px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-bars { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.dist-title { margin-bottom: 6px; }
.cp-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.cp-list li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13.5px; }
.cp-list li > span:first-child { font-weight: 550; }
.cp-list li > span:last-child { margin-left: auto; text-align: right; }
.flat-report { margin-top: 8px; color: #cfc6bb; word-break: break-word; font-variant-ligatures: none; }
.flat-report.kv-list .kv dd { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mon-index { padding: 0 18px 14px; }
.mon-index > summary { padding: 14px 0 6px; }
.mon-index-list { list-style: none; padding: 0; margin: 6px 0 0; columns: 3 170px; column-gap: 18px; font-size: 13px; }
.mon-index-list li { padding: 3px 6px; border-radius: 5px; cursor: default; break-inside: avoid; }
.mon-index-list li:hover, .mon-index-list li:focus { background: var(--surface-3); outline: none; }
/* public-link banner on the done page: icon · text · Copy link / Turn off */
.share-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; }
.share-row > .icon { margin-top: 0; }
.share-row-text strong { color: #e3eefa; font-weight: 600; }
.share-row-actions { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.share-row .link-btn { color: #9cc8f0; font-size: 13px; }
.warn-body { flex: 1; min-width: 0; }
.warn-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; }
.warn-hint { color: #d9c49b; }

/* ------------------------------------------------------------------ library */
.library { display: flex; flex-direction: column; gap: 28px; margin-top: 18px; max-width: 1400px; }
.day-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--subtle); font-weight: 600; margin-bottom: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.map-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: border-color 0.12s; }
.map-card:hover { border-color: var(--border-strong); }
.map-thumb { position: relative; display: block; aspect-ratio: 1; background: #0f1f24; overflow: hidden; }
.map-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s; }
.map-card:hover .map-thumb img { transform: scale(1.025); }
.thumb-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--subtle); background: var(--surface-2); }
.thumb-ph.pattern { background: repeating-linear-gradient(135deg, #1d1b18 0 12px, #201d1a 12px 24px); }
.thumb-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px;
  text-align: center; background: rgba(18, 17, 16, 0.55); color: var(--text); font-size: 13px;
}
.thumb-overlay .bar { width: 70%; margin-top: 4px; }
.thumb-overlay span { color: var(--muted); }
.ov-failed { color: #ffb3b5; }
.ov-failed .icon { color: var(--danger); }
.overlay-err { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ov-running .icon, .ov-queued .icon { color: var(--accent-text); }
.map-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.map-card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-right: -6px; }
.map-card-title { flex: 1 1 auto; font-size: 15px; font-weight: 600; line-height: 22px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-card-title a { color: var(--text); }
.badge-public { height: 20px; padding: 0 7px; gap: 4px; font-size: 11.5px; background: var(--info-soft); color: #8cbbe6; }
.map-card-stats { color: var(--muted); font-size: 12px; }
.map-card-warn { display: flex; align-items: center; gap: 6px; color: var(--warning); margin-top: -2px; }
.map-card-warn a { color: inherit; }
.map-card-time { margin-top: -2px; }
/* the two buttons share a row when they fit, else stack */
.map-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.map-card-actions .btn { flex: 1 1 auto; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 56px 24px; max-width: 560px; }
.empty.slim { padding: 28px; flex-direction: row; justify-content: center; }
.empty h2 { font-size: 18px; font-weight: 600; }
.empty .btn { margin-top: 8px; }
.empty-art { width: 72px; height: 72px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }

/* ------------------------------------------------------------------ prefabs */
.slot-list { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.list-sub { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--subtle); margin: 18px 0 0; font-weight: 600; }
.slot { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; transition: border-color 0.12s, background 0.12s; }
.slot.is-attached { border-color: #34302b; }
.slot.has-error { border-color: rgba(229, 72, 77, 0.55); }
.slot.drag { border-color: var(--accent); background: #201916; }
.slot-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.slot-name { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.slot-name h3 { font-size: 15.5px; font-weight: 600; }
.dropzone {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 16px; border-radius: 10px;
  border: 1.5px dashed #4d463f; background: #161412; color: var(--muted); cursor: pointer; text-align: center;
}
.dropzone:hover, .slot.drag .dropzone { border-color: var(--accent); color: var(--text); background: #1c1714; }
.dz-main { font-weight: 550; color: var(--text); }
.dz-help { max-width: 520px; }
.slot-uploading { display: flex; align-items: center; gap: 10px; padding: 18px; border-radius: 10px; background: #161412; border: 1px solid var(--border); }
.slot-file { display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.slot-file.off { opacity: 0.85; }
.file-icon { width: 38px; height: 38px; border-radius: 9px; background: var(--success-soft); color: var(--success); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.slot-file.off .file-icon { background: var(--surface-3); color: var(--subtle); }
.file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-ctl { display: flex; align-items: center; gap: 6px; }
.slot-adv { margin-top: 0; border-top: none; }
.slot-adv > summary { padding: 0; font-size: 13px; }
.adv-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 0 0 20px; }
.tpl-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.adv-body .check-row { margin: 8px 0 0; }
details.history { border-top: 1px solid var(--border); }
details.history > summary { padding: 10px 0 0; font-size: 13px; }
.history-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.history-list li { display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 20px; border-radius: 8px; flex-wrap: wrap; }
.history-list li:hover { background: var(--surface-2); }
.history-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }

/* ------------------------------------------------------------------ settings */
.settings { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.settings-card { display: flex; flex-direction: column; gap: 14px; }
.settings-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.settings-head p { margin-top: 2px; }
.srv-progress { display: flex; align-items: center; gap: 12px; }
.settings-card .btn-row { margin-top: 0; }
.settings-card > .btn { align-self: flex-start; }
.hook-form .input-group { max-width: 640px; }
.preset-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.preset-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.preset-list li:first-child { border-top: none; }
.preset-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.preset-actions { display: flex; gap: 6px; align-items: center; }

/* ------------------------------------------------------------------ public share page (/d/<token>, rendered by the backend) */
body.share { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; background: radial-gradient(ellipse at 50% -10%, rgba(206, 66, 43, 0.12), transparent 55%), var(--bg); }
.share-card { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.share-card img { width: 100%; border-radius: 10px; border: 1px solid var(--border); aspect-ratio: 1; object-fit: cover; }
.share-card h1 { font-size: 22px; font-weight: 650; line-height: 30px; }
.share-card .btn { height: 44px; font-size: 15px; }
.share-card code.copy { display: inline-block; margin-top: 6px; word-break: break-all; user-select: all; }
/* the server.levelurl line: the URL in a field-like box that wraps on any character, the Copy button beside it */
.share-card .share-url { display: flex; align-items: flex-start; gap: 8px; margin-top: -4px; }
.share-card .share-url code.copy {
  flex: 1; min-width: 0; display: block; margin: 0; padding: 8px 10px; border-radius: 8px; background: #141210; border-color: var(--border-strong);
  font-size: 12.5px; line-height: 18px; color: #d6cec4; overflow-wrap: anywhere; word-break: break-all;
}
.share-card .share-url .btn { height: 36px; padding: 0 14px; font-size: 13px; flex: none; min-width: 72px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .gen-layout { grid-template-columns: minmax(0, 1fr); max-width: 820px; }
  .gen-summary { position: static; }
  .gen-summary .btn.primary.lg.block, .gen-summary .center { display: none; }
  .gen-bar {
    display: flex; position: fixed; z-index: 40; left: var(--sidebar-w); right: 0; bottom: 0; gap: 14px; align-items: center; justify-content: space-between;
    padding: 12px 24px calc(12px + env(safe-area-inset-bottom)); background: rgba(26, 24, 22, 0.94); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-strong);
  }
  .gen-bar-info { min-width: 0; }
  .gen-bar-main { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .gen-bar-sub { font-size: 12px; }
  .gen-bar-btn.block { width: auto; flex: none; min-width: 200px; }
  .done-grid { grid-template-columns: minmax(0, 1fr); }
  .stats-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}
@media (max-width: 1000px) {
  .main { padding: 26px 24px 56px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .amount-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); background: none; }
  .sidebar {
    position: sticky; top: 0; z-index: 50; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px;
    padding: 8px 12px; border-right: none; border-bottom: 1px solid var(--border); background: rgba(22, 20, 18, 0.96); backdrop-filter: blur(8px);
  }
  .brand { padding: 4px 4px; font-size: 14px; }
  .brand img { width: 24px; height: 24px; }
  .nav-links { flex-direction: row; margin-left: auto; gap: 2px; }
  .nav-link { height: 34px; padding: 0 9px; gap: 6px; font-size: 13px; }
  .nav-link[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .sidebar-foot { display: none; }
  /* the running-job pill shrinks to one short chip inside the nav row (spinner + 41%), so only the bar stays sticky */
  .run-pill-slot { order: 1; margin: 0; flex: none; }
  .nav-links { order: 2; }
  .run-pill { flex-direction: row; align-items: center; height: 32px; padding: 0 10px; border-radius: 999px; }
  .run-pill-top { font-size: 12px; gap: 6px; text-transform: none; letter-spacing: 0; }
  .run-pill-title, .run-pill-name, .run-pill-sub, .run-pill .bar { display: none; }
  .run-pill-short { display: inline; color: var(--text); font-size: 12px; font-weight: 600; }
  .run-pill-more { margin-left: 0; font-size: 11px; }
  .gen-bar { left: 0; }
  .toasts { left: 16px; right: 16px; bottom: 88px; align-items: stretch; }
  .toast { max-width: none; }
}
@media (max-width: 767px) {
  /* Delete is in the job header's ⋯ menu; keep phones' action area to the safe, frequent actions */
  .result-secondary .link-btn.result-delete { display: none; }
}
@media (max-width: 600px) {
  .main { padding: 18px 16px 48px; }
  .main.has-gen-bar { padding-bottom: 110px; }
  .page-title { font-size: 21px; line-height: 28px; }
  .brand-name { display: none; }
  .nav-links { margin-left: 0; flex: 1; justify-content: space-between; min-width: 0; }
  .nav-link { flex-direction: column; height: 46px; gap: 2px; font-size: 11px; padding: 4px 4px; justify-content: center; flex: 1; min-width: 0; }
  .run-pill { padding: 0 8px; }
  .run-pill-more { display: none; }
  .card { padding: 16px; }
  .section { padding: 0; }
  .section-head { padding: 14px 16px; gap: 12px; }
  .section-icon { display: none; }
  .section-body { padding: 2px 16px 16px; }
  .preset-row-2 { flex-direction: column; align-items: stretch; }
  .preset-row-2 .btn { align-self: flex-start; }
  .mon-list { grid-template-columns: minmax(0, 1fr); }
  .toggle-row { flex-direction: column; align-items: stretch; gap: 10px; }
  /* in a column the 260px flex-basis would become a 260px minimum height */
  .toggle-row > .row-text { flex: 0 0 auto; }
  .toggle-row .seg { align-self: flex-start; }
  .toggle-row .switch-wrap { align-self: flex-start; }
  .toggle-row .switch-state { text-align: left; order: 2; }
  .ctl-stack { align-items: stretch; }
  .ctl-stack .seg, .ctl-stack .switch-wrap { align-self: flex-start; }
  .alloc-row { grid-template-columns: 1fr 84px; gap: 6px 12px; }
  .alloc-row .range { grid-column: 1 / -1; grid-row: 2; }
  .gen-bar { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .gen-bar-btn.block { min-width: 0; height: 42px; padding: 0 14px; }
  .job-actions .btn.danger-text { padding: 0 10px; }
  .hide-sm { display: none; }
  .settings-head > .icon { display: none; }
  .map-card:not(.status-done) .map-thumb { aspect-ratio: 16 / 9; }
  .result-actions .btn { flex: 1 1 calc(50% - 10px); }
  .share-row { grid-template-columns: auto minmax(0, 1fr); }
  .share-row > .icon { align-self: start; margin-top: 2px; }
  .share-row-actions { grid-column: 2; }
  .stats-col { display: flex; }
  .progress-card { padding: 18px; }
  .log-panel.card { padding: 0; }
  .log-panel > summary { padding: 14px 16px; }
  .log { padding: 12px 16px; }
  .sheet-filters { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .slot-file { flex-wrap: wrap; }
  .file-ctl { width: 100%; justify-content: space-between; }
  .mon-toolbar .btn { margin-left: 0; }
  .mon-toolbar .input { max-width: none; }
  .settings-head { flex-direction: column; gap: 8px; }
  .input-unit { max-width: none; }
  #f-flatten { display: flex; }
  #f-flatten .seg-btn { min-width: 0; flex: 1; padding: 0 6px; }
  .dialog-actions .btn { flex: 1; }
}

/* per-group bulk actions in the Monuments section */
.group-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: -2px 0 10px 26px; }
.group-bulk-label { margin-right: 2px; }
.group-bulk .btn.bulk-try { color: #8fd47f; }
.group-bulk .btn.bulk-avoid { color: #ff8589; }
.group-bulk .btn.bulk-try:hover:not([aria-disabled="true"]) { border-color: rgba(107, 191, 89, 0.55); background: var(--success-soft); }
.group-bulk .btn.bulk-avoid:hover:not([aria-disabled="true"]) { border-color: rgba(229, 72, 77, 0.55); background: var(--danger-soft); }

/* the Generate page's fixed bottom bar (861–1280 px; narrower screens already lift toasts): toasts sit above it */
@media (min-width: 861px) and (max-width: 1280px) {
  body:has(.main.has-gen-bar) .toasts { bottom: 88px; }
}

/* toast action (Undo) */
.toast-action { font-size: 13px; padding: 4px 6px; border-radius: 6px; flex: none; display: inline-flex; align-items: center; gap: 6px; }
.toast-action:hover { background: var(--surface-3); text-decoration: none; }
.toast-kbd {
  font-family: var(--mono); font-size: 11px; font-weight: 500; line-height: 16px; padding: 0 5px; border-radius: 4px;
  color: var(--muted); background: var(--surface-3); border: 1px solid var(--border-strong);
}
/* touch screens: no keyboard shortcut to show */
@media (hover: none) and (pointer: coarse) { .toast-kbd { display: none; } }

/* Monument spacing row at the top of the Monuments section */
.toggle-row.relax-row { border-top: none; border-bottom: 1px solid var(--border); padding: 14px 0; }
.relax-row + .mon-intro { margin-top: 12px; }
/* Building on roads: a grid, so the (polite live region) note under it takes no space while it is empty */
.toggle-row.road-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 20px; }
.road-row .row-note-wrap { grid-column: 1 / -1; }
.road-row .row-note { margin-top: 10px; }
.toggle-row.amount-row .amount-ctl { flex: none; }
.toggle-row.amount-row.changed .row-label { color: #fff; }
.kv.warn-v dd { color: #f0c27a; }

/* done page: post-processing notes under Map stats (roads opened, wrecks removed, underwater labs) */
.stat-notes { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 18px; color: #cfc6bb; }
.stat-notes li { display: flex; gap: 8px; align-items: flex-start; }
.stat-notes .icon { color: var(--subtle); margin-top: 1px; }

/* Underwater labs group: labs set to 0 in Infrastructure */
.group-note { margin: 0 0 10px 26px; }
.group-note .link-btn { font-size: inherit; color: inherit; text-decoration: underline; }

@media (max-width: 600px) {
  /* help text, note and the "Set all" bar share one left edge under the group title */
  .group-bulk, .group-help, .group-note { margin-left: 0; }
  .group-bulk-label { flex-basis: 100%; }
  /* long option labels (Building on roads): the control spans the row and its labels may wrap */
  .toggle-row.road-row { grid-template-columns: minmax(0, 1fr); }
  .road-row .seg { margin-top: 10px; }
  .toggle-row .seg.seg-fit { align-self: stretch; display: flex; }
  .seg.seg-fit .seg-btn { flex: 1 1 auto; justify-content: center; text-align: center; white-space: normal; height: auto; min-height: 30px; padding: 4px 8px; line-height: 16px; }
  .toggle-row.amount-row { flex-direction: row; align-items: center; }
  .toggle-row.amount-row > .row-text { flex: 1 1 auto; }
}
.amount-note { margin-top: 8px; }
.amount > .amount-note-wrap { grid-column: 1 / -1; }
