/* =====================================================
   BENZO STUDIO — Professional 2D Animation Editor
   World-class dark UI
   ===================================================== */

:root {
  --bg-0: #0b0b0f;
  --bg-1: #111116;
  --bg-2: #18181f;
  --bg-3: #1f1f28;
  --bg-4: #282833;
  --bg-hover: #2e2e3a;
  --bg-active: #353544;
  --border: #2a2a36;
  --border-2: #3a3a4a;
  --text: #ececf2;
  --text-2: #a0a0b4;
  --text-3: #6a6a80;
  --accent: #8b6cff;
  --accent-2: #a78bff;
  --accent-dim: rgba(139, 108, 255, 0.18);
  --accent-glow: rgba(139, 108, 255, 0.35);
  --cyan: #22d3ee;
  --green: #34d399;
  --red: #f43f5e;
  --orange: #fb923c;
  --yellow: #fbbf24;
  --stage-bg: #14141c;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --top-h: 42px;
  --tl-h: 168px;
  --tb-w: 52px;
  --rp-w: 268px;
  --radius: 6px;
  --shadow: 0 8px 32px rgba(0,0,0,.55);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg-0);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; color: inherit; }

.hidden { display: none !important; }

/* ========== SPLASH ========== */
#splash {
  position: fixed; inset: 0;
  background: var(--bg-0);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity .5s, visibility .5s;
}
#splash.fade { opacity: 0; visibility: hidden; }
.splash-logo {
  font-size: 56px; color: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
  text-shadow: 0 0 40px var(--accent-glow);
}
.splash-title {
  font-size: 22px; font-weight: 700; letter-spacing: 6px;
  margin-top: 12px;
}
.splash-sub {
  color: var(--text-3); font-size: 12px; letter-spacing: 2px;
  margin-top: 6px; text-transform: uppercase;
}
.splash-bar {
  width: 180px; height: 3px; background: var(--bg-3);
  border-radius: 2px; margin-top: 28px; overflow: hidden;
}
.splash-fill {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--cyan));
  animation: load 1.4s ease forwards;
}
@keyframes pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: .85; }
}
@keyframes load {
  to { width: 100%; }
}

/* ========== APP ========== */
#app {
  display: flex; flex-direction: column;
  height: 100vh; width: 100vw;
}

/* ========== TOPBAR ========== */
#topbar {
  height: var(--top-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 10px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.tb-left { display: flex; align-items: center; gap: 14px; }
.tb-center { flex: 1; display: flex; justify-content: center; }
.tb-right { display: flex; align-items: center; gap: 6px; }

.brand {
  display: flex; align-items: center; gap: 5px;
  font-weight: 700; letter-spacing: 1px;
}
.brand-icon { color: var(--accent); font-size: 16px; }
.brand-name { font-size: 13px; }
.brand-pro {
  font-size: 9px; font-weight: 600; letter-spacing: 1px;
  background: var(--accent-dim); color: var(--accent-2);
  padding: 2px 5px; border-radius: 3px;
}

.menubar { display: flex; gap: 1px; }
.menu { position: relative; }
.menu-trigger {
  padding: 5px 10px; border-radius: 4px;
  color: var(--text-2); font-size: 12px;
}
.menu-trigger:hover, .menu.open .menu-trigger {
  background: var(--bg-hover); color: var(--text);
}
.menu-drop {
  display: none; position: absolute; top: 100%; left: 0;
  min-width: 220px; background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: 8px;
  padding: 4px; box-shadow: var(--shadow); z-index: 300;
}
.menu.open .menu-drop { display: block; }
.menu-drop button {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 7px 10px; border-radius: 5px;
  font-size: 12px; color: var(--text-2);
}
.menu-drop button:hover { background: var(--accent-dim); color: var(--accent-2); }
.menu-drop kbd {
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
}
.menu-drop hr {
  border: none; border-top: 1px solid var(--border); margin: 4px 0;
}

.project-name {
  background: transparent; border: 1px solid transparent;
  border-radius: 5px; padding: 4px 12px; text-align: center;
  font-size: 12.5px; font-weight: 500; width: 180px;
}
.project-name:hover, .project-name:focus {
  border-color: var(--border); background: var(--bg-3); outline: none;
}

.playback-group { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  width: 30px; height: 28px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 13px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.play-btn {
  width: 36px; height: 28px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.play-btn:hover { background: var(--accent-2); }
.play-btn.playing { background: var(--red); }

.fps-group {
  display: flex; align-items: center; gap: 4px;
  margin-left: 6px; color: var(--text-3); font-size: 11px;
}
.fps-group input {
  width: 40px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 5px; text-align: center; font-size: 11px;
}
.fps-group input:focus { outline: none; border-color: var(--accent); }

.sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* ========== WORKSPACE ========== */
#workspace {
  flex: 1; display: flex; min-height: 0;
}

/* Toolbar */
#toolbar {
  width: var(--tb-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center; padding: 6px 0; gap: 2px;
  overflow-y: auto; flex-shrink: 0;
}
.tool-group {
  display: flex; flex-direction: column; gap: 1px;
  width: 100%; align-items: center; padding: 2px 0;
}
.tool {
  width: 40px; height: 36px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); transition: .12s;
}
.tool svg { width: 20px; height: 20px; }
.tool:hover { background: var(--bg-hover); color: var(--text); }
.tool.active {
  background: var(--accent-dim); color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(139,108,255,.3);
}
.tool-sep {
  width: 28px; height: 1px; background: var(--border); margin: 5px 0;
}

.color-tools { padding: 6px 0; }
.swatch-pair {
  position: relative; width: 36px; height: 36px;
}
.swatch {
  width: 22px; height: 22px; border-radius: 5px;
  border: 2px solid var(--border-2); cursor: pointer;
  position: absolute;
}
.swatch.fill { background: #8b6cff; top: 0; left: 0; z-index: 2; }
.swatch.stroke {
  background: transparent; border: 3px solid #fff;
  bottom: 0; right: 0; z-index: 1;
}
.swap-colors, .default-colors {
  position: absolute; font-size: 9px; color: var(--text-3);
  width: 14px; height: 14px; display: flex; align-items: center; justify-content: center;
}
.swap-colors { top: -2px; right: -2px; }
.default-colors { bottom: -2px; left: -2px; }
.swap-colors:hover, .default-colors:hover { color: var(--text); }

.stroke-control {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 4px 0; color: var(--text-3); font-size: 10px;
}
.stroke-control input { width: 40px; accent-color: var(--accent); }
.brush-control {
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px 6px; font-size: 10px; color: var(--text-3); width: 100%;
}
.brush-control label { display: flex; flex-direction: column; gap: 1px; align-items: center; }
.brush-control input { width: 40px; accent-color: var(--accent); }

/* Stage */
#stage-area {
  flex: 1; display: flex; flex-direction: column;
  background: #08080c; position: relative; min-width: 0;
}
#rulers {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
}
#ruler-corner {
  position: absolute; top: 0; left: 0; width: 20px; height: 20px;
  background: var(--bg-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
#ruler-h {
  position: absolute; top: 0; left: 20px; right: 0; height: 20px;
  background: var(--bg-2);
}
#ruler-v {
  position: absolute; top: 20px; left: 0; bottom: 22px; width: 20px;
  background: var(--bg-2);
}

