:root {
  color-scheme: light;
  --milk: #eeeee7;
  --milk-light: #fafaf5;
  --milk-deep: #dfdfd6;
  --milk-panel: rgba(249, 249, 244, 0.78);
  --milk-panel-solid: #f7f7f1;
  --ink: #213633;
  --ink-soft: #445651;
  --muted: #78817c;
  --quiet: rgba(33, 54, 51, 0.45);
  --line: rgba(33, 54, 51, 0.13);
  --line-strong: rgba(33, 54, 51, 0.25);
  --chalk-green: #c6d7bd;
  --chalk-green-ink: #314838;
  --chalk-green-line: rgba(87, 116, 91, 0.24);
  --chalk-red: #d8b7ad;
  --shadow: rgba(33, 54, 51, 0.11);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; }
html { background: var(--milk); }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 255, 252, 0.96), transparent 38%),
    linear-gradient(145deg, var(--milk-light), var(--milk) 60%, var(--milk-deep));
}

button, input, select, textarea { font: inherit; }
button, select { color: inherit; }
button { touch-action: manipulation; }

.app-frame {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.bridge-view,
.engine-view {
  position: absolute;
  inset: 0;
  min-width: 0;
  background: transparent;
  transition: transform 220ms ease, opacity 180ms ease;
}

.bridge-view { z-index: 2; transform: translateY(0); opacity: 1; }
.engine-view { z-index: 1; transform: translateY(7%); opacity: 0; pointer-events: none; }
.workspace-mode-engine .bridge-view { transform: translateY(-7%); opacity: 0; pointer-events: none; }
.workspace-mode-engine .engine-view { z-index: 3; transform: translateY(0); opacity: 1; pointer-events: auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  height: 82px;
  min-height: 82px;
  padding: 18px 18px 10px 20px;
  border-bottom: 1px solid transparent;
  background: transparent;
}

.brand-plate,
.brand-mark,
.topbar-actions { display: flex; align-items: center; }
.brand-plate { align-self: stretch; gap: 14px; min-width: 0; height: 54px; padding: 0 12px; }
.brand-mark { gap: 12px; min-width: 0; }
.brand-home-link { display: inline-flex; width: 48px; height: 48px; align-items: center; justify-content: center; }
.brand-bird {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(20%) sepia(18%) saturate(673%) hue-rotate(122deg) brightness(92%) contrast(90%);
  opacity: 0.94;
}
.brand-name { font-size: clamp(1.32rem, 2.05vw, 1.82rem); font-weight: 700; line-height: 1; letter-spacing: 0; }

.header-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.header-icon-button:hover,
.header-icon-button:focus-visible,
.header-icon-button[aria-expanded="true"] { outline: none; border-color: var(--line); background: rgba(255,255,252,.56); }
.menu-lines,
.menu-lines::before,
.menu-lines::after { display: block; width: 22px; height: 2px; border-radius: 2px; background: var(--ink); }
.menu-lines { position: relative; }
.menu-lines::before,
.menu-lines::after { content: ""; position: absolute; left: 0; }
.menu-lines::before { top: -7px; }
.menu-lines::after { top: 7px; }
.reset-icon { width: 19px; height: 19px; background: currentColor; mask: url("https://api.iconify.design/material-symbols/restart-alt-rounded.svg") center / contain no-repeat; }

.bridge-stage {
  height: calc(100dvh - 82px);
  overflow: auto;
  scrollbar-width: thin;
  padding: clamp(18px, 3vw, 38px) clamp(16px, 4vw, 50px) 82px;
}
.bridge-shell { width: min(1080px, 100%); margin: 0 auto; }

.profile-bar {
  margin-bottom: clamp(18px, 3vw, 32px);
}
.selection-menu { display: flex; border-bottom: 1px solid var(--line); }
.selection-menu-shell { position: relative; flex: 1 1 0; min-width: 0; }
.selection-menu-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 8px 34px 8px 13px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.selection-menu-shell:last-child .selection-menu-button { border-right: 0; }
.selection-menu-button::after { content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-70%) rotate(45deg); }
.selection-menu-button:hover,
.selection-menu-button[aria-expanded="true"] { background: rgba(255,255,252,.48); }
.selection-menu-button:focus-visible { outline: 2px solid var(--line-strong); outline-offset: -2px; }
.selection-menu-button:disabled { cursor: default; opacity: .6; }
.selection-menu-button span { font-size: .9rem; font-weight: 600; }
.selection-menu-popup {
  position: absolute;
  z-index: 30;
  top: calc(100% + 7px);
  left: 0;
  width: max(100%, 235px);
  max-height: min(390px, 55vh);
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(247,247,240,.98);
  box-shadow: 0 16px 40px rgba(33,54,51,.14);
}
.selection-menu-popup-right { right: 0; left: auto; }
.selection-menu-popup[hidden] { display: none; }
.selection-menu-popup button { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.selection-menu-popup button:hover,
.selection-menu-popup button.is-selected { background: rgba(33,54,51,.075); }
.selection-menu-popup button.is-selected { font-weight: 700; }
.selection-summary { margin: 9px 13px 0; color: var(--ink-soft); font-size: .84rem; line-height: 1.45; }
.label { color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }

.select-shell { position: relative; display: block; }
select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(251, 251, 247, .76);
  color: var(--ink);
  outline: none;
}
select { min-height: 43px; padding: 0 38px 0 13px; appearance: none; cursor: pointer; }
input { min-height: 43px; padding: 9px 12px; }
textarea { resize: vertical; padding: 10px 12px; line-height: 1.4; }
select:focus,
input:focus,
textarea:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(33,54,51,.075); }
.select-caret { position: absolute; top: 50%; right: 13px; width: 8px; height: 8px; border-right: 1.5px solid var(--ink-soft); border-bottom: 1.5px solid var(--ink-soft); transform: translateY(-70%) rotate(45deg); pointer-events: none; }

