:root {
  --bg: #090909;
  --panel: #111214;
  --panel-2: #17191d;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.28);
  --text: #f4efe7;
  --muted: rgba(244, 239, 231, 0.62);
  --accent: #d26638;
  --accent-soft: rgba(210, 102, 56, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #050505;
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans TC", sans-serif;
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0)),
    var(--panel);
  padding: 18px;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
}

.brandbar,
.panel,
.workspace__topbar,
.canvas-frame,
.timeline-bar {
  border: 1px solid var(--line);
}

.brandbar {
  padding: 14px;
  margin-bottom: 16px;
  background: var(--panel-2);
}

.brandbar__title {
  font-size: 24px;
  font-weight: 700;
}

.brandbar__meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  padding: 14px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.panel__title,
.layer-group__label {
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stack-actions,
.split-grid {
  display: grid;
  gap: 8px;
}

.stack-actions {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
}

.stack-actions--single {
  grid-template-columns: 1fr;
}

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

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

.field span,
.inline-note {
  color: var(--muted);
  font-size: 12px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="color"],
.field select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #0f1012;
  color: var(--text);
}

.field input[type="range"] {
  width: 100%;
}

.action-btn,
.layer-item {
  border: 1px solid var(--line-strong);
  background: #151618;
  color: var(--text);
}

.action-btn {
  min-height: 40px;
  cursor: pointer;
}

.action-btn:hover,
.layer-item:hover {
  background: #1d1f22;
}

.action-btn--primary,
.layer-item.active {
  background: var(--accent);
  border-color: rgba(255,255,255,0.24);
  color: #fff;
}

.hidden-file-input {
  display: none;
}

.upload-box {
  display: grid;
  gap: 6px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.upload-box:hover,
.upload-box.is-dragover {
  background: rgba(210, 102, 56, 0.12);
  border-color: rgba(210, 102, 56, 0.82);
  transform: translateY(-1px);
}

.upload-box--alt:hover,
.upload-box--alt.is-dragover {
  background: rgba(255, 255, 255, 0.07);
}

.upload-box__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.upload-box__desc {
  font-size: 12px;
  color: var(--muted);
}

.analyze-stats,
.inline-note {
  min-height: 40px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.inline-note {
  min-height: 0;
}

.layer-groups {
  display: grid;
  gap: 12px;
}

.layer-list {
  display: grid;
  gap: 6px;
}

.layer-item {
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}

.layer-item__meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.workspace {
  position: sticky;
  top: 0;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    #0a0a0b;
  background-size: 32px 32px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.workspace__topbar,
.timeline-bar {
  min-height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 13px;
}

.preview-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.preview-controls .action-btn {
  min-height: 34px;
  padding: 0 12px;
}

.preview-controls input[type="range"] {
  width: min(220px, 100%);
}

.preview-zoom-text {
  min-width: 48px;
  text-align: right;
}

.canvas-frame {
  display: grid;
  place-items: center;
  min-height: 0;
  background:
    radial-gradient(circle at top, rgba(210,102,56,0.14), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)),
    #111;
  overflow: auto;
}

canvas {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: #101215;
  cursor: grab;
  flex: 0 0 auto;
}

canvas.dragging {
  cursor: grabbing;
}

.timeline-bar input[type="range"] {
  flex: 1;
}

.timeline-time {
  min-width: 130px;
  text-align: right;
}

.motion-count {
  color: var(--text);
  background: var(--accent-soft);
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .workspace {
    position: static;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .sidebar {
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .canvas-frame {
    padding: 18px 0;
  }

  canvas {
    width: min(100%, 1000px);
    max-height: none;
  }
}
