:root {
  --paper: #ede6d6;
  --paper-strong: #e4dbc8;
  --ink: #19312d;
  --muted-ink: #55665d;
  --accent: #165f56;
  --accent-strong: #0f4f49;
  --accent-soft: #bfd9d2;
  --accent-pale: #ddebe7;
  --warn: #ba4e2d;
  --line: #6e6c62;
  --shadow: 0 18px 36px rgba(29, 28, 25, 0.2);
  --shadow-soft: 0 12px 28px rgba(26, 31, 28, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 14% 10%, rgba(143, 184, 173, 0.42), transparent 32%),
    radial-gradient(circle at 85% 12%, rgba(223, 176, 135, 0.24), transparent 34%),
    linear-gradient(145deg, #d7cfbf, #f3eadc 44%, #e4d9c7);
}

.app-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.menu-bar {
  display: grid;
  grid-template-columns: minmax(260px, auto) minmax(260px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(43, 57, 51, 0.24);
  background:
    linear-gradient(150deg, rgba(255, 253, 247, 0.96), rgba(232, 224, 208, 0.92));
  box-shadow: var(--shadow-soft);
}

.brand h1 {
  margin: 2px 0 0;
  letter-spacing: 0.04em;
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-family: "Baskerville", "Times New Roman", serif;
}

.eyebrow,
.section-kicker {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
  font-weight: 700;
}

.brand-note {
  margin: 6px 0 0;
  max-width: 30rem;
  color: var(--muted-ink);
  font-size: 0.92rem;
  line-height: 1.4;
}

.menu-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.menu-tab {
  border: 1px solid rgba(17, 60, 56, 0.35);
  border-radius: 999px;
  padding: 9px 15px;
  background: rgba(225, 241, 237, 0.72);
  color: #134740;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.menu-tab.active {
  color: #fbfffd;
  background: linear-gradient(170deg, #1e756c, #0f4f49);
  border-color: rgba(8, 42, 39, 0.5);
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.stage {
  position: relative;
  min-height: 0;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(58, 60, 51, 0.26);
  background:
    linear-gradient(180deg, rgba(248, 243, 233, 0.94), rgba(234, 226, 211, 0.9));
  box-shadow: var(--shadow);
}

.board-wrap {
  position: absolute;
  inset: 0;
  isolation: isolate;
}

#board {
  width: 100%;
  height: 100%;
  min-height: 540px;
  touch-action: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 243, 232, 0.94)),
    radial-gradient(circle at 74% 16%, rgba(195, 214, 204, 0.2), transparent 34%),
    radial-gradient(circle at 16% 82%, rgba(231, 209, 174, 0.18), transparent 28%);
}

.board-hud {
  position: absolute;
  top: 18px;
  right: 18px;
  left: min(372px, calc(100% - 320px));
  z-index: 9;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

.hud-readouts,
.hud-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hud-readouts {
  max-width: min(58%, 720px);
}

.hud-hints {
  justify-content: flex-end;
  max-width: 32rem;
}

.hud-pill,
.hint-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(32, 53, 49, 0.16);
  background: rgba(255, 251, 244, 0.88);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.hud-pill {
  font-weight: 600;
}

.hud-pill-primary {
  background: linear-gradient(170deg, rgba(31, 115, 106, 0.96), rgba(15, 81, 75, 0.96));
  color: #f7fbfa;
  border-color: rgba(10, 49, 45, 0.36);
}

.hint-chip {
  color: var(--muted-ink);
  background: rgba(242, 236, 226, 0.9);
}

kbd {
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid rgba(24, 45, 42, 0.18);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
}

.selection-spotlight {
  position: absolute;
  right: 18px;
  bottom: 78px;
  width: min(360px, calc(100% - 392px));
  z-index: 10;
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(31, 62, 57, 0.18);
  background: linear-gradient(180deg, rgba(247, 241, 231, 0.92), rgba(238, 231, 219, 0.9));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.selection-spotlight-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.selection-spotlight-head h2 {
  margin: 4px 0 0;
  font-family: "Baskerville", "Times New Roman", serif;
  letter-spacing: 0.06em;
  font-size: 1.04rem;
}

.selection-spotlight-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.selection-spotlight-actions button {
  min-width: 84px;
}

.status-bar {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: min(372px, calc(100% - 320px));
  z-index: 8;
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(47, 58, 51, 0.14);
  border-radius: 14px;
  color: var(--muted-ink);
  font-size: 0.8rem;
  background: rgba(252, 248, 240, 0.84);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.control-dock {
  position: absolute;
  top: 18px;
  left: 18px;
  width: min(338px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow: auto;
  z-index: 10;
  border-radius: 18px;
  border: 1px solid rgba(48, 59, 52, 0.28);
  background: linear-gradient(180deg, rgba(248, 242, 232, 0.95), rgba(240, 233, 219, 0.9));
  box-shadow: 0 18px 34px rgba(24, 25, 22, 0.2);
  backdrop-filter: blur(10px);
  padding: 14px;
}

.control-dock.hidden {
  display: none;
}

.control-dock.hidden + .board-wrap .board-hud,
.control-dock.hidden + .board-wrap .status-bar,
.control-dock.hidden + .board-wrap .selection-spotlight {
  left: 18px;
  width: auto;
}

.dock-panel {
  display: none;
}

.dock-panel.active {
  display: grid;
  gap: 10px;
  align-content: start;
}

.notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(165, 201, 193, 0.35);
  border: 1px solid rgba(25, 88, 83, 0.28);
  color: #194f4a;
  font-size: 0.88rem;
}

.notice.error {
  border-color: rgba(170, 73, 41, 0.4);
  background: rgba(216, 125, 95, 0.26);
  color: #6d2b1b;
}

.hero-copy {
  margin: 0;
  color: var(--muted-ink);
  font-size: 0.88rem;
  line-height: 1.45;
}

.section-card {
  margin-top: 0;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(162deg, rgba(255, 255, 255, 0.76), rgba(243, 236, 223, 0.8));
  border: 1px solid rgba(51, 56, 47, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.section-card:first-child {
  margin-top: 0;
}

.section-card h2 {
  margin: 4px 0 0;
  font-family: "Baskerville", "Times New Roman", serif;
  letter-spacing: 0.06em;
  font-size: 1.04rem;
}

.section-card.compact {
  margin-top: 9px;
}

.section-note {
  margin: 6px 0 0;
  color: var(--muted-ink);
  font-size: 0.82rem;
  line-height: 1.45;
}

.section-card h3 {
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: var(--muted-ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tool-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(224, 239, 235, 0.92);
  border: 1px solid rgba(20, 78, 71, 0.18);
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tool-strip button {
  width: 100%;
}

.tool-strip-secondary {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.form-shelf {
  margin-top: 10px;
}

.angle-measure-fields {
  display: grid;
  gap: 10px;
}

.micro-note {
  margin: 10px 0 0;
  color: var(--muted-ink);
  font-size: 0.8rem;
  line-height: 1.45;
}

.endpoint-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.field-grid {
  display: grid;
  gap: 8px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.hint-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted-ink);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(69, 80, 72, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 10px;
  color: var(--ink);
}

button {
  border: 1px solid rgba(17, 60, 56, 0.45);
  border-radius: 11px;
  padding: 8px 12px;
  cursor: pointer;
  color: #f8fbf9;
  background: linear-gradient(170deg, #1f736a, #0f514b);
  transition: transform 120ms ease, filter 120ms ease, background 140ms ease;
}

button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

button.ghost {
  color: #11453f;
  background: linear-gradient(170deg, #d8ebe8, #c1ddd7);
  border-color: rgba(17, 69, 63, 0.3);
}

button.danger {
  background: linear-gradient(170deg, #bf6040, #9a3f25);
  border-color: rgba(100, 34, 19, 0.4);
}

button.active {
  background: linear-gradient(170deg, #d37b2a, #b85e1e);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.endpoint-card {
  margin-top: 0;
  border: 1px solid rgba(69, 80, 72, 0.2);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 254, 248, 0.78);
}

.hidden {
  display: none;
}

.table-wrap {
  max-height: 220px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead {
  position: sticky;
  top: 0;
  background: rgba(231, 223, 208, 0.95);
  z-index: 1;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid rgba(65, 67, 53, 0.18);
  padding: 5px 6px;
  white-space: nowrap;
}

tbody tr[data-select-segment] {
  cursor: pointer;
}

tbody tr.selected {
  background: rgba(223, 235, 230, 0.62);
}

.line-list {
  display: grid;
  gap: 8px;
}

.line-item {
  border: 1px solid rgba(53, 66, 60, 0.22);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 6px;
  cursor: pointer;
}

.line-item.selected {
  border-color: rgba(18, 91, 82, 0.55);
  box-shadow: inset 0 0 0 1px rgba(20, 108, 97, 0.28);
  background: linear-gradient(170deg, rgba(232, 246, 241, 0.86), rgba(221, 239, 232, 0.74));
}

.line-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.83rem;
  flex-wrap: wrap;
}

.chip {
  border-radius: 999px;
  width: 11px;
  height: 11px;
  display: inline-block;
  border: 1px solid rgba(18, 27, 22, 0.4);
}

.line-item button {
  justify-self: start;
  padding: 4px 8px;
  font-size: 0.76rem;
}

.empty {
  color: var(--muted-ink);
  font-size: 0.84rem;
}

.selection-summary {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(25, 88, 83, 0.14);
  background: linear-gradient(160deg, rgba(223, 235, 230, 0.54), rgba(244, 238, 229, 0.74));
}

.selection-summary.empty {
  background: rgba(248, 243, 234, 0.75);
}

.selection-summary p {
  margin: 0;
  color: var(--muted-ink);
  font-size: 0.84rem;
  line-height: 1.45;
}

.selection-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.selection-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(23, 33, 28, 0.32);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.selection-title {
  font-size: 0.96rem;
  letter-spacing: 0.02em;
}

.selection-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.selection-metric {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(41, 57, 53, 0.12);
}

.selection-metric-label {
  color: var(--muted-ink);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.selection-metric-value {
  font-size: 0.84rem;
  line-height: 1.3;
}

.selection-note {
  margin: 0;
  color: var(--muted-ink);
  font-size: 0.8rem;
  line-height: 1.45;
}

.selection-editor {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(47, 58, 51, 0.12);
}

.selection-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.selection-editor-span-2 {
  grid-column: 1 / -1;
}

.selection-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selection-editor-actions button {
  min-width: 148px;
}

.selection-point-grid {
  display: grid;
  gap: 10px;
}

.toggle-stack {
  display: grid;
  gap: 10px;
}

.toggle-grid {
  display: grid;
  gap: 8px;
}

.toggle-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(41, 57, 53, 0.12);
}

.toggle-row-master {
  background: linear-gradient(160deg, rgba(223, 235, 230, 0.72), rgba(244, 238, 229, 0.82));
}

.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.toggle-copy {
  display: grid;
  gap: 3px;
}

.toggle-copy strong {
  font-size: 0.84rem;
}

.toggle-copy small {
  color: var(--muted-ink);
  font-size: 0.76rem;
  line-height: 1.4;
}

.toggle-row:has(input:disabled) {
  opacity: 0.58;
}

.selection-point-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(41, 57, 53, 0.12);
}

.selection-point-title {
  font-size: 0.84rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: rise-in 520ms cubic-bezier(0.17, 0.82, 0.35, 1) forwards;
}

.reveal-b {
  animation-delay: 120ms;
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .menu-bar {
    grid-template-columns: 1fr;
  }

  .menu-tabs {
    justify-content: flex-start;
  }

  .menu-actions {
    justify-content: flex-start;
  }

  .board-hud,
  .status-bar,
  .selection-spotlight {
    left: 18px;
    width: auto;
  }
}

@media (max-width: 980px) {
  .endpoint-grid,
  .selection-metrics,
  .selection-editor-grid {
    grid-template-columns: 1fr;
  }

  .toggle-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  #board {
    min-height: 430px;
  }

  .control-dock {
    width: calc(100% - 20px);
    top: 10px;
    left: 10px;
    max-height: 72%;
  }

  .board-hud {
    top: auto;
    right: 10px;
    bottom: 162px;
    left: 10px;
    flex-direction: column;
    align-items: stretch;
  }

  .hud-readouts,
  .hud-hints {
    max-width: none;
    justify-content: flex-start;
  }

  .selection-spotlight {
    right: 10px;
    bottom: 84px;
    left: 10px;
    width: auto;
  }

  .selection-spotlight-head {
    flex-direction: column;
  }

  .selection-spotlight-actions {
    justify-content: flex-start;
  }

  .status-bar {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .tool-strip,
  .tool-strip-secondary,
  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }
}