.bridge-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: clamp(14px, 2.2vw, 24px); }
.score-card,
.result-card,
.boundaries-card,
.engine-panel {
  border: 1px solid var(--line);
  background: var(--milk-panel);
  box-shadow: 0 18px 50px rgba(33,54,51,.07), inset 0 1px 0 rgba(255,255,255,.72);
  backdrop-filter: blur(14px);
}
.score-card,
.result-card { min-height: 292px; border-radius: 22px; padding: clamp(20px, 3vw, 32px); }
.section-head,
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-head h1,
.section-head h2,
.panel-head h2,
.result-main h2 { margin: 4px 0 0; font-size: 1.18rem; line-height: 1.2; }
.percentage-output { display: block; width: 100%; margin-top: 10px; color: var(--ink-soft); font-size: 1.05rem; text-align: center; font-variant-numeric: tabular-nums; }

.score-inputs { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 12px; align-items: end; margin-top: 34px; }
.score-inputs label { display: grid; gap: 8px; color: var(--muted); font-size: .82rem; }
.score-inputs input {
  height: auto;
  min-height: 74px;
  padding: 6px 10px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  font-weight: 500;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.score-inputs input:focus { box-shadow: none; border-bottom-color: var(--ink); }
.score-divider { padding-bottom: 13px; color: var(--quiet); font-size: 2rem; }
.score-track { height: 6px; margin-top: 30px; border-radius: 999px; background: rgba(33,54,51,.09); overflow: hidden; }
.score-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--ink); transition: width 180ms ease; }
.input-message { min-height: 1.35em; margin: 12px 0 0; color: var(--muted); font-size: .85rem; }
.input-message.is-error { color: var(--ink); font-weight: 700; }

