:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: #eeedf4;
  background: #101117;
  --panel: #181a23;
  --line: #303240;
  --muted: #b0b1c1;
  --accent: #b4a7ff;
  --accent-ink: #1b1530;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button {
  min-height: 33px;
  padding: 5px 9px;
  border: 1px solid #3b3d4c;
  border-radius: 6px;
  background: #242632;
  color: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
button:not(:disabled):hover { background: #303243; border-color: #6c6b83; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.shell { width: min(100% - 42px, 1520px); margin: 0 auto; }
.site-header { border-bottom: 1px solid #282b36; background: #13151d; }
.site-inner { min-height: 56px; display: flex; align-items: center; gap: 14px; }
.site-inner .brand-mark { width: 19px; background: #a596ff; }
.site-inner .brand-period { color: #a596ff; }
.site-divider { width: 1px; height: 15px; background: #414350; }
.app-name { color: var(--muted); font-size: 14px; }
.draft-status { margin-left: auto; color: var(--muted); font-size: 12px; }
main { padding: 24px 0 28px; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 15px; margin-bottom: 19px; }
h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.65rem); letter-spacing: -.065em; line-height: 1.15; }
.intro p { margin: 6px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.project-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.project-actions button { min-height: 37px; padding-inline: 12px; }
button.primary { background: #b2a4fb; border-color: #b2a4fb; color: var(--accent-ink); }
button.primary:not(:disabled):hover { background: #d2c8ff; border-color: #d2c8ff; }

.editor {
  display: grid;
  grid-template-columns: minmax(165px, 220px) minmax(0, 1fr) minmax(236px, 278px);
  grid-template-rows: minmax(330px, 1fr) auto;
  grid-template-areas: 'layers stage inspector' 'timeline timeline inspector';
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
}
.panel { min-width: 0; }
.panel-heading { min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 11px; border-bottom: 1px solid var(--line); background: #1c1e28; }
.panel-heading h2, .transform-heading h3 { margin: 0; font-size: 14px; font-weight: 760; }
.panel-heading output { color: var(--muted); font-size: 12px; }
.layer-panel { grid-area: layers; display: grid; grid-template-rows: auto auto 1fr auto; min-height: 0; border-right: 1px solid var(--line); }
.add-tools, .layer-tools { display: flex; gap: 4px; padding: 8px; }
.add-tools button, .layer-tools button { flex: 1; padding-inline: 3px; white-space: nowrap; }
.layer-tools { border-top: 1px solid var(--line); }
.layer-list { margin: 0; padding: 0 6px; list-style: none; overflow: auto; max-height: 365px; }
.layer-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; margin: 2px 0; border: 1px solid transparent; border-radius: 6px; }
.layer-item.is-selected { border-color: #9788ef; background: #302949; }
.layer-item .pick-layer, .layer-item .layer-visible { min-width: 0; border: 0; background: transparent; font-weight: 550; }
.layer-item .pick-layer { display: flex; gap: 7px; align-items: center; padding-inline: 6px; text-align: left; }
.layer-item .layer-visible { min-width: 27px; padding-inline: 3px; color: #d9d5ef; }
.layer-item .layer-visible[aria-pressed=false] { color: var(--muted); opacity: .62; }
.layer-type { display: grid; place-items: center; flex: 0 0 20px; height: 19px; background: #2b2e43; color: var(--accent); border-radius: 4px; font: 650 12px ui-monospace, monospace; }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-list, .empty-layer { margin: 0; padding: 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }

.stage-panel { grid-area: stage; display: grid; grid-template-rows: auto 1fr auto; min-height: 0; background: #161821; }
.history-actions { display: flex; gap: 4px; }
.history-actions button { min-height: 28px; min-width: 30px; padding: 1px 6px; font-size: 17px; }
.stage-surround { display: grid; place-items: center; padding: 16px; background-color: #13151d; background-image: radial-gradient(#666d8847 1px, transparent 1px); background-size: 16px 16px; }
.stage-inner { position: relative; width: min(100%, 850px, max(440px, calc((100dvh - 450px) * 16 / 9))); aspect-ratio: 16 / 9; overflow: hidden; border-radius: 3px; background: #10131b; box-shadow: 0 10px 23px #0007; }
#composition { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
#composition.is-dragging { cursor: grabbing; }
.selection { pointer-events: none; position: absolute; transform: translate(-50%, -50%) rotate(var(--layer-angle, 0deg)); border: 1px solid #c6baff; box-shadow: 0 0 0 1px #2e2350ab; }
.stage-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 5px 12px; padding: 7px 11px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

.inspector { grid-area: inspector; border-left: 1px solid var(--line); }
.inspector-section { display: grid; gap: 7px; padding: 10px; border-bottom: 1px solid var(--line); }
.inspector-section label { display: block; color: #d1d1de; font-size: 13px; font-weight: 620; }
.inspector-section :is(input, textarea, select) { display: block; width: 100%; min-width: 0; min-height: 31px; padding: 4px 7px; border: 1px solid #3b3e4c; border-radius: 5px; background: #12141c; color: #eeedf4; font-size: 13px; }
.inspector-section label :is(input, textarea, select) { margin-top: 4px; }
.inspector-section textarea { resize: vertical; }
.inspector-section input[type=color] { height: 31px; padding: 3px; }
.property-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.transform-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
#key-state { color: var(--accent); font-size: 12px; }
.key-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; margin-top: 2px; }
button.key-button { border-color: #7368aa; background: #393053; color: #eadfff; }

.timeline-panel { grid-area: timeline; min-width: 0; border-top: 1px solid var(--line); }
.timeline-heading { flex-wrap: wrap; padding-block: 5px; }
.transport { display: flex; align-items: center; gap: 4px; }
.transport button { min-height: 29px; min-width: 29px; padding: 0 6px; }
#play { width: 38px; background: #38324f; color: #ebdfff; }
#loop[aria-pressed=true] { border-color: #a799ef; color: #e1d6ff; }
#timecode { padding-inline: 7px; white-space: nowrap; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }

.export-progress, .notice { position: fixed; right: 14px; bottom: 14px; z-index: 2; display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 28px); margin: 0; padding: 9px 11px; border: 1px solid #666185; border-radius: 8px; background: #28263a; color: #f4ecff; box-shadow: 0 10px 24px #0007; font-size: 13px; }
.export-progress progress { accent-color: var(--accent); width: clamp(50px, 15vw, 135px); }
.notice { overflow-wrap: anywhere; display: block; }

@media (max-width: 960px) {
  .editor { grid-template-columns: minmax(150px, 190px) minmax(0, 1fr) minmax(220px, 242px); }
  .stage-surround { padding: 9px; }
  .project-actions button { padding-inline: 8px; }
}
@media (max-width: 760px) {
  .shell { width: calc(100% - 24px); }
  main { padding-top: 17px; }
  .editor {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: 'stage stage' 'timeline timeline' 'layers inspector';
  }
  .layer-panel { align-self: start; border-right: 0; }
  .inspector, .layer-panel { border-top: 1px solid var(--line); }
  .stage-footer { font-size: 11px; }
}
@media (max-width: 460px) {
  .editor { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'stage' 'timeline' 'layers' 'inspector'; }
  .inspector { border-left: 0; }
  .layer-list { max-height: 164px; }
  .layer-panel { grid-template-rows: auto auto auto auto; }
  .site-inner { gap: 10px; }
  .draft-status { font-size: 11px; }
  .add-tools button, .layer-tools button { min-height: 37px; }
}
