:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  --page: #0a0e19;
  --panel: #101727;
  --field: #131c2e;
  --raised: #182338;
  --border: #253149;
  --text: #eaf0fb;
  --muted: #a5b2c9;
  --accent: #86edd1;
  --accent-bg: #142e36;
  --error: #ffa5a8;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  min-width: 0;
  font-size: 13px;
}

button, input, select, textarea { font: inherit; }
button, .button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  line-height: 1.2;
  text-decoration: none;
}

button:hover:not(:disabled), .button:hover { background: var(--raised); border-color: #3b4d69; }
button:disabled { opacity: .47; cursor: default; }
:focus-visible, .file-picker:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, .button.primary { border-color: #7cdeca; background: var(--accent); color: #071d20; font-weight: 650; }
button.primary:hover:not(:disabled) { background: #abfbe5; }
a { color: var(--accent); }

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select, textarea {
  min-width: 0;
  min-height: 33px;
  background: #0c1423;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
}

input[type="color"] { padding: 3px !important; min-width: 40px !important; cursor: pointer; }
input[type="checkbox"], input[type="range"], progress { accent-color: var(--accent); }
[data-error="true"] { color: var(--error) !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 62px;
  padding: 10px 19px;
  border-bottom: 1px solid #202a3e;
  background: #0d1321;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 21px;
  font-weight: 730;
  letter-spacing: -.045em;
}

.brand-mark {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 43%, #d2fff2 0 10%, #8ff2d5 12% 25%, transparent 28% 38%,
    #559f9c 39% 43%, #16323d 45% 64%, transparent 66%);
  box-shadow: 0 0 14px #65d9c328;
}

.project-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.project-tools { display: flex; gap: 7px; margin-left: auto; flex-wrap: wrap; }
.workspace {
  display: grid;
  grid-template-columns: minmax(172px, 198px) minmax(0, 1fr) minmax(332px, 365px);
  gap: 13px;
  height: calc(100dvh - 62px);
  padding: 13px 16px 15px;
}

.panel { min-height: 0; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.panel > summary { display: none; }
.library { overflow: auto; }
.library-inner { padding: 15px 11px; }
.section-label {
  margin: 0 7px 13px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
#scene-library { display: grid; gap: 5px; }
.scene-choice {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  justify-content: start;
  text-align: left;
  padding-inline: 8px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.scene-choice .mode-icon { color: #88a2bc; font-size: 17px; text-align: center; }
.scene-choice[aria-current="true"] { background: var(--accent-bg); color: #d9fff4; border-color: #2d555b; font-weight: 650; }
.scene-choice[aria-current="true"] .mode-icon { color: var(--accent); }

.stage { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.stage-head, .transport, .stage-foot { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.stage-head { min-height: 32px; justify-content: space-between; }
.stage-head h1 { margin: 0; font-size: 21px; font-weight: 680; letter-spacing: -.025em; }
.scene-status { color: var(--accent); font-size: 11px; }
.viewport {
  display: grid;
  place-items: center;
  flex: 1 1 280px;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid #26324a;
  border-radius: 11px;
  background: #070a13;
}
.viewport[data-drop="true"] { border-color: var(--accent); }
#scene-canvas { display: block; max-width: 100%; max-height: 100%; background: #070910; }
#scene-canvas:focus-visible { outline-offset: -2px; }
.stage-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #070a13e8;
  color: var(--muted);
  pointer-events: none;
}
.transport button { min-height: 35px; }
#sound-toggle[aria-pressed="true"] { border-color: #44847f; color: var(--accent); }
.time-value { margin-left: auto; color: var(--muted); min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.stage-foot { justify-content: space-between; min-height: 19px; }
.stage-foot p { margin: 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.stage:fullscreen { padding: 14px; background: var(--page); }
.inspector { overflow: hidden; }
.settings { height: 100%; overflow: auto; scrollbar-width: thin; scrollbar-color: #32425c transparent; }

dialog {
  color: var(--text);
  background: var(--panel);
  border: 1px solid #3a4a63;
  border-radius: 12px;
  padding: 0;
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
}
dialog::backdrop { background: #04070caa; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 15px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 16px; margin: 0; }
.dialog-body { padding: 14px 15px; }
.dialog-body p { margin: 0 0 12px; color: var(--muted); }
.dialog-body ul { margin: 0; padding-inline-start: 20px; }
.dialog-body li { margin: 0 0 8px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: center; }
.dialog-actions select { flex: 1 1 240px; }
.file-picker { position: relative; overflow: hidden; }
.file-picker input { position: absolute; opacity: 0; inset: 0; cursor: pointer; width: 100%; }

@media (max-width: 1040px) {
  .workspace { grid-template-columns: 163px minmax(0, 1fr) 322px; gap: 9px; padding-inline: 10px; }
  .topbar { padding-inline: 10px; gap: 13px; }
}

@media (max-width: 800px) {
  .topbar { min-height: auto; flex-wrap: wrap; padding: 9px 10px; gap: 8px 12px; }
  .brand { font-size: 19px; }
  .project-name { flex: 1; text-align: right; }
  .project-tools { width: 100%; margin: 0; gap: 5px; }
  .project-tools button { min-height: 33px; font-size: 12px; padding-inline: 8px; }
  .workspace { display: flex; flex-direction: column; height: auto; padding: 9px 9px 15px; }
  .stage { order: -1; }
  .stage-head { min-height: 28px; }
  .stage-head h1 { font-size: 18px; }
  .viewport { flex: 0 0 auto; height: min(51svh, 480px); min-height: 210px; }
  .transport { gap: 5px; }
  .transport button { padding-inline: 7px; }
  .time-value { min-width: 53px; }
  .panel > summary { display: list-item; padding: 11px; cursor: pointer; font-weight: 650; }
  .library-inner { padding-top: 3px; }
  .library-inner h2 { display: none; }
  #scene-library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings { height: auto; overflow: visible; }
  .stage:fullscreen .viewport { flex: 1; }
}