.result-card { display: flex; flex-direction: column; container-name: result; container-type: inline-size; }
.result-content { display: flex; flex: 1; flex-direction: column; }
.result-main { display: flex; align-items: center; justify-content: center; margin: 18px 0 auto; }
.result-primary { display: inline-flex; align-items: center; justify-content: center; min-width: 112px; min-height: 112px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 50%; background: rgba(255,255,252,.52); font-size: clamp(3.8rem, 7vw, 5.6rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.result-secondary { display: block; min-height: 1.2em; margin-top: 10px; color: var(--ink-soft); font-size: 1rem; text-align: center; }
.result-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 18px; }
.result-facts div { display: grid; gap: 5px; }
.result-facts span { color: var(--muted); font-size: .76rem; }
.result-facts strong { font-size: .96rem; font-weight: 600; }
.result-neighbor-grade { display: none; }
.result-facts output { font-size: .96rem; font-weight: 600; }

/* Die kompakte Dreier-Anordnung bleibt auch erhalten, wenn der Ergebnis-
   container auf kleinen Displays als breite Einzelspalte dargestellt wird. */
@container result (max-width: 900px) {
  .result-content { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); grid-template-rows: auto auto; align-content: center; align-items: center; gap: 10px 8px; }
  .result-main { grid-column: 2; grid-row: 1; margin: 10px 0; }
  .result-secondary { grid-column: 2; grid-row: 2; justify-self: center; margin: 0; }
  .result-facts { display: contents; }
  .result-facts > div { grid-row: 1; align-content: center; justify-items: center; gap: 4px; padding: 0; border: 0; text-align: center; }
  .result-facts > div:first-child { grid-column: 1; }
  .result-facts > div:last-child { grid-column: 3; }
  .result-fact-label { display: none; }
  .result-neighbor-grade { display: block; font-size: 1.45rem !important; line-height: 1; }
  .result-facts output { color: var(--ink-soft); font-size: .78rem; white-space: nowrap; }
}

