:root {
  --bg: #06111f;
  --bg-soft: #0b1930;
  --panel: rgba(18, 34, 62, 0.9);
  --panel-2: rgba(16, 29, 53, 0.88);
  --line: rgba(156, 186, 255, 0.18);
  --line-strong: rgba(189, 214, 255, 0.34);
  --text: #eef5ff;
  --muted: #b8c8e6;
  --accent: #ffd23c;
  --accent-2: #58f0c1;
  --danger: #ff7a8b;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at top left, rgba(51, 112, 255, 0.2), transparent 35%),
    radial-gradient(circle at bottom right, rgba(18, 198, 159, 0.14), transparent 30%),
    linear-gradient(145deg, #030913 0%, #071323 46%, #040d1a 100%);
  color: var(--text);
  font-family: "Inter", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
  align-items: start;
}

.sidebar,
.scene-pane {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(9, 20, 39, 0.95), rgba(8, 18, 35, 0.82));
  box-shadow: var(--shadow);
}

.sidebar {
  border-radius: 28px;
  padding: 22px;
  overflow: auto;
  max-height: calc(100vh - 40px);
}

.scene-pane {
  border-radius: 32px;
  padding: 22px 22px 16px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 40px);
  position: sticky;
  top: 20px;
}

.brand-block,
.panel,
.scene-header {
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  font-weight: 700;
  font-family: "Chakra Petch", sans-serif;
}

h1,
h2 {
  margin: 0;
  font-family: "Chakra Petch", sans-serif;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 0.94;
  max-width: 10ch;
}

.brand-block .lede {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.panel {
  margin-top: 18px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 18px;
}

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

.panel-header h2 {
  font-size: 1.15rem;
}

.pill,
.ghost-button,
.remove-button {
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}

.pill {
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.ghost-button,
.remove-button {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.ghost-button:hover,
.remove-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 210, 60, 0.5);
  background: rgba(255, 210, 60, 0.1);
}

.panel-copy,
.scene-footer p,
.summary-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.86rem;
  color: #d4e2fb;
  font-weight: 600;
}

.field input,
.field textarea,
.type-name {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(205, 225, 255, 0.08);
  color: var(--text);
  padding: 14px 14px;
  outline: none;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.field input:focus,
.field textarea:focus,
.type-name:focus {
  border-color: rgba(255, 210, 60, 0.68);
  background: rgba(205, 225, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(255, 210, 60, 0.12);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.field-span-2 {
  grid-column: span 2;
}

.checkbox-field {
  justify-content: flex-end;
}

.checkbox-card {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(205, 225, 255, 0.06);
  padding: 12px 14px;
}

.checkbox-field input {
  width: 22px;
  height: 22px;
  margin-top: 4px;
  accent-color: var(--accent);
}

.pallet-list {
  display: grid;
  gap: 14px;
}

.pallet-card {
  border-radius: 22px;
  border: 1px solid rgba(164, 196, 255, 0.15);
  background: rgba(255, 255, 255, 0.035);
  padding: 14px;
}

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

.type-badge-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.type-badge {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06);
}

.type-name {
  font-family: "Chakra Petch", sans-serif;
  font-weight: 600;
}

.stats-panel .panel-header {
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(164, 196, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
}

.stat-card.accent {
  background: linear-gradient(180deg, rgba(255, 210, 60, 0.18), rgba(255, 210, 60, 0.08));
  border-color: rgba(255, 210, 60, 0.22);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
  font-family: "Chakra Petch", sans-serif;
}

.ai-grid {
  margin-top: 14px;
}

.ai-results {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.ai-result-card {
  border-radius: 18px;
  border: 1px solid rgba(164, 196, 255, 0.14);
  background: rgba(255, 255, 255, 0.035);
  padding: 14px;
}

.ai-result-card strong {
  display: block;
  margin-bottom: 6px;
  font-family: "Chakra Petch", sans-serif;
}

.ai-result-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.ai-result-card[data-allowed="yes"] {
  border-color: rgba(88, 240, 193, 0.25);
}

.ai-result-card[data-allowed="no"] {
  border-color: rgba(255, 122, 139, 0.28);
}

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

.scene-header h2 {
  font-size: clamp(2.8rem, 8vw, 5.8rem);
  line-height: 0.88;
}

.scene-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  flex-wrap: wrap;
}

.scene-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: inline-block;
}

.legend-swatch.loaded {
  background: linear-gradient(135deg, var(--accent), #eb9700);
}

.legend-swatch.open {
  background: rgba(170, 214, 255, 0.1);
}

.scene-viewport {
  position: relative;
  flex: none;
  height: min(65vh, 720px);
  min-height: 460px;
  border-radius: 26px;
  border: 1px solid var(--line);
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(69, 121, 255, 0.16), transparent 24%),
    linear-gradient(180deg, rgba(11, 22, 42, 0.96), rgba(8, 16, 30, 0.98));
}

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

.scene-footer {
  padding: 14px 6px 0;
}

.summary-message[data-state="warning"] {
  color: #ff7a8b;
}

.summary-message[data-state="good"] {
  color: #92f0d0;
}

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

  .scene-pane {
    position: static;
    height: 70vh;
  }
}

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

  .sidebar,
  .scene-pane {
    border-radius: 22px;
    padding: 16px;
  }

  .field-grid,
  .summary-grid,
  .trailer-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: auto;
  }

  .scene-header {
    flex-direction: column;
  }

  .scene-viewport {
    height: 52vh;
    min-height: 380px;
  }
}