#stage-viewport {
  flex: 1; overflow: auto; display: flex;
  align-items: center; justify-content: center;
  position: relative;
}
#stage-container {
  position: relative;
  box-shadow: 0 0 0 1px var(--border), 0 12px 48px rgba(0,0,0,.5);
}
#stage, #overlay {
  display: block; position: absolute; top: 0; left: 0;
}
#stage { background: var(--stage-bg); }
#overlay { background: transparent; pointer-events: none; }

#status-bar {
  height: 22px; background: var(--bg-1); border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 12px;
  font-size: 11px; color: var(--text-3); font-family: var(--mono); flex-shrink: 0;
}

/* Right Panels */
#right-panels {
  width: var(--rp-w);
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.panel-tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.ptab {
  flex: 1; padding: 9px 4px; font-size: 11px; font-weight: 500;
  color: var(--text-3); text-align: center;
  border-bottom: 2px solid transparent;
}
.ptab:hover { color: var(--text-2); background: var(--bg-2); }
.ptab.active { color: var(--accent-2); border-bottom-color: var(--accent); }

.panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.panel.active { display: flex; }
.panel-toolbar {
  padding: 8px; border-bottom: 1px solid var(--border);
  display: flex; gap: 6px;
}
.panel-body {
  flex: 1; overflow-y: auto; padding: 10px;
}
.empty-state {
  color: var(--text-3); text-align: center; padding: 24px 12px;
  font-size: 12px; line-height: 1.5;
}

.sm-btn {
  padding: 5px 10px; background: var(--bg-3); border-radius: 5px;
  font-size: 11px; color: var(--text-2);
}
.sm-btn:hover { background: var(--bg-hover); color: var(--text); }
.sm-btn.active { background: var(--accent-dim); color: var(--accent-2); }

.prop-section { margin-bottom: 14px; }
.prop-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-3); margin-bottom: 8px; font-weight: 600;
}
.prop-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.prop-row label {
  width: 42px; font-size: 11px; color: var(--text-3); flex-shrink: 0;
}
.prop-row input[type="number"],
.prop-row input[type="text"],
.prop-row select {
  flex: 1; min-width: 0;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 4px; padding: 5px 7px; font-size: 12px;
}
.prop-row input:focus, .prop-row select:focus {
  outline: none; border-color: var(--accent);
}
.prop-row input[type="color"] {
  width: 28px; height: 26px; border: none; border-radius: 4px;
  cursor: pointer; background: none; padding: 0;
}
.prop-row .check {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-2); width: auto;
}
.prop-row .check input { accent-color: var(--accent); }