.boundaries-card { margin-top: clamp(14px, 2.2vw, 24px); border-radius: 18px; padding: 18px 20px 20px; }
.section-head.compact { align-items: end; }
.boundary-list { display: grid; grid-template-columns: repeat(6, minmax(90px, 1fr)); gap: 7px; margin-top: 16px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
.boundary-item { min-width: 86px; padding: 10px; border: 1px solid transparent; border-radius: 10px; background: rgba(33,54,51,.035); }
.boundary-item.is-current { border-color: var(--line-strong); background: rgba(255,255,252,.68); }
.boundary-item strong { display: block; font-size: 1rem; }
.boundary-item > span { display: grid; gap: 2px; margin-top: 4px; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.boundary-item > span > span { display: block; }

.workspace-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: rgba(239,239,232,.94);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(16px);
}
.workspace-strip span { font-size: .78rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.workspace-strip:hover,
.workspace-strip:focus-visible { outline: none; color: var(--ink); background: rgba(248,248,242,.96); }
.workspace-strip-top { top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); }

.engine-stage { height: 100dvh; overflow: hidden; display: grid; grid-template-columns: minmax(330px,.82fr) minmax(430px,1.18fr); gap: 20px; padding: 72px 22px 22px; }
.engine-panel {
  min-height: 0;
  height: 100%;
  overflow: auto;
  border-radius: 18px;
  padding: clamp(18px, 2.4vw, 28px);
  align-self: stretch;
  scrollbar-width: none;
}
.engine-panel::-webkit-scrollbar { display: none; }
.profile-manager { position: relative; }
.engine-tabs { display: flex; gap: 6px; margin-top: 18px; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,252,.36); }
.engine-tab { flex: 1 1 0; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); cursor: pointer; font-weight: 700; }
.engine-tab:hover,
.engine-tab:focus-visible { outline: none; color: var(--ink); background: rgba(255,255,252,.46); }
.engine-tab[aria-selected="true"] { color: var(--ink); background: rgba(255,255,252,.78); box-shadow: 0 1px 0 rgba(255,255,252,.65) inset; }
.engine-tab-pane { margin-top: 18px; }
.engine-tab-pane[hidden] { display: none; }
.browser-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.import-menu-shell { position: relative; display: inline-flex; }
.profile-import-menu {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(248,248,242,.98);
  box-shadow: 0 14px 30px rgba(33,54,51,.12);
}
.profile-import-menu[hidden] { display: none; }
.profile-folder-menu {
  position: absolute;
  z-index: 9;
  top: calc(100% + 6px);
  left: 158px;
  display: grid;
  min-width: min(280px, 72vw);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(248,248,242,.98);
  box-shadow: 0 14px 30px rgba(33,54,51,.12);
}
.profile-folder-menu[hidden] { display: none; }
.profile-import-menu button {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.profile-import-menu button:hover { background: rgba(33,54,51,.075); }
.profile-folder-choice {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.profile-folder-choice:hover { background: rgba(33,54,51,.075); }
.profile-folder-choice strong { font-size: .9rem; }
.profile-folder-choice span { color: var(--muted); font-size: .76rem; }
.profile-browser-list { display: grid; gap: 8px; margin-top: 16px; }
.profile-browser-empty { margin: 0; padding: 14px 4px; color: var(--ink-soft); font-size: .9rem; line-height: 1.45; }
.profile-browser-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 10px 12px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(33,54,51,.035);
  cursor: pointer;
}
.profile-browser-item:hover,
.profile-browser-item:focus-visible { outline: none; border-color: var(--line); background: rgba(255,255,252,.52); }
.profile-browser-item.is-active { border-color: var(--line-strong); background: rgba(255,255,252,.62); }
.profile-browser-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; }
.profile-active-badge {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 2px 8px 1px;
  border: 1px solid var(--chalk-green-line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--chalk-green) 72%, rgba(255,255,252,.9));
  color: var(--chalk-green-ink);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1;
  text-transform: uppercase;
}
.profile-browser-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; line-height: 1.35; }
.profile-record-menu { position: relative; }
.profile-record-menu summary {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
}
.profile-record-menu summary::-webkit-details-marker { display: none; }
.profile-record-menu summary:hover,
.profile-record-menu[open] summary { background: rgba(255,255,252,.72); color: var(--ink); }
.profile-record-actions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(248,248,242,.98);
  box-shadow: 0 14px 30px rgba(33,54,51,.12);
}
.profile-record-actions button {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.profile-record-actions button:hover { background: rgba(33,54,51,.075); }
.profile-record-actions .profile-record-action-delete {
  --hold-progress: 0%;
  color: var(--ink);
}
.profile-record-actions .profile-record-action-delete.is-hold-active,
.profile-record-actions .profile-record-action-delete.is-hold-ready {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--chalk-red) 86%, white) 0%, color-mix(in srgb, var(--chalk-red) 86%, white) var(--hold-progress), transparent var(--hold-progress), transparent 100%),
    rgba(255,255,252,.68);
  color: var(--ink);
}
.engine-tab-browser .threshold-manager > :not(.profile-preview) { display: none; }
.engine-tab-profile .profile-preview { display: none; }
.engine-tab-profile:not(.engine-scale-selected) .threshold-manager .threshold-head,
.engine-tab-profile:not(.engine-scale-selected) .threshold-manager .panel-note,
.engine-tab-profile:not(.engine-scale-selected) .threshold-manager .threshold-actions,
.engine-tab-profile:not(.engine-scale-selected) .threshold-manager .threshold-table-head,
.engine-tab-profile:not(.engine-scale-selected) .threshold-manager .threshold-editor { display: none; }
.profile-workbench { display: grid; gap: 14px; }
.profile-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: .82rem;
  line-height: 1.45;
}
.profile-breadcrumb span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.profile-breadcrumb span:not(:last-child)::after { content: "›"; color: var(--muted); }
.profile-tree {
  display: grid;
  gap: 4px;
  margin-top: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,252,.36);
}
.profile-tree ul { display: grid; gap: 3px; margin: 0; padding: 0 0 0 18px; list-style: none; }
.profile-tree > ul { padding-left: 0; }
.profile-tree li { position: relative; margin: 0; }
.profile-tree-node > ul {
  position: relative;
  margin-left: 12px;
  padding-left: 20px;
}
.profile-tree-node > ul::before {
  content: "";
  position: absolute;
  top: -2px;
  bottom: 15px;
  left: 8px;
  width: 1px;
  background: linear-gradient(to bottom, rgba(96,111,104,.34), rgba(96,111,104,.12));
}
.profile-tree-node > ul > .profile-tree-node::before {
  content: "";
  position: absolute;
  top: 16px;
  left: -12px;
  width: 15px;
  height: 1px;
  background: rgba(96,111,104,.28);
}
.profile-tree > ul > .profile-tree-node::before { display: none; }
.profile-tree-row { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 4px; align-items: center; }
.profile-tree-toggle {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(96,111,104,.2);
  border-radius: 7px;
  background: rgba(255,255,252,.48);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
}
.profile-tree-toggle:hover,
.profile-tree-toggle:focus-visible { outline: none; border-color: var(--line); background: rgba(255,255,252,.58); color: var(--ink); }
.profile-tree-toggle-placeholder { width: 24px; height: 24px; }
.profile-tree-node.is-collapsed > ul { display: none; }
.profile-tree-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.profile-tree-button:hover,
.profile-tree-button:focus-visible { outline: none; border-color: var(--line); background: rgba(255,255,252,.62); }
.profile-tree-button.is-active { border-color: var(--line-strong); background: rgba(255,255,252,.76); font-weight: 700; }
.profile-tree-readonly .profile-tree-button {
  cursor: default;
  opacity: .92;
}
.profile-tree-readonly .profile-tree-button:hover,
.profile-tree-readonly .profile-tree-button:focus-visible {
  border-color: transparent;
  background: transparent;
}
.profile-tree-kicker {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.profile-detail { margin-top: 0; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.profile-detail-card[hidden] { display: none; }
.compact-note { margin: 8px 0 0; }
.profile-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 18px; }
.engine-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.engine-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.engine-section-head h3 { margin: 4px 0 0; font-size: 1rem; }
.engine-section .profile-fields { margin-top: 14px; }
.scope-head { align-items: center; }
.scope-head .secondary-button { flex: 0 0 auto; }
.scope-section > .field { margin-top: 14px; }
.basis-select { margin-top: 14px; }
.basis-actions { margin-top: 8px; }
.scope-delete { margin-top: 8px; padding-left: 0; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span:first-child { color: var(--muted); font-size: .78rem; }
.field.full { grid-column: 1 / -1; }
.field label { display: grid; gap: 6px; min-width: 0; }
.field label > span:first-child { color: var(--muted); font-size: .78rem; }
.field-with-action { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.field-with-action.full { grid-column: 1 / -1; }
.profile-fields > .full { grid-column: 1 / -1; }
.profile-manager > .field { margin-top: 18px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.secondary-button,
.text-button { min-height: 38px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,252,.48); cursor: pointer; }
.secondary-button.primary-action { border-color: var(--line-strong); background: rgba(255,255,252,.72); font-weight: 700; }
.secondary-button:disabled,
.text-button:disabled { cursor: default; opacity: .42; }
.secondary-button:hover,
.secondary-button:focus-visible,
.text-button:hover,
.text-button:focus-visible { outline: none; border-color: var(--line-strong); background: rgba(255,255,252,.78); }
.text-button { border-color: transparent; color: var(--muted); background: transparent; font-size: .8rem; }
.threshold-head { align-items: center; }
.panel-note { margin: 18px 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.threshold-actions { display: flex; justify-content: flex-end; margin: -4px 0 10px; }
.threshold-actions .secondary-button { min-height: 34px; font-size: .82rem; }
.threshold-table-head,
.threshold-row { display: grid; grid-template-columns: minmax(80px,.8fr) minmax(80px,.8fr) minmax(120px,1fr) 34px; gap: 10px; align-items: center; }
.threshold-table-head { padding: 0 10px 7px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.threshold-editor { display: grid; gap: 5px; }
.threshold-row { padding: 7px 10px; border: 1px solid transparent; border-radius: 10px; background: rgba(33,54,51,.03); }
.threshold-row:focus-within { border-color: var(--line); background: rgba(255,255,252,.62); }
.threshold-row output { font-weight: 600; }
.threshold-row input { min-height: 36px; font-variant-numeric: tabular-nums; }
.threshold-row .percent-field input { text-align: right; }
.threshold-row .threshold-text-input { padding: 8px 9px; }
.threshold-remove-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.threshold-remove-button:hover,
.threshold-remove-button:focus-visible { outline: none; color: var(--ink); background: rgba(255,255,252,.72); }
.threshold-remove-button:disabled { cursor: default; opacity: .3; }
.percent-field { position: relative; }
.percent-field::after { content: "%"; position: absolute; top: 50%; right: 12px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.percent-field input { padding-right: 30px; }
.menu-overlay { position: fixed; inset: 0; z-index: 30; background: rgba(33,54,51,.13); backdrop-filter: blur(2px); }
.menu-overlay[hidden] { display: none; }
.side-menu { position: fixed; z-index: 31; inset: 0 auto 0 0; width: min(420px, calc(100vw - 28px)); padding: 18px; border-right: 1px solid var(--line); background: rgba(246,246,239,.97); box-shadow: 24px 0 70px rgba(33,54,51,.15); transform: translateX(-100%); transition: transform 180ms ease; }
.side-menu.is-open { transform: translateX(0); }
.side-menu-inner { display: flex; flex-direction: column; gap: 18px; height: 100%; }
.side-menu-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.side-menu-head strong { display: block; margin-top: 4px; }
.menu-close-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,252,.55); color: var(--ink); font-size: 1.1rem; cursor: pointer; }
.side-menu-list { display: grid; gap: 8px; overflow: auto; }
.side-menu-list details { border: 1px solid transparent; border-radius: 10px; }
.side-menu-list details[open] { border-color: var(--line); background: rgba(255,255,252,.48); }
.side-menu-list summary { padding: 12px; font-weight: 700; cursor: pointer; list-style: none; }
.side-menu-list summary::-webkit-details-marker { display: none; }
.side-menu-list p { margin: 0; padding: 0 12px 14px; color: var(--ink-soft); font-size: .9rem; line-height: 1.5; }
.project-choice-list { display: grid; gap: 6px; padding: 0 12px 14px; }
.project-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
}
.project-choice:hover,
.project-choice[aria-current="page"] {
  border-color: var(--line);
  background: rgba(255, 255, 252, 0.58);
}
.project-choice[aria-current="page"]::after {
  content: "✓";
  color: var(--ink-soft);
  font-weight: 700;
}

@media (max-width: 900px) {
  .bridge-grid { grid-template-columns: 1fr; }
  .score-card, .result-card { min-height: 260px; }
  .boundary-list { grid-template-columns: repeat(6, minmax(88px,1fr)); }
  .engine-stage { overflow: auto; grid-template-columns: 1fr; }
  .engine-panel { height: auto; overflow: visible; }
  .profile-manager { position: static; }
}

@media (max-width: 620px) {
  .topbar { height: 82px; min-height: 82px; padding: 18px 10px 10px 12px; }
  .brand-plate { padding: 0 5px; gap: 8px; }
  .brand-home-link, .brand-bird { width: 44px; height: 44px; }
  .brand-name { font-size: 1.36rem; }
  .bridge-stage { padding: 10px 10px calc(78px + env(safe-area-inset-bottom)); }
  .bridge-view > .workspace-strip {
    position: fixed;
    bottom: 0;
    z-index: 20;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .profile-bar { margin-bottom: 10px; }
  .selection-menu-button { min-height: 44px; padding-right: 25px; padding-left: 10px; }
  .selection-menu-button::after { right: 9px; }
  .selection-summary { margin-right: 8px; margin-left: 8px; font-size: .77rem; }
  .bridge-grid { gap: 10px; }
  .score-card, .result-card { min-height: 0; border-radius: 16px; padding: 16px; }
  .score-inputs { margin-top: 18px; gap: 7px; }
  .score-inputs input { min-height: 60px; font-size: 2.85rem; }
  .score-track { margin-top: 18px; }
  .result-primary { min-width: 82px; min-height: 82px; font-size: 3.3rem; }
  .result-secondary { display: none; }
  .boundaries-card { margin-top: 10px; border-radius: 14px; padding: 14px; }
  .boundary-list { margin-top: 11px; }
  .engine-stage { padding: 66px 8px 10px; gap: 10px; }
  .engine-panel { border-radius: 14px; padding: 16px; }
  .profile-fields { grid-template-columns: 1fr; }
  .scope-head { align-items: flex-start; flex-direction: column; }
  .scope-head .secondary-button { width: 100%; }
  .field.full { grid-column: auto; }
  .threshold-head { align-items: flex-start; flex-direction: column; }
  .threshold-table-head, .threshold-row { grid-template-columns: 56px 56px minmax(96px,1fr) 30px; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
