:root {
  color-scheme: light;
  --ink: #211e18;
  --muted: #6f675a;
  --paper: #f0e8d4;
  --paper-bright: #fffdf6;
  --paper-deep: #dfd2b7;
  --charcoal: #171511;
  --charcoal-2: #28241e;
  --amber: #d08a20;
  --amber-bright: #f1b854;
  --amber-deep: #8a5112;
  --green: #2f5d50;
  --red: #a84b36;
  --blue: #31556e;
  --line: #c9bda5;
  --shadow: 0 14px 36px rgba(36, 27, 13, 0.16);
  --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 780px;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(241, 184, 84, 0.72);
  outline-offset: 2px;
}

.masthead {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 122px;
  padding: 20px 26px 18px;
  color: #fbf3df;
  background:
    radial-gradient(circle at 18% -60%, rgba(218, 151, 52, 0.34), transparent 46%),
    linear-gradient(135deg, #14120e 0%, #28231b 58%, #171511 100%);
  border-bottom: 3px solid var(--amber);
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.25);
}

.masthead::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: repeating-linear-gradient(97deg, transparent 0 16px, rgba(255, 255, 255, 0.08) 17px, transparent 18px 33px);
}

.brand-lockup,
.masthead-new-action,
.masthead-actions {
  position: relative;
  z-index: 1;
}

.masthead-new-action {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin-inline: auto;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--amber-bright);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 780px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.44rem, 2.2vw, 2.12rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.025em;
}

h1 span {
  color: var(--amber-bright);
  font-style: italic;
}

h1 sup {
  margin-left: 3px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.38em;
  vertical-align: top;
}

.tagline {
  margin: 7px 0 0;
  color: #cfc4ae;
  font-size: 0.84rem;
}

.masthead-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 630px;
}

.button,
.icon-button,
.icon-text-button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 760;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.button:hover,
.icon-button:hover,
.icon-text-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active,
.icon-button:active,
.icon-text-button:active:not(:disabled) {
  transform: translateY(0);
}

.button-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 3px;
  padding: 0 5px;
  place-items: center;
  color: #2e271c;
  background: #f0d7a7;
  border-radius: 999px;
  font-size: 0.65rem;
}

.button {
  min-height: 38px;
  padding: 9px 13px;
  font-size: 0.8rem;
}

.button-quiet {
  color: #f5ecd9;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.button-quiet:hover {
  background: rgba(255, 255, 255, 0.14);
}

.button-primary {
  color: #fffaf0;
  background: var(--green);
  box-shadow: 0 4px 14px rgba(31, 79, 66, 0.35);
}

.button-primary:hover {
  background: #396e5f;
}

.button-accent {
  color: #251707;
  background: var(--amber-bright);
  box-shadow: 0 4px 14px rgba(208, 138, 32, 0.3);
}

.button-accent:hover {
  background: #f6c36b;
}

.button-pro {
  color: #241707;
  background: #f5d78e;
  border: 1px solid #ffebba;
  text-decoration: none;
}

.button-pro:hover {
  background: #ffe4a5;
}