.align-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
}
.align-grid button {
  padding: 8px; background: var(--bg-3); border-radius: 5px;
  font-size: 14px; color: var(--text-2);
}
.align-grid button:hover { background: var(--bg-hover); color: var(--text); }
.panel-hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Library items */
.lib-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 6px; cursor: pointer;
}
.lib-item:hover { background: var(--bg-hover); }
.lib-thumb {
  width: 32px; height: 32px; background: var(--bg-3);
  border-radius: 4px; border: 1px solid var(--border);
}
.lib-name { font-size: 12px; }

/* ========== TIMELINE ========== */
#timeline {
  height: var(--tl-h);
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  display: flex; flex-shrink: 0;
}

.tl-left {
  width: 160px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.tl-layers-header {
  height: 32px; display: flex; align-items: center; gap: 2px;
  padding: 0 6px; border-bottom: 1px solid var(--border);
}
.tl-layers-header button {
  width: 24px; height: 22px; border-radius: 4px;
  background: var(--bg-3); color: var(--text-3); font-size: 12px;
}
.tl-layers-header button:hover { background: var(--bg-hover); color: var(--text); }

#layerLabels {
  flex: 1; overflow-y: auto;
}
.layer-label {
  height: 28px; display: flex; align-items: center; gap: 6px;
  padding: 0 8px; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: 11px;
}
.layer-label:hover { background: var(--bg-2); }
.layer-label.active { background: var(--accent-dim); }
.layer-label .vis {
  width: 16px; text-align: center; color: var(--text-3); font-size: 11px;
}
.layer-label .vis.off { opacity: .3; }
.layer-label .lock { width: 14px; color: var(--text-3); font-size: 10px; }
.layer-label .name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tl-right {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.tl-controls {
  height: 32px; display: flex; align-items: center; gap: 6px;
  padding: 0 10px; border-bottom: 1px solid var(--border);
}
.onion-opts { display: flex; gap: 3px; }
.onion-opts input {
  width: 32px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 3px; padding: 2px 4px; text-align: center; font-size: 11px;
}
.frame-readout {
  margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-3);
}
.frame-readout b { color: var(--accent-2); }

#tlScroll {
  flex: 1; overflow: auto; position: relative;
}
#tlHeaders {
  display: flex; height: 20px; position: sticky; top: 0;
  background: var(--bg-2); z-index: 2; border-bottom: 1px solid var(--border);
}
.tl-hcell {
  width: 28px; min-width: 28px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--text-3); font-family: var(--mono);
  border-right: 1px solid var(--border); flex-shrink: 0;
}
.tl-hcell.current { background: var(--accent-dim); color: var(--accent-2); }

#tlTracks { display: flex; flex-direction: column; }
.tl-track {
  height: 28px; display: flex; border-bottom: 1px solid var(--border);
}
.tl-cell {
  width: 28px; min-width: 28px; height: 28px;
  border-right: 1px solid var(--border); flex-shrink: 0;
  position: relative; cursor: pointer;
}
.tl-cell:hover { background: rgba(255,255,255,.03); }
.tl-cell.current { background: var(--accent-dim); }
.tl-cell.has-key::after {
  content: ''; position: absolute;
  left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(45deg);
  width: 7px; height: 7px; background: var(--accent);
  border-radius: 1px;
}
.tl-cell.has-tween {
  background: linear-gradient(90deg, rgba(139,108,255,.12), rgba(34,211,238,.08));
}
.tl-cell.has-tween::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; background: var(--accent); opacity: .4;
}

/* ========== MODALS ========== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  z-index: 2000;
}
.modal.show { display: flex; }
.modal-card {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 12px; padding: 28px 32px; max-width: 400px;
  width: 90%; text-align: center; box-shadow: var(--shadow);
}
.modal-card.wide { max-width: 560px; }
.modal-card h2 { font-size: 18px; margin-bottom: 10px; }
.tagline { color: var(--accent-2); font-size: 13px; margin-bottom: 12px; }
.ver { color: var(--text-3); font-size: 11px; margin-top: 12px; }
.about-logo { font-size: 40px; color: var(--accent); margin-bottom: 8px; }
.shortcuts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  text-align: left; margin: 18px 0; font-size: 12px;
}
.shortcuts kbd {
  display: inline-block; background: var(--bg-3);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 6px; font-family: var(--mono); font-size: 10px;
  margin-right: 4px;
}
.btn-primary {
  padding: 8px 20px; background: var(--accent); color: #fff;
  border-radius: 6px; font-size: 13px; font-weight: 500;
}
.btn-primary:hover { background: var(--accent-2); }

/* Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a5a; }

/* Responsive */
@media (max-width: 1100px) {
  :root { --rp-w: 220px; --tb-w: 46px; }
}
