:root {
  color-scheme: dark;
  --surface: #17141a;
  --panel: #211b24;
  --panel-raised: #29212c;
  --line: #403343;
  --line-quiet: #342a37;
  --text: #f8edf2;
  --muted: #c2adbf;
  --quiet: #a995a8;
  --amber: #ffbd85;
  --amber-ink: #30201c;
  --mint: #7be5ce;
  --rose: #f7a0b8;
  --radius: 15px;
  font: 14px/1.45 Inter, "Segoe UI", sans-serif;
}

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

body {
  min-width: 280px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(ellipse at 4% 0, #2a1c2b 0, transparent 47rem),
    radial-gradient(ellipse at 100% 70%, #211b25 0, transparent 52rem),
    var(--surface);
}

button, input, output { font: inherit; }
button { color: inherit; }
button, label.button { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, input:focus-visible, label.button:focus-within {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.app-header {
  border-bottom: 1px solid var(--line-quiet);
  background: #1e1720;
}

.app-header-inner, .workbench {
  width: min(100% - clamp(28px, 6vw, 88px), 1472px);
  margin-inline: auto;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  min-height: 68px;
  padding-block: 11px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  font: 800 18px/1 "Archivo Black", Inter, "Segoe UI", sans-serif;
  letter-spacing: .045em;
}

.brand-slash { color: var(--amber); margin-inline: 4px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #d9895e;
  border-radius: 8px;
  background: #37262c;
}

.brand-mark span {
  display: block;
  width: 18px;
  height: 14px;
  border-block: 2px solid var(--amber);
  border-inline: 3px dotted var(--amber);
  border-radius: 3px;
  transform: rotate(-11deg);
  background: #ffbd8530;
}

.header-actions, .mode-switch, .object-actions, .game-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.button, .mode-switch button, .tool-card, .object-row {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 650;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  line-height: 1.2;
  text-align: center;
}

.button-ghost { background: transparent; color: var(--muted); }
.button-ghost:hover:not(:disabled) { background: var(--panel-raised); color: var(--text); }
.button-quiet { background: var(--panel-raised); border-color: var(--line); }
.button-quiet:hover:not(:disabled) { background: #382c3c; }
.button-accent { background: var(--amber); color: var(--amber-ink); border-color: #ffcba2; }
.button-accent:hover { background: #ffd0a6; }

.workbench { padding-block: clamp(18px, 3vw, 35px) 20px; }

.project-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 18px;
}

.project-heading h1 {
  margin: 0;
  color: #fff3f4;
  font: 750 clamp(26px, 5vw, 44px)/1.05 "Bricolage Grotesque", Inter, "Segoe UI", sans-serif;
  letter-spacing: -.055em;
}

.project-heading p { margin: 7px 0 0; color: var(--muted); }

.mode-switch {
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #211a25;
}

.mode-switch button {
  padding: 7px 13px;
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.mode-switch button:hover:not(:disabled) { background: #3a2b3b; color: var(--text); }
.mode-switch button[aria-pressed="true"] { background: #604338; color: #ffe7d4; border-color: #8d6251; }
.mode-switch button span { padding-inline-end: 3px; font-size: .8em; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 285px);
  align-items: start;
  gap: 15px;
}

.viewer, .inspector-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 16px 50px #0b070d38;
}

.viewer { overflow: hidden; }

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  padding: 9px 13px;
}

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

.clip-icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  border: 1px solid #6c4e56;
  border-radius: 6px;
  color: var(--amber);
  background: #382a34;
  font-size: 18px;
}

.clip-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#clip-name, #clip-info {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#clip-info { font-size: 11px; color: var(--quiet); }

.mode-label {
  flex: 0 0 auto;
  border-radius: 5px;
  padding: 3px 7px;
  background: #422f3c;
  border: 1px solid #624757;
  color: #f4cad3;
  font: 600 11px/1.3 "IBM Plex Mono", Consolas, monospace;
}

body[data-mode="play"] .mode-label { background: #253d3a; border-color: #40675d; color: var(--mint); }

.stage-shell {
  display: grid;
  place-items: center;
  min-width: 0;
  background:
    radial-gradient(ellipse at center, #1d131e 0, #120f15 80%);
  border-block: 1px solid var(--line-quiet);
}

#scene {
  display: block;
  max-width: 100%;
  max-height: min(58vh, 680px);
  width: auto;
  height: auto;
  background: #141016;
  touch-action: none;
}

body[data-mode="edit"] #scene:not([data-tool="select"]) { cursor: crosshair; }

.timeline { padding: 9px 13px 12px; }

.timeline-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timeline-top label { font-weight: 650; }
.transport { min-width: 34px; min-height: 31px; padding: 4px; }
.transport[data-playing="true"] { color: var(--mint); }

.timecode {
  margin-inline-start: auto;
  color: var(--amber);
  white-space: nowrap;
  font: 600 12px/1.3 "IBM Plex Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.timeline-track { position: relative; }

#scrub {
  display: block;
  width: 100%;
  height: 29px;
  margin: 2px 0 0;
  padding: 0;
  border-radius: 5px;
  cursor: ew-resize;
  accent-color: var(--amber);
}

#scrub:disabled { cursor: default; }

#timeline-marks {
  position: absolute;
  inset: auto 7px -1px;
  height: 10px;
  pointer-events: none;
}

#timeline-marks:empty { display: none; }

.timeline-marker {
  position: absolute;
  top: 0;
  width: 12px;
  height: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateX(-50%);
  cursor: pointer;
  pointer-events: auto;
}

.timeline-marker::before {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  margin: auto;
  transform: rotate(45deg);
  border-radius: 1px;
  background: var(--mint);
}

.stage-note { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.game-controls { border-top: 1px solid var(--line-quiet); padding: 10px 13px; }
.game-key { min-width: 43px; touch-action: none; user-select: none; }
.game-key:active, .game-key[aria-pressed="true"] { color: var(--amber-ink); background: var(--mint); }
.game-jump { min-width: 75px; }
#restart-button { margin-inline-start: auto; }

.inspector { display: grid; gap: 11px; }
.inspector-panel { padding: 12px; }

.inspector-panel h2 {
  margin: 0 0 9px;
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
}

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

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-height: 49px;
  padding: 7px 6px;
  background: #2c2430;
  border-color: #49394b;
  color: #eedfeb;
  text-align: left;
  font-size: 11px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.tool-card:hover:not(:disabled) { background: #3a2c3d; border-color: #7b5d78; }
.tool-card[aria-pressed="true"], .tool-card.is-selected, .tool-card.active { background: #4d352f; border-color: #bf815f; color: #ffe6d5; }
.tool-icon { display: inline-grid; place-items: center; flex: 0 0 15px; font-size: 14px; line-height: 1; }
.icon-static { color: var(--amber); }
.icon-moving, .icon-start { color: var(--mint); }
.icon-finish { color: var(--rose); }
.icon-select { color: #ebcee7; }

.object-list {
  display: grid;
  gap: 5px;
  max-height: 209px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-color: #72566c transparent;
  padding: 2px;
  margin: -2px;
}

.object-list:empty::before { content: "Добавьте объекты на кадр."; color: var(--quiet); font-size: 12px; padding: 3px 0; }
.object-list p { margin: 3px 0; font-size: 12px; color: var(--muted); }

.object-list button, .object-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line-quiet);
  border-radius: 6px;
  color: var(--text);
  background: #291f2b;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
}

.object-list button:hover { border-color: #795d78; }
.object-list button[aria-pressed="true"], .object-list .is-selected, .object-list .active { border-color: #ae7c66; background: #493330; }
.object-kind { color: var(--muted); font-size: 11px; }
.object-actions { margin-top: 9px; gap: 4px; }
.object-actions .button { min-height: 30px; font-size: 11px; padding-inline: 8px; }

.play-guide { display: none; }
.play-guide p { margin: 4px 0; color: var(--muted); }
kbd {
  display: inline-block;
  margin-inline-end: 3px;
  padding: 2px 4px;
  background: #362a3b;
  border: 1px solid #59435d;
  border-radius: 4px;
  color: #f6e8f7;
  font: 12px/1.15 "IBM Plex Mono", Consolas, monospace;
}

body[data-mode="play"] #draw-tools, body[data-mode="play"] .object-panel { display: none; }
body[data-mode="play"] .play-guide { display: block; }

.workbench-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 16px;
  padding: 9px 2px;
  color: var(--muted);
  font-size: 12px;
}

.workbench-foot p { margin: 0; }
#status[data-tone="success"] { color: var(--mint); }
#status[data-tone="error"] { color: var(--rose); }
.privacy-note { color: var(--quiet); }

@media (max-width: 775px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 225px; gap: 10px; }
  .inspector-panel { padding: 9px; }
}

@media (max-width: 650px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .inspector { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  body[data-mode="play"] .inspector { grid-template-columns: minmax(0, 1fr); }
  .tool-card { min-height: 42px; }
  #scene { max-height: 55vh; }
}

@media (max-width: 430px) {
  .app-header-inner { gap: 8px 10px; }
  .header-actions { gap: 5px; }
  .header-actions .button { min-height: 33px; padding-inline: 7px; font-size: 12px; }
  .inspector { grid-template-columns: minmax(0, 1fr); }
  .tool-card { min-height: 38px; }
  .project-heading { margin-bottom: 12px; gap: 10px; }
}

@media (pointer: coarse) {
  .game-key, .button[for], .transport { min-height: 44px; }
  #scrub { height: 41px; }
}
