/* ══════════════════════════════════════════════════
   RupertG Editor — Stylesheet
   ══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:        #09090f;
  --bg2:       #0f1018;
  --surface:   #13141d;
  --surface2:  #1c1d2a;
  --surface3:  #22233a;
  --border:    #272838;
  --border2:   #32344a;
  --text:      #e8e9f4;
  --text2:     #7c7d99;
  --text3:     #50516a;
  --primary:   #7c3aed;
  --primary-h: #6d28d9;
  --accent:    #22d3ee;
  --green:     #22c55e;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --track-v:   #7c3aed;
  --track-a:   #0ea5e9;
  --track-t:   #f59e0b;
  --track-img: #ec4899;
  --r:         6px;
  --r2:        10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --topbar-h: 50px;
  --tl-h:     200px;
}

html, body { height: 100%; overflow: hidden; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 13px; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
input[type=range] { accent-color: var(--primary); cursor: pointer; }
select { appearance: none; }

/* ── TOP BAR ────────────────────────────────────── */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--topbar-h); padding: 0 12px; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  z-index: 200; flex-shrink: 0;
}
.tb-left, .tb-right, .tb-center { display: flex; align-items: center; gap: 6px; }
.tb-left { flex: 1; min-width: 0; }
.tb-right { flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; white-space: nowrap; flex-shrink: 0; }
.divider-v { width: 1px; height: 22px; background: var(--border2); flex-shrink: 0; }
.project-name {
  padding: 4px 8px; border-radius: var(--r); font-size: 13px; color: var(--text2);
  border: 1px solid transparent; cursor: text; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px; transition: all .15s;
}
.project-name:hover { background: var(--surface2); color: var(--text); }
.project-name:focus { border-color: var(--primary); color: var(--text); outline: none; background: var(--surface2); }
.save-status { font-size: 11px; color: var(--text3); white-space: nowrap; }

.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 6px;
  border: none; border-radius: var(--r); background: transparent; color: var(--text2);
  cursor: pointer; transition: all .15s;
}
.tb-btn:hover { background: var(--surface2); color: var(--text); }
.btn-export, .btn-signin {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  border: none; border-radius: var(--r); font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn-export { background: var(--primary); color: #fff; }
.btn-export:hover { background: var(--primary-h); }
.btn-signin { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.btn-signin:hover { background: var(--surface3); }

/* ── APP BODY ───────────────────────────────────── */
#appBody {
  display: flex;
  height: calc(100vh - var(--topbar-h) - var(--tl-h));
  overflow: hidden;
}

/* ── LEFT PANEL ─────────────────────────────────── */
#leftPanel {
  width: 240px; min-width: 240px; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); overflow: hidden;
}
.lp-tabs {
  display: flex; flex-shrink: 0; border-bottom: 1px solid var(--border); overflow-x: auto;
  scrollbar-width: none;
}
.lp-tabs::-webkit-scrollbar { display: none; }
.lp-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border: none; background: none; color: var(--text3);
  cursor: pointer; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid transparent; transition: all .15s; white-space: nowrap; min-width: 44px;
}
.lp-tab svg { flex-shrink: 0; }
.lp-tab:hover { color: var(--text2); }
.lp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.lp-content { flex: 1; overflow: hidden; position: relative; }
.lp-panel { display: none; height: 100%; overflow-y: auto; padding: 10px; }
.lp-panel.active { display: block; }

.drop-zone {
  border: 2px dashed var(--border2); border-radius: var(--r2); padding: 22px 12px;
  text-align: center; cursor: pointer; transition: all .2s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: rgba(124,58,237,.06); }
