:root {
  --bg: #0b1017;
  --bg-accent: #121a25;
  --panel: rgba(13, 19, 29, 0.92);
  --panel-border: rgba(125, 156, 198, 0.18);
  --text: #edf3ff;
  --muted: #97a8c2;
  --soft: #5d708f;
  --primary: #36d0b2;
  --primary-strong: #1ea78d;
  --warning: #ff8d5a;
  --danger: #ff6176;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --radius-sm: 12px;
  --mono: "DejaVu Sans Mono", "Liberation Mono", monospace;
  --ui: "DejaVu Sans", "Liberation Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(54, 208, 178, 0.08), transparent 36%),
    radial-gradient(circle at top right, rgba(255, 141, 90, 0.08), transparent 30%),
    linear-gradient(180deg, #0a0f15 0%, #0d1420 45%, #091018 100%);
  color: var(--text);
  font-family: var(--ui);
}

body {
  min-height: 100vh;
}

.app-shell {
  padding: 22px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
}

h1,
h2 {
  margin: 0;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

h1 {
  font-size: 2.05rem;
}

h2 {
  font-size: 1rem;
}

.subtitle {
  max-width: 900px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.host-badge {
  min-width: 180px;
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: rgba(10, 15, 25, 0.72);
  box-shadow: var(--shadow);
  text-align: right;
}

.host-badge span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.host-badge strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.app-grid {
  display: grid;
  grid-template-columns: 330px minmax(480px, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.panel,
.center-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  position: relative;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(15, 22, 34, 0.96), rgba(10, 16, 24, 0.94));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(54, 208, 178, 0.24), transparent 40%);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.step-flow {
  display: grid;
  gap: 10px;
  padding-left: 18px;
  margin: 14px 0 4px;
}

.step-flow li {
  color: var(--muted);
  padding-left: 4px;
}

.step-flow li.active {
  color: var(--text);
}

.step-flow li.done {
  color: var(--primary);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
}

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

input,
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(123, 154, 195, 0.22);
  border-radius: 12px;
  background: rgba(7, 12, 20, 0.94);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(54, 208, 178, 0.65);
  box-shadow: 0 0 0 3px rgba(54, 208, 178, 0.14);
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
}

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), #5ce0c6);
  color: #03231c;
  font-weight: 700;
}

.secondary-btn {
  width: 100%;
  background: rgba(54, 208, 178, 0.12);
  border: 1px solid rgba(54, 208, 178, 0.28);
  color: var(--text);
}

.helper,
.muted {
  color: var(--muted);
}

.mono-block,
.activity-log {
  padding: 12px;
  border-radius: 14px;
  background: rgba(6, 10, 16, 0.88);
  border: 1px solid rgba(123, 154, 195, 0.14);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.activity-log {
  min-height: 120px;
  max-height: 220px;
  overflow: auto;
}

.control-grid,
.advanced-grid,
.settings-form {
  display: grid;
  gap: 12px;
}

.advanced-panel {
  padding: 12px;
  border-radius: 14px;
  background: rgba(8, 13, 21, 0.78);
  border: 1px solid rgba(123, 154, 195, 0.12);
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--text);
  list-style: none;
}

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

.advanced-grid {
  margin-top: 12px;
}

.viewer-card,
.heatmap-card,
.deform-card {
  min-height: 360px;
}

.viewer-surface {
  min-height: 540px;
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(54, 208, 178, 0.06), transparent 40%),
    linear-gradient(180deg, rgba(10, 16, 26, 0.98), rgba(5, 9, 15, 0.98));
  border: 1px solid rgba(123, 154, 195, 0.12);
  overflow: hidden;
}

.canvas-layout {
  display: grid;
  gap: 12px;
}

#bedCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(8, 12, 20, 0.96), rgba(4, 8, 15, 0.98));
  border: 1px solid rgba(123, 154, 195, 0.12);
}

.hover-card {
  min-height: 92px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(5, 10, 16, 0.9);
  border: 1px solid rgba(123, 154, 195, 0.16);
  line-height: 1.45;
}

.deform-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
}

.deform-field input[type="range"] {
  padding: 0;
  cursor: pointer;
}

.deform-scale-readout {
  display: grid;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(5, 10, 16, 0.9);
  border: 1px solid rgba(123, 154, 195, 0.14);
  text-align: right;
}

.deform-scale-readout span {
  color: var(--muted);
  font-size: 0.82rem;
}

.deform-scale-readout strong {
  font-family: var(--mono);
  font-size: 1.15rem;
}

.deform-surface {
  min-height: 420px;
  margin-bottom: 12px;
}

.score-card {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background:
    radial-gradient(circle at left top, rgba(54, 208, 178, 0.18), transparent 48%),
    rgba(7, 13, 21, 0.92);
  border: 1px solid rgba(54, 208, 178, 0.18);
}

.score-card span,
.score-card small {
  color: var(--muted);
}

.score-card strong {
  font-family: var(--mono);
  font-size: 2.7rem;
  line-height: 1;
}

.stats-grid,
.list-block {
  display: grid;
  gap: 10px;
}

.stat-row,
.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(5, 10, 16, 0.82);
  border: 1px solid rgba(123, 154, 195, 0.1);
}

.list-row span:last-child,
.stat-row span:last-child {
  color: var(--text);
  font-family: var(--mono);
}

.pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(125, 156, 198, 0.12);
  color: var(--muted);
  border: 1px solid rgba(125, 156, 198, 0.14);
}

.pill.good {
  color: var(--primary);
  border-color: rgba(54, 208, 178, 0.24);
  background: rgba(54, 208, 178, 0.1);
}

.pill.warn {
  color: var(--warning);
  border-color: rgba(255, 141, 90, 0.24);
  background: rgba(255, 141, 90, 0.1);
}

.pill.bad {
  color: var(--danger);
  border-color: rgba(255, 97, 118, 0.24);
  background: rgba(255, 97, 118, 0.12);
}

.warning-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #ffd0b3;
  border: 1px solid rgba(255, 141, 90, 0.2);
  background: rgba(255, 141, 90, 0.12);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 10, 0.74);
  backdrop-filter: blur(7px);
  z-index: 999;
}

.loading-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 22px 28px;
  border-radius: 18px;
  background: rgba(11, 18, 27, 0.96);
  border: 1px solid rgba(125, 156, 198, 0.16);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(54, 208, 178, 0.18);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1450px) {
  .app-grid {
    grid-template-columns: 300px minmax(420px, 1fr) 300px;
  }
}

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

  .viewer-surface {
    min-height: 420px;
  }

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

  #bedCanvas {
    aspect-ratio: 1 / 1;
  }
}