.button-new-map {
  min-width: 132px;
  min-height: 50px;
  padding: 12px 20px;
  color: #251707;
  background: var(--amber-bright);
  border: 1px solid #f8d891;
  box-shadow: 0 0 0 3px rgba(241, 184, 84, 0.14), 0 8px 24px rgba(208, 138, 32, 0.3);
  font-size: 0.9rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.button-new-map:hover {
  background: #f6c36b;
  box-shadow: 0 0 0 4px rgba(241, 184, 84, 0.2), 0 10px 28px rgba(208, 138, 32, 0.38);
}

.button-danger {
  color: #fff8f4;
  background: var(--red);
}

.button-danger:hover {
  background: #bc5841;
}

.button-wide {
  width: 100%;
}

.button:disabled {
  cursor: wait;
  opacity: 0.72;
}

@media print {
  body {
    display: block;
    min-width: 0;
    overflow: visible;
    background: white;
  }

  .masthead,
  .document-bar,
  .inspector,
  .canvas-foot,
  .toast {
    display: none !important;
  }

  .workspace,
  .canvas-shell,
  .canvas-viewport {
    display: block;
    height: auto;
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  .canvas-stage {
    transform: none !important;
  }
}

.icon-button {
  width: 38px;
  height: 38px;
  color: #f8ecd4;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 1rem;
}

.document-bar {
  position: relative;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 9px 18px;
  background: #fffaf0;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(46, 35, 18, 0.08);
}

.map-name-field {
  display: grid;
  grid-template-columns: auto minmax(170px, 560px);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.map-name-field span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.map-name-field input {
  width: 100%;
  padding: 7px 9px;
  color: var(--ink);
  background: #fffef9;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 760;
}

.map-name-field input:hover,
.map-name-field input:focus {
  border-color: var(--line);
}

.history-controls,
.document-stats {
  display: flex;
  align-items: center;
  gap: 7px;
}

.history-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.add-box-button {
  color: #fffaf0;
  background: var(--green);
  border-color: #285044;
}

.add-box-button:hover {
  background: #396e5f;
}

.zoom-controls {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid #d4c8b1;
  border-radius: 7px;
}

.zoom-button,
.zoom-level,
.zoom-fit {
  min-height: 34px;
  padding: 6px 9px;
  color: #484034;
  background: #fffaf0;
  border: 0;
  border-right: 1px solid #d4c8b1;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 780;
}

.zoom-button {
  min-width: 34px;
  font-size: 1rem;
  line-height: 1;
}

.zoom-level {
  min-width: 48px;
  font-variant-numeric: tabular-nums;
}

.zoom-fit {
  border-right: 0;
  background: #f2ead9;
}

.zoom-button:hover:not(:disabled),
.zoom-level:hover,
.zoom-fit:hover {
  background: #eadfc9;
}

.zoom-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.lens-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 4px 8px 4px 10px;
  color: #6f604b;
  background: #fffaf0;
  border: 1px solid #d4c8b1;
  border-radius: 7px;
  font-size: 0.64rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lens-control select {
  min-height: 26px;
  color: #332d24;
  background: transparent;
  border: 0;
  font-size: 0.7rem;
  font-weight: 760;
}

.icon-text-button {
  min-height: 34px;
  padding: 7px 10px;
  color: #484034;
  background: #f2ead9;
  border: 1px solid #d4c8b1;
  font-size: 0.74rem;
}

.icon-text-button span {
  margin-right: 3px;
  font-size: 1rem;
}

.icon-text-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.document-stats {
  justify-content: flex-end;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.document-stats > span:not(:last-child) {
  padding: 5px 8px;
  background: #eee5d2;
  border-radius: 999px;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.save-state i {
  width: 7px;
  height: 7px;
  background: #3d8067;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(61, 128, 103, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns 160ms ease;
}

.workspace.inspector-focused {
  grid-template-columns: minmax(0, 1fr) clamp(520px, 42vw, 680px);
}

.canvas-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: #dcd0b8;
  border-right: 1px solid #bdae91;
}

.canvas-viewport {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: #cbbda3;
}

.canvas-stage {
  position: relative;
  width: 1800px;
  height: 1100px;
}

.canvas {
  position: relative;
  width: 1800px;
  height: 1100px;
  overflow: hidden;
  background-color: #f7f1e3;
  background-image:
    linear-gradient(rgba(111, 95, 67, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 95, 67, 0.075) 1px, transparent 1px),
    linear-gradient(rgba(111, 95, 67, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 95, 67, 0.035) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  box-shadow: inset 0 0 90px rgba(94, 74, 40, 0.08);
  cursor: default;
  user-select: none;
  transform-origin: 0 0;
}

.canvas.connecting,
.canvas.reconnecting {
  cursor: crosshair;
}

.edges,
.node-layer,
.handle-layer {
  position: absolute;
  inset: 0;
  width: 1800px;
  height: 1100px;
}

.edges {
  z-index: 1;
  overflow: visible;
}

.node-layer {
  z-index: 2;
  pointer-events: none;
}

.handle-layer {
  z-index: 4;
  pointer-events: none;
}

.node {
  position: absolute;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 120px;
  min-height: 80px;
  padding: 0;
  overflow: visible;
  color: var(--ink);
  background: #fffdf7;
  border: 2px solid #3b352c;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(63, 48, 25, 0.18), 0 2px 0 rgba(255, 255, 255, 0.95) inset;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transition: box-shadow 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.node:hover {
  border-color: #76582c;
  box-shadow: 0 11px 24px rgba(63, 48, 25, 0.23), 0 2px 0 rgba(255, 255, 255, 0.95) inset;
}

.node.selected {
  border-color: var(--amber-deep);
  box-shadow: 0 0 0 4px rgba(226, 158, 54, 0.28), 0 14px 28px rgba(63, 48, 25, 0.24);
}

.node.dragging {
  cursor: grabbing;
  transform: rotate(-0.35deg) scale(1.01);
  box-shadow: 0 18px 34px rgba(63, 48, 25, 0.28);
}

.node.gap-present {
  border-color: #b85835;
  box-shadow: 0 0 0 3px rgba(184, 88, 53, 0.14), 0 8px 18px rgba(63, 48, 25, 0.18);
}

.node.gap-present::before {
  content: attr(data-gap-count) " gap";
  position: absolute;
  z-index: 2;
  top: -11px;
  right: 10px;
  padding: 3px 7px;
  color: #fffaf0;
  background: #b85835;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.node.gap-clear {
  border-color: #3f7c67;
}

.node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 11px 6px;
  border-bottom: 1px solid #e4dac5;
}

.node h3 {
  margin: 0;
  min-width: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.08;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.node.multiline-title h3 {
  white-space: normal;
}

.node-category {
  flex: 0 0 auto;
  padding: 3px 6px;
  color: #675b49;
  background: #eee4d0;
  border-radius: 999px;
  font-size: 0.54rem;
  font-weight: 820;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.node-definition {
  display: -webkit-box;
  margin: 0;
  padding: 8px 11px 2px;
  overflow: hidden;
  color: #5f574b;
  font-size: 0.7rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.node-tags {
  display: flex;
  gap: 4px;
  min-height: 21px;
  padding: 3px 11px 8px;
  overflow: hidden;
}

.node-tag {
  flex: 0 0 auto;
  max-width: 86px;
  padding: 2px 5px;
  overflow: hidden;
  color: #31554a;
  background: #e4eee9;
  border-radius: 3px;
  font-size: 0.56rem;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-port {
  position: absolute;
  top: 50%;
  right: -11px;
  width: 20px;
  height: 20px;
  padding: 0;
  color: transparent;
  background: var(--amber-bright);
  border: 3px solid #fffaf0;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--amber-deep), 0 3px 7px rgba(68, 42, 10, 0.28);
  cursor: crosshair;
  opacity: 0;
  pointer-events: auto;
  transform: translateY(-50%) scale(0.76);
  transition: opacity 120ms ease, transform 120ms ease;
}

.node:hover .connection-port,
.node.selected .connection-port,
.connection-port:focus-visible {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.connection-port::after {
  content: "+";
  position: absolute;
  inset: -1px 0 0;
  display: grid;
  place-items: center;
  color: #5b370d;
  font-size: 0.68rem;
  font-weight: 900;
}

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  pointer-events: stroke;
  cursor: pointer;
}

.edge-wire {
  fill: none;
  stroke: #6d5b3f;
  stroke-linecap: round;
  stroke-width: 2.5;
  pointer-events: none;
  filter: url(#edge-shadow);
}

.edge-group:hover .edge-wire {
  stroke: #a06a23;
  stroke-width: 3.25;
}

.edge-group.selected .edge-wire {
  stroke: var(--amber-deep);
  stroke-width: 4;
}

.edge-group.detached .edge-wire {
  stroke: var(--red);
  stroke-dasharray: 9 7;
}

.edge-group.money-present .edge-wire {
  stroke: #2f765c;
  stroke-width: 4;
}

.edge-group.money-present .edge-type-label {
  fill: #1f624a;
}

.edge-group.money-empty {
  opacity: 0.38;
}

.edge-group.gap-present .edge-wire {
  stroke: #b85835;
  stroke-dasharray: 7 5;
}

.edge-group.gap-present .edge-type-label {
  fill: #9b3f25;
}

.edge-group.gap-clear .edge-wire {
  stroke: #2f765c;
}

.edge-label {
  fill: #30291f;
  stroke: #f7f1e3;
  stroke-linejoin: round;
  stroke-width: 8px;
  paint-order: stroke;
  pointer-events: none;
  font-size: 12px;
  font-weight: 760;
  text-anchor: middle;
}

.edge-type-label {
  fill: #7a6b57;
  stroke: #f7f1e3;
  stroke-linejoin: round;
  stroke-width: 6px;
  paint-order: stroke;
  pointer-events: none;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-anchor: middle;
  text-transform: uppercase;
}

.endpoint-halo {
  fill: rgba(255, 251, 239, 0.9);
  stroke: rgba(208, 138, 32, 0.28);
  stroke-width: 7;
  pointer-events: none;
}

.endpoint-handle {
  fill: #fffaf0;
  stroke: var(--amber-deep);
  stroke-width: 3;
  cursor: crosshair;
  pointer-events: all;
}

.edge-endpoint-button {
  position: absolute;
  width: 19px;
  height: 19px;
  padding: 0;
  background: #fffaf0;
  border: 3px solid var(--amber-deep);
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(208, 138, 32, 0.2), 0 3px 8px rgba(70, 42, 11, 0.24);
  cursor: crosshair;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  touch-action: none;
}

.edge-endpoint-button:hover,
.edge-endpoint-button:focus-visible {
  background: var(--amber-bright);
  transform: translate(-50%, -50%) scale(1.12);
}

.edge-endpoint-button.detached {
  border-color: var(--red);
  box-shadow: 0 0 0 6px rgba(168, 75, 54, 0.18), 0 3px 8px rgba(70, 42, 11, 0.24);
}

.edge-group.detached .endpoint-handle {
  stroke: var(--red);
}

.draft-edge {
  fill: none;
  stroke: var(--amber-deep);
  stroke-dasharray: 8 6;
  stroke-linecap: round;
  stroke-width: 3;
  pointer-events: none;
}

.empty-hint {
  position: absolute;
  z-index: 0;
  top: 180px;
  left: 260px;
  display: grid;
  gap: 5px;
  padding: 22px 25px;
  color: #776a56;
  background: rgba(255, 253, 247, 0.74);
  border: 2px dashed #b8a88b;
  border-radius: 12px;
  pointer-events: none;
}

.empty-hint[hidden] {
  display: none;
}

.empty-hint strong {
  color: #463c2f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.14rem;
}

.canvas-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 42px;
  padding: 7px 14px;
  color: #504739;
  background: #eee4cf;
  border-top: 1px solid #c3b497;
  font-size: 0.7rem;
}

.canvas-foot p {
  margin: 0;
}

.legal-links {
  display: flex;
  flex: 0 0 auto;
  gap: 9px;
}

.legal-links a {
  color: #66563e;
  font-size: 0.64rem;
  font-weight: 720;
}

.legal-links a:hover {
  color: var(--amber-deep);
}

#status-message {
  max-width: 48%;
  overflow: hidden;
  color: #6c5f4d;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 20px 18px 28px;
  background: #fffaf0;
  box-shadow: -10px 0 28px rgba(45, 34, 18, 0.08);
}

.function-note {
  background: #f3ead5;
  border-left: 4px solid var(--amber);
}

.function-library {
  margin-top: 16px;
}

.function-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 11px;
}

.function-add-form input {
  min-width: 0;
  padding: 8px 9px;
  color: var(--ink);
  background: #fffefb;
  border: 1px solid #cfc2aa;
  border-radius: 7px;
}

.function-add-form .button {
  min-height: 38px;
  padding-inline: 10px;
}

.function-library-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.function-library-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  background: #f4e8cd;
  border: 1px solid #decba5;
  border-radius: 7px;
}

.function-library-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.function-library-copy strong {
  overflow: hidden;
  color: #51422d;
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.function-library-copy span {
  color: #89765a;
  font-size: 0.57rem;
}

.function-library-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.mini-button {
  padding: 4px 6px;
  color: #5a4c38;
  background: #fffaf0;
  border: 1px solid #cbb995;
  border-radius: 5px;
  font: inherit;
  font-size: 0.57rem;
  font-weight: 760;
  cursor: pointer;
}

.mini-button:hover:not(:disabled) {
  border-color: var(--amber-deep);
}

.mini-button-danger {
  color: #8b3b2c;
}

.mini-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.function-choice-count {
  margin-top: 9px !important;
  color: #887964 !important;
  font-size: 0.64rem !important;
}

.connection-builder {
  margin-top: 16px;
  background: #f3ead5;
  border-left: 4px solid var(--amber);
}

.connection-builder-form {
  display: grid;
  gap: 7px;
  margin-top: 11px;
}

.connection-builder-form select {
  width: 100%;
  min-height: 38px;
  padding: 7px 28px 7px 8px;
  color: var(--ink);
  background: #fffefb;
  border: 1px solid #cfc2aa;
  border-radius: 7px;
}

.map-outline {
  margin-top: 16px;
}

.map-outline-search {
  width: 100%;
  margin-top: 10px;
  padding: 8px 9px;
  color: var(--ink);
  background: #fffefb;
  border: 1px solid #cfc2aa;
  border-radius: 7px;
}

.map-outline-list {
  display: grid;
  gap: 4px;
  max-height: 220px;
  margin-top: 8px;
  overflow: auto;
}

.map-outline-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  color: #4e4436;
  text-align: left;
  background: #fffdf7;
  border: 1px solid #ded3bf;
  border-radius: 6px;
  cursor: pointer;
}

.map-outline-button:hover,
.map-outline-button:focus-visible {
  background: #f1e4ca;
  border-color: #c6ad81;
}

.map-outline-button strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-outline-button span {
  flex: 0 0 auto;
  color: #887a66;
  font-size: 0.55rem;
  font-weight: 760;
  text-transform: uppercase;
}

.map-outline-button[hidden] {
  display: none;
}

.inspector-head {
  margin: 0 0 17px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.inspector-kicker {
  margin: 0 0 5px;
  color: var(--amber-deep);
  font-size: 0.64rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.inspector h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.32rem;
  line-height: 1.05;
}

.inspector-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.inspector-empty {
  display: grid;
  align-content: start;
  gap: 18px;
}

.empty-card,
.inspector-section,
.relationship-list {
  padding: 14px;
  background: #fffdf8;
  border: 1px solid #ddd1bb;
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(59, 45, 23, 0.05);
}

.empty-card h3,
.inspector-section h3,
.relationship-list h3 {
  margin: 0 0 8px;
  color: #40382c;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.empty-card p,
.inspector-section p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.48;
}

.inspector-form {
  display: grid;
  gap: 13px;
}

.field {
  display: grid;
  gap: 5px;
}

.field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: #51483b;
  font-size: 0.68rem;
  font-weight: 820;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field > span small {
  color: #968975;
  font-size: 0.59rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  color: var(--ink);
  background: #fffefb;
  border: 1px solid #cfc2aa;
  border-radius: 7px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.field input,
.field select {
  min-height: 39px;
  padding: 8px 10px;
}

.field textarea {
  min-height: 76px;
  padding: 9px 10px;
  line-height: 1.4;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(208, 138, 32, 0.13);
}

.field-note {
  margin: -1px 0 0;
  color: #8c7e69;
  font-size: 0.64rem;
  line-height: 1.35;
}

.advanced-disclosure {
  margin-top: 14px;
  background: #fffdf8;
  border: 1px solid #d8cbb4;
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(59, 45, 23, 0.05);
}

.advanced-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  cursor: pointer;
  list-style: none;
}

.advanced-disclosure > summary::-webkit-details-marker {
  display: none;
}

.advanced-disclosure > summary span {
  display: grid;
  gap: 3px;
}

.advanced-disclosure > summary strong {
  color: #40382c;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.advanced-disclosure > summary small {
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.35;
}

.advanced-disclosure[open] > summary {
  border-bottom: 1px solid #e1d6c2;
}

.advanced-count {
  min-width: 25px;
  padding: 4px 7px;
  color: #fffaf0;
  text-align: center;
  background: var(--green);
  border-radius: 999px;
  font-size: 0.66rem;
}

.advanced-body {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.compact-editor-button {
  position: sticky;
  top: -8px;
  z-index: 4;
  justify-self: end;
  min-height: 34px;
  padding: 7px 11px;
  color: #fffaf0;
  background: var(--green);
  border: 1px solid #214c3f;
  border-radius: 7px;
  box-shadow: 0 4px 12px rgba(29, 70, 57, 0.18);
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 800;
}

.compact-editor-button:hover {
  background: #214c3f;
}

.advanced-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  background: #f7f0e1;
  border: 1px solid #ded1bb;
  border-radius: 7px;
}

.money-card {
  border-left: 4px solid #3f7c67;
}

.advanced-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.advanced-card-title strong {
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advanced-form {
  gap: 10px;
}

.workspace.inspector-focused .advanced-card {
  padding: 16px;
}

.workspace.inspector-focused .advanced-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.workspace.inspector-focused .advanced-form .field:has(textarea) {
  grid-column: 1 / -1;
}

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

.endpoint-summary {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #f2ead9;
  border-radius: 7px;
  font-size: 0.68rem;
}

.endpoint-summary span {
  min-width: 0;
  overflow: hidden;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.endpoint-summary b {
  color: var(--amber-deep);
  font-size: 1rem;
}

.endpoint-summary .detached-text {
  color: var(--red);
  font-style: italic;
}

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

.relationship-list ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.relationship-button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  width: 100%;
  padding: 8px 9px;
  text-align: left;
  background: #f7f0e1;
  border: 1px solid #ded1bb;
  border-radius: 6px;
  cursor: pointer;
}

.relationship-button:hover {
  background: #f0e3ca;
  border-color: #c6ad81;
}

.relationship-button i {
  color: var(--amber-deep);
  font-style: normal;
  font-weight: 900;
}

.relationship-button span {
  min-width: 0;
  overflow: hidden;
  font-size: 0.67rem;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.inspector-id {
  margin: 12px 0 0;
  overflow: hidden;
  color: #9a8c77;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.57rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 24px;
  bottom: 24px;
  max-width: 430px;
  padding: 12px 15px;
  color: #fff8ea;
  background: #242018;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 15px 34px rgba(0, 0, 0, 0.28);
  font-size: 0.77rem;
  font-weight: 700;
}

.toast.error {
  background: #792e22;
}

.help-dialog {
  width: min(620px, calc(100vw - 40px));
  padding: 0;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid #bba989;
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.help-dialog::backdrop {
  background: rgba(20, 17, 12, 0.72);
  backdrop-filter: blur(2px);
}

.help-dialog form {
  position: relative;
  padding: 28px 30px 30px;
}

.maps-dialog {
  width: min(720px, calc(100vw - 40px));
}

.maps-dialog-inner {
  position: relative;
  padding: 28px 30px 30px;
}

.help-dialog h2 {
  margin: 0 44px 18px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  line-height: 1.08;
}

.maps-dialog-note {
  margin: -7px 44px 20px 0;
  color: #665c4d;
  font-size: 0.8rem;
  line-height: 1.42;
}

.ai-dialog {
  width: min(620px, calc(100vw - 32px));
}

.ai-target-control {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  color: var(--amber-deep);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ai-target-control select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid #d7c8aa;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.readiness-card {
  display: grid;
  gap: 4px;
  margin: 14px 0;
  padding: 12px 14px;
  background: #f2ead9;
  border: 1px solid #d7c8aa;
  border-left: 5px solid var(--amber-deep);
  border-radius: 8px;
}

.readiness-card strong {
  font-size: 0.8rem;
}

.readiness-card span {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.readiness-ready {
  border-left-color: #2f765c;
}

.readiness-blocked {
  border-left-color: var(--red);
}

.handoff-scopes {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}

.handoff-scopes label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 10px 11px;
  background: #fffdf8;
  border: 1px solid #ded1bb;
  border-radius: 7px;
  cursor: pointer;
}

.handoff-scopes input {
  margin-top: 3px;
}

.handoff-scopes span {
  display: grid;
  gap: 3px;
}

.handoff-scopes strong {
  font-size: 0.75rem;
}

.handoff-scopes small {
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.35;
}

.ai-dialog-actions,
.codex-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-dialog .button-quiet {
  color: #554a3a;
  background: #f1e7d3;
  border-color: #d7c8aa;
}

.ai-dialog .button-quiet:hover {
  background: #e7d8bc;
}

.saved-map-list {
  display: grid;
  gap: 10px;
  max-height: min(480px, 55vh);
  margin-bottom: 18px;
  overflow-y: auto;
}

.saved-map-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 14px 15px;
  background: #fffdf7;
  border: 1px solid #d8cbb3;
  border-radius: 9px;
}

.saved-map-copy {
  min-width: 0;
}

.saved-map-copy h3 {
  margin: 0 0 4px;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-map-copy p {
  margin: 0;
  color: #766b5a;
  font-size: 0.7rem;
}

.saved-map-actions {
  display: flex;
  gap: 7px;
}

.saved-map-actions .button {
  padding: 9px 12px;
}

.saved-map-delete {
  color: #7d3427;
}

.saved-map-empty {
  display: grid;
  gap: 5px;
  padding: 28px;
  color: #665c4d;
  text-align: center;
  background: #f2ead8;
  border: 1px dashed #b9aa8e;
  border-radius: 9px;
}

.saved-map-empty strong {
  color: #3e372d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
}

.saved-map-empty span {
  font-size: 0.75rem;
}

.help-dialog ol {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding-left: 22px;
  color: #4f4638;
  font-size: 0.82rem;
  line-height: 1.42;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 36px;
  height: 36px;
  padding: 0;
  color: #655a48;
  background: transparent;
  border: 1px solid #d0c2aa;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.35rem;
}

.help-note {
  margin: 0 0 20px;
  padding: 12px 14px;
  color: #4c4030;
  background: #efe3c9;
  border-left: 4px solid var(--amber);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  line-height: 1.4;
}

@media (max-width: 1120px) {
  .masthead {
    align-items: flex-start;
  }

  .masthead-actions {
    max-width: 410px;
  }

  .masthead-new-action {
    margin-inline: 0;
  }

  .button-new-map {
    min-width: 112px;
    padding-inline: 14px;
  }

  .document-bar {
    grid-template-columns: minmax(250px, 1fr) auto;
  }

  .document-stats {
    display: none;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .workspace.inspector-focused {
    grid-template-columns: minmax(0, 1fr) min(56vw, 600px);
  }
}

@media (max-height: 760px) {
  .masthead {
    min-height: 92px;
    padding-top: 13px;
    padding-bottom: 12px;
  }

  .tagline {
    display: none;
  }

  .document-bar {
    min-height: 50px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
}

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

body.legal-body {
  display: block;
  min-width: 0;
  min-height: 100%;
  height: auto;
  overflow: auto;
  background: #f3ead7;
}

.legal-masthead {
  min-height: 102px;
}

.legal-masthead h1 {
  max-width: none;
}

.legal-back {
  color: #fff8e8;
  text-decoration: none;
}

.legal-page {
  width: min(820px, calc(100% - 36px));
  margin: 38px auto 64px;
  padding: 34px clamp(22px, 5vw, 52px);
  background: #fffdf7;
  border: 1px solid #d8cbb3;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.legal-page h2,
.legal-page h3 {
  font-family: Georgia, "Times New Roman", serif;
}

.legal-page h2 {
  margin: 0 0 10px;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.legal-page h3 {
  margin: 28px 0 8px;
  font-size: 1.08rem;
}

.legal-page p,
.legal-page li {
  color: #554b3d;
  font-size: 0.94rem;
  line-height: 1.65;
}

.legal-page a {
  color: #24574a;
  font-weight: 700;
}

.legal-summary {
  margin: 18px 0 26px;
  padding: 14px 16px;
  color: #403526 !important;
  background: #f1e3c5;
  border-left: 4px solid var(--amber);
}

.legal-meta {
  color: #80725f !important;
  font-size: 0.78rem !important;
}

.legal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid #d8cbb3;
}