.drop-zone svg { color: var(--text3); margin: 0 auto 8px; display: block; }
.drop-zone p { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.drop-zone span { font-size: 11px; color: var(--text2); }

.media-list { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.media-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  background: var(--surface2); border-radius: var(--r); cursor: grab; transition: background .15s;
  border: 1px solid transparent;
}
.media-item:hover { background: var(--surface3); border-color: var(--border2); }
.media-item:active { cursor: grabbing; }
.mi-thumb {
  width: 42px; height: 28px; border-radius: 4px; background: var(--bg2); flex-shrink: 0;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.mi-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mi-thumb svg { color: var(--text3); }
.mi-info { flex: 1; min-width: 0; }
.mi-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 500; }
.mi-meta { font-size: 10px; color: var(--text2); margin-top: 1px; }
.mi-remove {
  background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px;
  border-radius: 4px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.mi-remove:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* Effects panel */
.panel-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); margin-bottom: 8px; }
.effects-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.effect-card {
  padding: 10px 8px; background: var(--surface2); border-radius: var(--r); text-align: center;
  cursor: pointer; font-size: 11px; font-weight: 600; border: 2px solid transparent; transition: all .15s;
}
.effect-card:hover { border-color: var(--primary); background: var(--surface3); }
.effect-card.applied { border-color: var(--accent); background: rgba(34,211,238,.08); color: var(--accent); }
.effect-icon { margin-bottom: 5px; opacity: .7; }
.effect-icon svg { display: block; margin: 0 auto; }

.adj-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.adj-row label { font-size: 11px; color: var(--text2); width: 60px; flex-shrink: 0; }
.adj-row input[type=range] { flex: 1; }
.adj-row span { font-size: 11px; color: var(--text3); width: 28px; text-align: right; }

/* Text panel */
.btn-add {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px; border: 2px dashed var(--border2); border-radius: var(--r); background: none;
  color: var(--text2); cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.btn-add:hover { border-color: var(--primary); color: var(--primary); background: rgba(124,58,237,.06); }

.text-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.text-item {
  background: var(--surface2); border-radius: var(--r); padding: 10px; border: 1px solid transparent;
  cursor: pointer; transition: border-color .15s;
}
.text-item:hover { border-color: var(--border2); }
.text-item.selected { border-color: var(--primary); }
.ti-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.ti-input {
  flex: 1; padding: 5px 8px; background: var(--bg); border: 1px solid var(--border2);
  border-radius: 4px; color: var(--text); font-family: inherit; font-size: 12px;
}
.ti-input:focus { outline: none; border-color: var(--primary); }
.ti-color { width: 28px; height: 28px; border: none; border-radius: 4px; cursor: pointer; padding: 2px; background: none; flex-shrink: 0; }
.ti-sub-row { display: flex; gap: 6px; align-items: center; }
.ti-select {
  flex: 1; padding: 4px 6px; background: var(--bg); border: 1px solid var(--border2);
  border-radius: 4px; color: var(--text); font-family: inherit; font-size: 11px;
}
.ti-num { width: 54px; padding: 4px 6px; background: var(--bg); border: 1px solid var(--border2);
  border-radius: 4px; color: var(--text); font-family: inherit; font-size: 11px; }
.ti-del {
  background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px;
  border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.ti-del:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* Misc panel styles */
.panel-note { font-size: 12px; color: var(--text2); line-height: 1.6; background: var(--surface2); border-radius: var(--r); padding: 10px; }
.trans-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.trans-card {
  padding: 14px 8px; background: var(--surface2); border-radius: var(--r); text-align: center;
  cursor: pointer; font-size: 11px; font-weight: 600; border: 2px solid transparent; transition: all .15s;
}
.trans-card:hover { border-color: var(--primary); }
.trans-card.applied { border-color: var(--green); }
.trans-icon { margin: 0 auto 6px; color: var(--text2); display: block; }

/* ── PREVIEW ────────────────────────────────────── */
#preview {
  flex: 1; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; min-width: 0;
}
#canvasWrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 12px; overflow: hidden; position: relative; background: var(--bg2);
}
#canvas { max-width: 100%; max-height: 100%; border-radius: 4px; background: #000; box-shadow: 0 8px 40px rgba(0,0,0,.5); }

