:root {
  color-scheme: dark;
  --ink: #f7f3ea;
  --muted: #b8beb9;
  --panel: rgba(20, 25, 24, 0.88);
  --panel-solid: #171d1c;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #67d5b5;
  --accent-strong: #f7b267;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: #101414;
  color: var(--ink);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  height: calc(100vh - 82px);
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(103, 213, 181, 0.18), transparent 28rem),
    linear-gradient(140deg, #101414 0%, #20231f 48%, #13231f 100%);
}

.viewport {
  position: relative;
  height: calc(100vh - 82px);
  overflow: hidden;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 82px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 20, 20, 0.94);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(247, 178, 103, 0.16);
  object-fit: cover;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.55rem;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: min(36vw, 360px);
}

.preview-toggle {
  position: absolute;
  z-index: 3;
  top: 28px;
  right: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 25, 24, 0.78);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

.rotation-toggle {
  top: 82px;
}

.preview-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: calc(100vh - 82px);
  overflow-y: auto;
  padding: 28px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.quick-actions,
.stats {
  display: flex;
  align-items: center;
}

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

h2 {
  font-size: 1.75rem;
  line-height: 1;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202826;
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(103, 213, 181, 0.65);
}

.admin-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.admin-link:hover {
  border-color: rgba(103, 213, 181, 0.65);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.random-card {
  display: grid;
  gap: 12px;
}

.random-action {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 139, 122, 0.9);
  border-radius: 8px;
  background: #ff7a66;
  color: #101414;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(255, 122, 102, 0.24);
}

.random-action:hover {
  border-color: rgba(255, 190, 178, 0.98);
  background: #ff8f7d;
  box-shadow: 0 14px 32px rgba(255, 122, 102, 0.34);
}

.random-options {
  display: flex;
  width: 100%;
  gap: 8px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.random-options legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.random-options label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 0;
}

.random-options input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.random-options span {
  color: var(--ink);
  font-size: 0.72rem;
  text-align: center;
}

.quick-actions {
  gap: 10px;
}

.quick-actions button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #101414;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  background: var(--accent);
}

.secondary-action {
  background: var(--accent-strong);
}

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

.stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.stats span,
.controls span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 0.96rem;
  white-space: nowrap;
}

.controls {
  display: grid;
  gap: 17px;
}

.controls label {
  display: grid;
  gap: 9px;
}

.controls label > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.controls output {
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}

.control-section {
  display: grid;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.control-section[open] {
  gap: 14px;
}

.control-section summary {
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 900;
}

.control-section label:first-of-type {
  margin-top: 12px;
}

.control-section select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--ink);
  padding: 10px 12px;
}

.toggle-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 14px !important;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

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

.admin-page {
  min-height: 100vh;
  overflow: auto;
}

.admin-shell {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
}

.metric-card,
.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 33, 31, 0.86);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 102px;
  padding: 18px;
}

.metric-card span,
.data-row span,
.event-row span,
.event-row small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric-card strong {
  font-size: 2rem;
  line-height: 1;
}

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

.admin-panel {
  min-height: 260px;
  padding: 18px;
}

.wide-panel {
  grid-column: 1 / -1;
}

.panel-heading,
.data-row,
.event-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading h2 {
  font-size: 1rem;
}

.panel-heading button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(103, 213, 181, 0.45);
  border-radius: 8px;
  background: #202826;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.data-list,
.event-list {
  display: grid;
  gap: 10px;
}

.data-row,
.event-row {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.event-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, auto) minmax(90px, auto);
}

@media (max-width: 900px) {
  html,
  body {
    overflow: auto;
  }

  .top-bar {
    height: auto;
    min-height: 78px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 78px);
  }

  .viewport,
  #scene {
    height: 58vh;
    min-height: 58vh;
  }

  .control-panel {
    height: auto;
    min-height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .top-bar {
    align-items: flex-start;
    padding: 12px 16px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand p {
    font-size: 0.84rem;
  }

  .preview-toggle {
    top: 18px;
    right: 18px;
  }

  .control-panel {
    padding: 20px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 980px) {
  .admin-grid,
  .admin-panels {
    grid-template-columns: 1fr;
  }

  .event-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}
