:root {
  --bg: #000402;
  --panel: rgba(1, 7, 4, 0.94);
  --panel-soft: rgba(4, 13, 8, 0.78);
  --line: rgba(48, 255, 181, 0.18);
  --line-strong: rgba(48, 255, 181, 0.34);
  --text: #f3fff8;
  --muted: #7d9788;
  --soft: #4c6b5d;
  --accent: #00ffa2;
  --accent-secondary: #8e5eff;
  --danger: #ff6262;
  --warn: #ffca68;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #000;
  color: var(--text);
  font-family: "Rajdhani", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.45;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  background: #000;
}

.control-dock {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 18px 16px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(1, 7, 4, 0.97), rgba(0, 5, 3, 0.97));
}

.control-dock.collapsed {
  transform: translateX(-100%);
}

.dock-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  color: var(--accent);
  font-size: 24px;
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: 0.08em;
}

.dock-actions,
.button-row,
.metric-row,
.ai-row,
.triple-field,
.descriptor-meta,
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dock-section {
  padding: 0 4px 0 2px;
}

.cloud-section {
  padding-bottom: 24px;
}

.section-kicker {
  margin-bottom: 10px;
  color: var(--soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

.field-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  letter-spacing: 0.03em;
}

.field-head output {
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.hud-btn,
.icon-btn,
.primary-btn,
.ghost-btn,
.media-btn,
.style-btn,
.shape-btn,
.gallery-btn,
.ai-btn {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.hud-btn:hover,
.icon-btn:hover,
.primary-btn:hover,
.ghost-btn:hover,
.media-btn:hover,
.style-btn:hover,
.shape-btn:hover,
.gallery-btn:hover,
.ai-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.hud-btn,
.primary-btn,
.ghost-btn,
.media-btn,
.ai-btn {
  min-height: 40px;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-btn {
  border-color: var(--line-strong);
  background: rgba(0, 255, 162, 0.08);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.text-input,
.shape-name,
.code-input,
.idea-input,
.prompt-box,
.search-input,
.select-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.shape-name {
  min-height: 42px;
}

.text-input,
.shape-name {
  font-family: "Rajdhani", sans-serif;
  font-size: 15px;
  letter-spacing: 0.04em;
}

.text-input {
  min-height: 62px;
  resize: vertical;
}

.code-input,
.prompt-box {
  min-height: 190px;
  resize: vertical;
}

.idea-input {
  min-height: 92px;
  resize: vertical;
}

.text-input:focus,
.shape-name:focus,
.code-input:focus,
.idea-input:focus,
.prompt-box:focus,
.search-input:focus,
.select-input:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(0, 255, 162, 0.08);
}

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

.style-grid,
.shape-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.style-btn,
.shape-btn {
  min-height: 66px;
  padding: 8px 6px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  gap: 4px;
  text-align: center;
}

.style-btn span:first-child,
.shape-btn span:first-child {
  font-size: 18px;
  line-height: 1;
}

.style-btn span:last-child,
.shape-btn span:last-child {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.style-btn.active,
.shape-btn.active,
.gallery-btn.active {
  background: rgba(0, 255, 162, 0.1);
  border-color: var(--line-strong);
}

.media-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  margin-bottom: 10px;
}

.media-btn {
  justify-content: space-between;
  display: flex;
  align-items: center;
}

.media-btn strong {
  color: var(--danger);
}

.clear-btn {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: transparent;
  color: var(--danger);
  border-radius: 10px;
  font-size: 18px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

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

.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.control-row label {
  font-size: 13px;
  letter-spacing: 0.04em;
}

.control-row output {
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.control-row input[type="range"] {
  grid-column: 1 / -1;
}

.metric-row {
  margin: 10px 0 12px;
}

.metric {
  flex: 1 1 130px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.metric strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric span {
  font-size: 15px;
  letter-spacing: 0.03em;
}

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

.validation-item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.validation-item.good {
  border-color: rgba(0, 255, 162, 0.18);
  background: rgba(0, 255, 162, 0.06);
}

.validation-item.bad {
  border-color: rgba(255, 98, 98, 0.2);
  background: rgba(255, 98, 98, 0.06);
}

.validation-item.warn {
  border-color: rgba(255, 202, 104, 0.2);
  background: rgba(255, 202, 104, 0.06);
}

.validation-item b {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.validation-item small {
  color: var(--muted);
  line-height: 1.45;
}

.gallery-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 500px;
  overflow: auto;
  padding-right: 2px;
}

.gallery-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
}

.gallery-btn strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0.05em;
}

.gallery-btn small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.gallery-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  color: var(--soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stage-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 26%),
    radial-gradient(circle at 78% 16%, color-mix(in srgb, var(--accent-secondary) 14%, transparent), transparent 28%),
    #000;
}

.media-layer,
#preview,
.annotation-layer {
  position: absolute;
  inset: 0;
}

.media-layer {
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.media-layer img,
.media-layer video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.7;
  filter: saturate(0.9) contrast(1.05) brightness(0.65);
}

#preview {
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

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

.annotation {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.topbar,
.status-pill,
.scene-card {
  position: absolute;
  pointer-events: auto;
}

.topbar {
  top: 20px;
  right: 20px;
}

.status-pill {
  top: 180px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(1, 7, 4, 0.72);
  font-size: 14px;
  letter-spacing: 0.03em;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 18px rgba(255, 202, 104, 0.4);
}

.status-dot.good {
  background: var(--accent);
  box-shadow: 0 0 18px rgba(0, 255, 162, 0.42);
}

.status-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(255, 98, 98, 0.42);
}

.scene-card {
  right: 20px;
  bottom: 28px;
  width: min(320px, calc(100vw - 40px));
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(1, 7, 4, 0.78);
  backdrop-filter: blur(14px);
}

.scene-card h1 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.scene-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.descriptor-meta {
  margin-top: 14px;
}

.descriptor-meta span {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.modal-backdrop.open {
  display: flex;
}

.modal-panel {
  width: min(980px, 100%);
  max-height: calc(100vh - 36px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(1, 7, 4, 0.96);
}

.draw-panel {
  width: min(940px, 100%);
}

.draw-canvas {
  width: 100%;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    #030705;
  background-size: 24px 24px;
  touch-action: none;
}

.modal-head,
.modal-body {
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-head h2 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: 0.03em;
}

.modal-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-body {
  overflow: auto;
}

.guide-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.chip-btn {
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 12px;
}

.ai-btn {
  flex: 1 1 120px;
  text-align: left;
}

.ai-btn strong {
  display: block;
  margin-bottom: 3px;
}

.ai-btn span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  z-index: 12;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(1, 7, 4, 0.92);
  font-size: 13px;
  letter-spacing: 0.04em;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

  .control-dock {
    position: fixed;
    inset: 0 auto 0 0;
    width: 320px;
    max-width: calc(100vw - 48px);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.45);
  }

  .control-dock.open {
    transform: translateX(0);
  }

  .control-dock.collapsed {
    transform: translateX(-100%);
  }
}

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

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

  .topbar {
    left: 14px;
    right: 14px;
    justify-content: flex-start;
  }

  .status-pill {
    top: 76px;
    left: 14px;
    right: auto;
  }

  .scene-card {
    left: 14px;
    right: 14px;
    width: auto;
    bottom: 18px;
  }
}