/* Overlay handles */
.ov-handle {
  position: absolute; border: 2px solid var(--primary); border-radius: 3px; cursor: move; pointer-events: all;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5);
}
.ov-handle.selected { border-color: #fff; }
.ov-resize {
  position: absolute; width: 10px; height: 10px; background: #fff; border-radius: 50%;
  border: 2px solid var(--primary); cursor: nwse-resize; transform: translate(-50%,-50%);
}
.ov-resize-e { cursor: ew-resize; }
.ov-resize-s { cursor: ns-resize; }
.ov-resize-se { cursor: se-resize; }

/* Playbar */
#playbar {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap;
}
.pb-btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 6px;
  border: none; border-radius: var(--r); background: none; color: var(--text2);
  cursor: pointer; transition: all .15s; flex-shrink: 0;
}
.pb-btn:hover { background: var(--surface2); color: var(--text); }
.pb-play { background: var(--primary) !important; color: #fff !important; border-radius: 50%; padding: 8px; }
.pb-play:hover { background: var(--primary-h) !important; }
.pb-seek-wrap { flex: 1; min-width: 80px; }
.pb-seek { width: 100%; height: 4px; cursor: pointer; accent-color: var(--primary); }
.time-display { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text2); white-space: nowrap; font-family: monospace; min-width: 130px; }
.pb-spacer { flex: 0 0 8px; }
.pb-vol { display: flex; align-items: center; gap: 5px; }
.pb-vol svg { color: var(--text3); flex-shrink: 0; }
.vol-slider { width: 70px; }
.pb-select {
  padding: 4px 6px; background: var(--surface2); color: var(--text); border: 1px solid var(--border2);
  border-radius: var(--r); font-family: inherit; font-size: 12px; cursor: pointer;
}

/* ── RIGHT PANEL ────────────────────────────────── */
#rightPanel {
  width: 220px; min-width: 220px; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.rp-header {
  padding: 10px 14px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text3); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.prop-panel { flex: 1; overflow-y: auto; padding: 10px; }
.prop-empty { display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 10px; text-align: center; }
.prop-empty svg { color: var(--text3); }
.prop-empty p { font-size: 12px; color: var(--text3); line-height: 1.5; }
.prop-group { margin-bottom: 14px; }
.prop-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 6px; }
.prop-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.prop-row label { font-size: 11px; color: var(--text2); width: 54px; flex-shrink: 0; }
.prop-input {
  flex: 1; padding: 4px 7px; background: var(--bg); border: 1px solid var(--border2);
  border-radius: 4px; color: var(--text); font-family: inherit; font-size: 12px;
}
.prop-input:focus { outline: none; border-color: var(--primary); }
.prop-btn {
  width: 100%; padding: 7px; margin-top: 4px; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r); color: var(--text2); font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.prop-btn:hover { background: var(--surface3); color: var(--text); }
.prop-btn.danger:hover { background: rgba(239,68,68,.1); color: var(--red); border-color: var(--red); }

/* ── TIMELINE ───────────────────────────────────── */
#timeline {
  height: var(--tl-h); flex-shrink: 0; background: var(--surface);
  border-top: 1px solid var(--border); display: flex; flex-direction: column;
}
.tl-toolbar {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tl-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px;
  border: none; border-radius: var(--r); background: var(--surface2); color: var(--text2);
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.tl-btn:hover { background: var(--surface3); color: var(--text); }
.tl-divider { width: 1px; height: 18px; background: var(--border2); }
.tl-spacer { flex: 1; }
.zoom-slider { width: 90px; height: 4px; }
.zoom-label { font-size: 11px; color: var(--text3); min-width: 48px; }

#tlArea { flex: 1; display: flex; overflow: hidden; }
#tlLabels {
  width: 70px; min-width: 70px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); overflow-y: hidden;
}
.tl-label-row {
  height: 38px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text3);
  border-bottom: 1px solid var(--border);
}
#tlScrollArea { flex: 1; overflow: auto; position: relative; }
#tlRuler {
  height: 22px; background: var(--surface2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; white-space: nowrap; min-width: max-content;
}
.ruler-tick { display: inline-block; position: absolute; top: 0; height: 100%; }
.ruler-tick span { font-size: 9px; color: var(--text3); padding: 4px 3px 0; display: block; border-left: 1px solid var(--border2); }

#tlTracks { position: relative; min-width: max-content; }
.tl-track { height: 38px; border-bottom: 1px solid var(--border); position: relative; background: var(--bg2); }
.tl-track:hover { background: rgba(124,58,237,.03); }

