:root {
  --primary: #8B5CF6;
  --primary-dim: rgba(139,92,246,0.15);
  --primary-glow: rgba(139,92,246,0.3);
  --accent: #F472B6;
  --accent-dim: rgba(244,114,182,0.15);
  --bg: #0F0B1E;
  --bg-card: rgba(15,11,30,0.85);
  --bg-input: rgba(10,8,22,0.9);
  --border: rgba(139,92,246,0.12);
  --border-hover: rgba(139,92,246,0.25);
  --text: #E2E8F0;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 250ms ease;
  --glass: rgba(15,11,30,0.65);
  --glass-border: rgba(139,92,246,0.08);
  --success: #10B981;
  --warning: #F59E0B;
}
[data-theme="light"] {
  --bg: #FAF5FF; --bg-card: rgba(255,255,255,0.9); --bg-input: #fff;
  --border: rgba(139,92,246,0.15); --border-hover: rgba(139,92,246,0.3);
  --text: #1E293B; --text-dim: #475569; --text-muted: #94A3B8;
  --glass: rgba(255,255,255,0.7); --glass-border: rgba(139,92,246,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100vh; line-height: 1.6;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(139,92,246,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(244,114,182,0.05) 0%, transparent 50%);
}
.app { max-width: 1500px; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; min-height: 100vh; }

.header { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.header-left { display: flex; align-items: center; gap: 10px; }
.logo { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: var(--primary-dim); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.header h1 { font-size: 1.2rem; font-weight: 700; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.header-right { display: flex; gap: 6px; align-items: center; }

.btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 14px; border-radius: var(--radius-sm); border: none; font-family: var(--font); font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #7C3AED; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--primary-dim); }
.btn-icon { background: transparent; border: 1px solid var(--border); color: var(--text-dim); width: 34px; height: 34px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: 1rem; }
.btn-icon:hover { background: var(--primary-dim); }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-danger { background: transparent; color: #EF4444; border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }

.main { flex: 1; display: grid; grid-template-columns: 260px 1fr 320px; gap: 14px; padding: 16px 0; }

.panel { background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; animation: fadeIn 0.3s ease; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 0.85rem; font-weight: 600; }
.panel-body { padding: 14px; flex: 1; overflow-y: auto; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.72rem; font-weight: 600; color: var(--text-dim); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.input { width: 100%; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: var(--font); font-size: 0.82rem; outline: none; transition: all var(--transition); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M3 5l3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }

.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.section-title { font-size: 0.78rem; font-weight: 600; color: var(--text-dim); margin-bottom: 10px; }

.presets-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.preset-btn { padding: 6px 8px; font-size: 0.72rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-dim); cursor: pointer; font-family: var(--font); transition: all var(--transition); text-align: center; }
.preset-btn:hover { border-color: var(--primary); color: var(--text); background: var(--primary-dim); }

.center-panel { display: flex; flex-direction: column; gap: 14px; }

.preview-body { display: flex; align-items: center; justify-content: center; min-height: 250px; }
.preview-stage { width: 100%; height: 250px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(var(--bg-input) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px; border-radius: var(--radius-sm); overflow: hidden; position: relative; }
.preview-element { width: 80px; height: 80px; background: linear-gradient(135deg, var(--primary), var(--accent)); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.preview-controls { display: flex; gap: 6px; }

.timeline-track { position: relative; height: 60px; background: var(--bg-input); border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 12px; overflow: hidden; }
.timeline-ruler { display: flex; justify-content: space-between; padding: 4px 8px; font-size: 0.6rem; color: var(--text-muted); font-family: var(--mono); }
.timeline-bar { position: absolute; bottom: 0; left: 0; right: 0; height: 30px; display: flex; align-items: center; padding: 0 8px; }
.timeline-marker { position: absolute; width: 14px; height: 14px; background: var(--primary); border: 2px solid var(--accent); border-radius: 50%; cursor: pointer; transform: translate(-50%, 0); transition: all 150ms ease; z-index: 2; }
.timeline-marker:hover, .timeline-marker.active { transform: translate(-50%, 0) scale(1.3); box-shadow: 0 0 8px var(--primary-glow); }
.timeline-connector { position: absolute; bottom: 7px; height: 2px; background: linear-gradient(90deg, var(--primary), var(--accent)); z-index: 1; }

.keyframe-list { display: flex; flex-direction: column; gap: 6px; }
.keyframe-chip { padding: 6px 10px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: space-between; font-size: 0.78rem; cursor: pointer; transition: all var(--transition); }
.keyframe-chip:hover, .keyframe-chip.active { border-color: var(--primary); background: var(--primary-dim); }
.keyframe-chip .kf-pct { font-weight: 600; color: var(--primary); font-family: var(--mono); }

.keyframe-editor .prop-group { margin-bottom: 10px; }
.keyframe-editor .prop-group label { font-size: 0.72rem; color: var(--text-dim); font-weight: 600; margin-bottom: 3px; display: block; }
.keyframe-editor .prop-input { width: 100%; padding: 6px 10px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: var(--font); font-size: 0.8rem; outline: none; }
.keyframe-editor .prop-input:focus { border-color: var(--primary); }
.empty-state { font-size: 0.82rem; color: var(--text-muted); text-align: center; padding: 20px; }

.code-output { background: var(--bg-input); border-radius: var(--radius-sm); padding: 12px; font-family: var(--mono); font-size: 0.78rem; line-height: 1.6; overflow: auto; max-height: 300px; white-space: pre-wrap; word-break: break-word; color: var(--text); margin-bottom: 8px; }

.footer { padding: 14px 0; text-align: center; font-size: 0.72rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: auto; }
kbd { background: var(--primary-dim); padding: 1px 5px; border-radius: 3px; font-family: var(--mono); font-size: 0.68rem; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

@media (max-width: 1024px) { .main { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .app { padding: 0 10px; } .header h1 { font-size: 1rem; } }
