* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #14171c;
  --panel: #1e232b;
  --panel-2: #262c36;
  --line: #333b48;
  --text: #e8ebf0;
  --muted: #8a93a3;
  --accent: #4a8cff;
  --gold: #e0b64e;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  gap: 12px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bar-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.bar-btn:hover { border-color: var(--accent); }
.pro-tag {
  font-size: 9px; font-weight: 700; color: var(--gold);
  border: 1px solid var(--gold); border-radius: 4px; padding: 1px 3px; margin-left: 3px;
  vertical-align: 2px;
}
.pro-cta { background: var(--gold); color: #1a1405; border-color: var(--gold); font-weight: 700; }
.pro-cta:hover { filter: brightness(1.08); }

#layout { flex: 1; display: flex; min-height: 0; }
#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#viewport { flex: 1; position: relative; min-width: 0; min-height: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; }

/* ---------- Timeline ---------- */
#timeline {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  height: 128px;
  flex-shrink: 0;
}
.tl-controls { display: flex; flex-direction: column; gap: 6px; width: 108px; flex-shrink: 0; }
.tl-controls button {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 8px; font-size: 12px; cursor: pointer;
}
.tl-controls button:hover:not(:disabled) { border-color: var(--accent); }
.tl-controls button:disabled { opacity: 0.4; cursor: default; }
.tl-row2 { display: flex; gap: 6px; }
.tl-row2 button { flex: 1; padding: 7px 0; }
#tl-strip {
  flex: 1; display: flex; gap: 8px;
  overflow-x: auto; overflow-y: hidden;
  align-items: center;
}
.tl-step {
  position: relative;
  width: 148px; height: 92px; flex-shrink: 0;
  border: 2px solid var(--line); border-radius: 8px;
  overflow: hidden; cursor: pointer;
  background: var(--panel-2);
}
.tl-step:hover { border-color: var(--muted); }
.tl-step.active { border-color: var(--accent); }
.tl-step img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tl-badge {
  position: absolute; top: 4px; left: 4px;
  background: rgba(20, 23, 28, 0.85); color: var(--text);
  border-radius: 5px; font-size: 11px; font-weight: 700;
  padding: 1px 6px;
}
.tl-notedot {
  position: absolute; bottom: 4px; right: 6px;
  color: var(--gold); font-size: 12px;
  text-shadow: 0 0 4px rgba(0,0,0,0.9);
}
.tl-addtile {
  width: 92px; height: 92px; flex-shrink: 0;
  border: 2px dashed var(--line); border-radius: 8px;
  background: none; color: var(--muted);
  font-size: 22px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tl-addtile span { font-size: 11px; }
.tl-addtile:hover { border-color: var(--accent); color: var(--accent); }

#hint {
  position: absolute; bottom: 14px; left: 14px;
  background: rgba(20, 23, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  pointer-events: none;
  display: none;
}
#flash {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  border-radius: 8px; padding: 8px 14px; font-size: 13px;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}

#sidebar {
  width: 300px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.panel h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 10px;
}

.fig-tabs { display: flex; gap: 8px; }
.fig-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; font-size: 13px; cursor: pointer;
}
.fig-tab.active { border-color: var(--accent); background: rgba(74, 140, 255, 0.12); }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-blue { background: #3566c4; }
.swatch-white { background: #e8e6df; }

.slider-row { display: grid; grid-template-columns: 92px 1fr 38px; align-items: center; gap: 8px; margin-bottom: 8px; }
.slider-row label { font-size: 12px; color: var(--muted); }
.slider-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-val { font-size: 11.5px; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.limit-note { font-size: 11px; color: var(--muted); margin-top: 6px; font-style: italic; }

.preset-btn {
  display: block; width: 100%; text-align: left;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; cursor: pointer; margin-bottom: 6px;
}
.preset-btn:hover { border-color: var(--accent); }

.toggle-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; font-size: 12.5px; color: var(--muted); cursor: pointer;
}
.toggle-row input { accent-color: var(--accent); }

#step-note {
  width: 100%; resize: vertical; min-height: 72px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; line-height: 1.5;
  font-family: inherit;
}
#step-note:focus { outline: none; border-color: var(--accent); }
#step-note:disabled { opacity: 0.5; }

#move-name {
  width: 100%;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; margin-bottom: 8px;
}
#move-name:focus { outline: none; border-color: var(--accent); }
.move-actions { display: flex; gap: 6px; margin-bottom: 4px; }
.move-actions button {
  flex: 1;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.move-actions button.ghost {
  flex: 0 0 64px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); font-weight: 400;
}
.move-actions button:hover { filter: brightness(1.1); }
.subhead { margin-top: 14px; }

.saved-row { display: flex; gap: 6px; margin-bottom: 6px; }
.saved-name {
  flex: 1; text-align: left;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.saved-name:hover { border-color: var(--accent); }
.saved-del {
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px;
  width: 30px; cursor: pointer; font-size: 15px;
}
.saved-del:hover { color: #ff6b6b; border-color: #ff6b6b; }
.empty-note { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

#pro-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center; justify-content: center; z-index: 50;
}
.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: min(420px, 92vw);
}
.modal-card h2 { margin-bottom: 8px; }
.modal-card p { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.modal-card ul { margin: 0 0 16px 18px; font-size: 14px; line-height: 1.9; }
.price-line { font-size: 16px; margin-bottom: 16px; }
.price-line strong { color: var(--gold); font-size: 22px; }
.modal-cta {
  display: block; text-align: center;
  background: var(--gold); color: #1a1405;
  font-weight: 700; text-decoration: none;
  border-radius: 10px; padding: 12px;
}
.modal-note { font-size: 12px !important; margin-top: 10px; margin-bottom: 0 !important; }
.modal-close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 22px; cursor: pointer;
}

@media (max-width: 760px) {
  #layout { flex-direction: column; }
  #stage { min-height: 60vh; }
  #viewport { min-height: 42vh; }
  #timeline { height: 108px; }
  .tl-step { width: 118px; height: 72px; }
  .tl-addtile { width: 72px; height: 72px; }
  #sidebar { width: 100%; border-left: none; border-top: 1px solid var(--line); flex: 1; }
}