/* Clips */
.clip {
  position: absolute; top: 3px; height: 32px; border-radius: 5px; cursor: grab; overflow: hidden;
  display: flex; align-items: center; padding: 0 8px; font-size: 10px; font-weight: 700;
  letter-spacing: .02em; white-space: nowrap; border: 2px solid rgba(255,255,255,.1);
  transition: border-color .1s; user-select: none; min-width: 4px;
}
.clip:active { cursor: grabbing; }
.clip.vc { background: linear-gradient(135deg,#7c3aed,#5b21b6); color: #ede9fe; }
.clip.ac { background: linear-gradient(135deg,#0ea5e9,#0284c7); color: #e0f2fe; }
.clip.tc { background: linear-gradient(135deg,#f59e0b,#d97706); color: #fef3c7; }
.clip.ic { background: linear-gradient(135deg,#ec4899,#be185d); color: #fce7f3; }
.clip.selected { border-color: rgba(255,255,255,.85) !important; box-shadow: 0 0 0 1px rgba(255,255,255,.3); }
.clip-inner { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.clip-wave { position: absolute; bottom: 0; left: 0; right: 0; height: 12px; opacity: .3; pointer-events: none; }
.ch { position: absolute; top: 0; height: 100%; width: 7px; cursor: col-resize; z-index: 5; }
.ch-l { left: 0; background: linear-gradient(to right,rgba(255,255,255,.25),transparent); border-radius: 5px 0 0 5px; }
.ch-r { right: 0; background: linear-gradient(to left,rgba(255,255,255,.25),transparent); border-radius: 0 5px 5px 0; }

/* Playhead */
#playhead { position: absolute; top: 0; bottom: 0; width: 0; z-index: 20; pointer-events: none; }
.ph-head {
  position: absolute; top: 0; left: -6px; width: 13px; height: 16px;
  background: var(--red); border-radius: 3px 3px 2px 2px; cursor: pointer; pointer-events: all;
}
.ph-head::after { content:''; position:absolute; bottom:-5px; left:50%; transform:translateX(-50%); width:0; height:0; border:5px solid transparent; border-top-color:var(--red); border-bottom:none; }
.ph-line { position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--red); }

/* ── MODALS ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r2);
  width: 90%; max-width: 560px; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text2); cursor: pointer; padding: 4px;
  border-radius: 4px; display: flex; transition: all .15s;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.form-select {
  padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r); color: var(--text); font-family: inherit; font-size: 13px;
}
.btn-cancel {
  padding: 7px 16px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--r);
  color: var(--text2); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-cancel:hover { background: var(--surface3); color: var(--text); }
.export-progress { display: flex; align-items: center; gap: 10px; }
.export-progress.hidden { display: none; }
.export-bar-wrap { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.export-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width .1s; width: 0; }

/* ── PROJECTS MODAL ─────────────────────────────── */
.projects-list { display: flex; flex-direction: column; gap: 8px; }
.project-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface2); border-radius: var(--r); border: 1px solid var(--border);
  cursor: pointer; transition: all .15s;
}
.project-row:hover { border-color: var(--primary); background: var(--surface3); }
.pr-icon { color: var(--primary); flex-shrink: 0; }
.pr-info { flex: 1; min-width: 0; }
.pr-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-date { font-size: 11px; color: var(--text2); margin-top: 1px; }
.pr-del { background: none; border: none; color: var(--text3); cursor: pointer; padding: 5px; border-radius: 4px; display: flex; transition: all .15s; }
.pr-del:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ── TOASTS ─────────────────────────────────────── */
#toastArea { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; background: var(--surface3); border: 1px solid var(--border2);
  border-radius: var(--r); font-size: 13px; color: var(--text); box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: toastIn .2s ease; max-width: 280px;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }
@keyframes toastIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 900px) {
  #rightPanel { display: none; }
  #leftPanel { width: 200px; min-width: 200px; }
  :root { --tl-h: 160px; }
}
@media (max-width: 640px) {
  #leftPanel { width: 170px; min-width: 170px; }
  .logo span { display: none; }
  .tb-btn span { display: none; }
  :root { --topbar-h: 46px; --tl-h: 140px; }
}