:root {
  --bg: #f5f1e8;
  --panel: rgba(255, 253, 247, 0.9);
  --panel-border: rgba(63, 54, 34, 0.12);
  --text: #2a2418;
  --muted: #6e675c;
  --accent: #0b7285;
  --accent-soft: rgba(11, 114, 133, 0.12);
  --accent-strong: #b34700;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(70, 55, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(11, 114, 133, 0.12), transparent 32%),
    linear-gradient(180deg, #f8f4eb 0%, #efe5d2 100%);
}

.app-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar-side {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.subtitle,
.panel-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  font-weight: 600;
  white-space: nowrap;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-link {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

.header-link:hover {
  transform: translateY(-1px);
  background: rgba(11, 114, 133, 0.12);
  color: var(--accent);
}

.header-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.status-pill.busy {
  background: rgba(11, 114, 133, 0.12);
  color: var(--accent);
}

.status-pill.error {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.tab {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.65);
  color: var(--text);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease;
}

.tab:hover {
  transform: translateY(-1px);
}

.tab.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.workspace {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.external-link-panel {
  min-height: 0;
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 12px 0 0;
}

.external-link-intro {
  margin: 0;
}

.external-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.external-link-card {
  color: var(--text);
  text-decoration: none;
  display: grid;
  gap: 12px;
  padding: 24px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.external-link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 36px rgba(70, 55, 24, 0.12);
  border-color: rgba(11, 114, 133, 0.22);
}

.external-link-card-title {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.external-link-card-description {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.external-link-card-url {
  margin: 0;
  color: var(--muted);
  word-break: break-word;
  font-size: 0.92rem;
}

.clipping-grid {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 24px;
  align-items: start;
}

.clipping-left {
  display: grid;
  gap: 18px;
}

.clipping-controls {
  display: grid;
  gap: 14px;
}

.clipping-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}

.clipping-right {
  min-width: 0;
}

.clipping-visuals {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}

.clipping-visual-card {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.clipping-visual-header {
  display: grid;
  gap: 6px;
}

.clipping-visual-title {
  margin: 0;
  font-size: 1rem;
}

.clipping-visual-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.clipping-plot {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 70vh;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 8px;
}

.clipping-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.clipping-curve-host {
  width: 100%;
  min-height: 420px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  overflow: hidden;
}

@media (max-width: 1180px) {
  .clipping-visuals {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .clipping-grid {
    grid-template-columns: 1fr;
  }
}

.hero-panel {
  display: grid;
  gap: 18px;
}

.hero-copy {
  display: grid;
  gap: 6px;
}

.toolbar-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.panel-header,
.selection-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.field-stack {
  display: grid;
  gap: 14px;
}

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

.field-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
  font-weight: 600;
}

.field-unit {
  color: var(--muted);
  font-weight: 500;
}

.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(66, 57, 37, 0.18);
  padding: 10px 12px;
  font: inherit;
  background: rgba(255, 255, 255, 0.8);
}

.range-number {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.summary-card {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(58, 45, 23, 0.1);
  padding: 12px;
}

.summary-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-value {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
}

.builder-layout {
  display: grid;
  gap: 18px;
}

.builder-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.builder-toolbar-fields {
  display: grid;
  grid-template-columns: minmax(180px, 260px);
  gap: 12px;
  flex: 0 0 auto;
}

.builder-toolbar .palette {
  flex: 1 1 520px;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.palette-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 14px;
  border: 1px solid rgba(11, 114, 133, 0.22);
  background: var(--accent-soft);
  padding: 10px 12px;
  cursor: grab;
  font-weight: 600;
}

.palette-icon,
.element-kind-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.palette-icon.is-flipped,
.element-kind-icon.is-flipped {
  transform: scaleX(-1);
}

.axis-shell {
  border-radius: 20px;
  border: 1px solid rgba(54, 47, 33, 0.14);
  background:
    linear-gradient(180deg, rgba(11, 114, 133, 0.06), rgba(255, 255, 255, 0.55)),
    rgba(255, 255, 255, 0.6);
  padding: 16px;
  overflow-x: auto;
}

.axis-track {
  display: inline-flex;
  align-items: stretch;
  min-width: 100%;
  gap: 10px;
  padding: 12px 2px;
}

.gap-card,
.element-card,
.boundary-card,
.empty-drop-target {
  flex: 0 0 auto;
}

.empty-drop-target {
  width: 100%;
  min-height: 190px;
  border-radius: 20px;
  border: 2px dashed rgba(11, 114, 133, 0.28);
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}

.empty-drop-target.active {
  border-color: var(--accent);
  background: rgba(11, 114, 133, 0.12);
  color: var(--accent);
}

.gap-card,
.boundary-card {
  width: 138px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  align-items: center;
  justify-items: center;
  cursor: default;
}

.gap-pill {
  width: 100%;
  min-width: 104px;
  border-radius: 999px;
  padding: 6px 10px;
  text-align: center;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(52, 43, 26, 0.1);
  font-size: 0.82rem;
}

.gap-prop-button,
.gap-prop-editor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.gap-prop-button {
  appearance: none;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}

.gap-prop-button:hover,
.gap-prop-editor:focus-within {
  border-color: rgba(11, 114, 133, 0.34);
  box-shadow: 0 0 0 3px rgba(11, 114, 133, 0.08);
}

.gap-core {
  width: 100%;
  min-height: 78px;
  border-radius: 16px;
  border: 1px solid rgba(60, 50, 29, 0.12);
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  place-items: center;
  position: relative;
  text-align: center;
  padding: 10px;
}

.gap-core::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(11, 114, 133, 0.2), rgba(11, 114, 133, 0.75), rgba(11, 114, 133, 0.2));
}

.boundary-card .gap-core::before {
  background: linear-gradient(90deg, rgba(187, 62, 3, 0.16), rgba(187, 62, 3, 0.7), rgba(187, 62, 3, 0.16));
}

.gap-card.active .gap-core,
.boundary-card.active .gap-core {
  border-color: rgba(11, 114, 133, 0.55);
  background: rgba(11, 114, 133, 0.12);
}

.edge-label {
  position: relative;
  z-index: 1;
  font-size: 0.78rem;
  color: var(--muted);
}

.element-card {
  position: relative;
  width: 168px;
  min-height: 188px;
  border-radius: 20px;
  padding: 12px;
  border: 1px solid rgba(56, 46, 25, 0.12);
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-rows: auto auto 1fr auto;
  align-content: start;
}

.element-card.active {
  border-color: rgba(11, 114, 133, 0.55);
  background: rgba(11, 114, 133, 0.08);
}

.element-card[draggable="true"] {
  cursor: grab;
}

.element-card.dragging {
  opacity: 0.45;
  box-shadow: none;
}

.element-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.element-title-input {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  outline: none;
}

.element-title-input:focus {
  background: rgba(11, 114, 133, 0.08);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 0 0 3px rgba(11, 114, 133, 0.08);
}

.icon-button {
  appearance: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
  font-family: "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-button:hover {
  background: rgba(180, 35, 24, 0.16);
}

.element-kind {
  color: var(--muted);
  font-size: 0.82rem;
}

.element-kind-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.element-props {
  display: grid;
  gap: 6px;
}

.element-prop-button,
.element-prop-editor {
  width: 100%;
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(54, 45, 26, 0.12);
  background: rgba(255, 255, 255, 0.82);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.element-prop-button {
  appearance: none;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}

.element-prop-button:hover,
.element-prop-editor:focus-within {
  border-color: rgba(11, 114, 133, 0.36);
  box-shadow: 0 0 0 3px rgba(11, 114, 133, 0.08);
}

.element-prop-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.element-prop-value {
  font-weight: 700;
  font-size: 0.84rem;
  line-height: 1.1;
  white-space: nowrap;
}

.element-prop-input {
  min-width: 0;
  width: 54px;
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.84rem;
  line-height: 1.1;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  outline: none;
  appearance: textfield;
  white-space: nowrap;
}

.element-prop-input::-webkit-outer-spin-button,
.element-prop-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.element-prop-suffix {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.element-footer {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
}

.endpoint-button {
  appearance: none;
  border: 1px solid rgba(11, 114, 133, 0.22);
  border-radius: 999px;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  min-width: 98px;
}

.endpoint-button.active {
  background: rgba(11, 114, 133, 0.14);
  color: var(--accent);
  border-color: rgba(11, 114, 133, 0.34);
}

.messages {
  display: grid;
  gap: 10px;
}

.message {
  border-radius: 16px;
  padding: 12px 14px;
  line-height: 1.45;
}

.message.info {
  background: rgba(11, 114, 133, 0.09);
  color: #0d5d6c;
}

.message.error {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.message.warning {
  background: rgba(179, 71, 0, 0.11);
  color: var(--accent-strong);
}

.plot-panel {
  min-height: 620px;
}

.plot-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 220px));
  gap: 10px;
  margin-top: 16px;
}

.plot-stage {
  position: relative;
}

.plot-host {
  width: 100%;
  min-height: 560px;
}

.plot-readout {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  max-width: min(420px, calc(100% - 24px));
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(56, 46, 25, 0.12);
  box-shadow: 0 12px 28px rgba(70, 55, 24, 0.12);
  line-height: 1.45;
  color: var(--text);
  pointer-events: none;
}

.plot-readout-title {
  margin: 0 0 4px;
  font-size: 0.84rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.plot-readout-body {
  margin: 0;
  font-size: 0.92rem;
}

.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 820px) {
  .topbar {
    flex-direction: column;
  }

  .topbar-side {
    width: 100%;
    justify-items: start;
  }

  .toolbar-controls {
    grid-template-columns: 1fr;
  }
}
