:root {
  --bg: #0d0e10;
  --panel: #15171a;
  --panel-raised: #1a1c20;
  --line: #2a2d31;
  --line-soft: #22252a;
  --text: #f4f2ec;
  --muted: #999b9e;
  --muted-2: #6f7277;
  --accent: #ff5b35;
  --accent-bright: #ff7858;
  --accent-soft: rgba(255, 91, 53, 0.13);
  --green: #76db9b;
  --danger: #ff7272;
  --radius: 16px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% -10%, rgba(255, 91, 53, 0.09), transparent 34rem),
    var(--bg);
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.topbar {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(13, 14, 16, 0.9);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand small {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.brand-mark {
  width: 29px;
  height: 29px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  padding: 7px 6px;
  box-shadow: 0 8px 25px rgba(255, 91, 53, 0.25);
}

.brand-mark i { width: 3px; background: #19110e; border-radius: 2px; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 11px; }

.status-group { display: flex; gap: 9px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #131518;
}
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: #777; }
.status-pill.ready i { background: var(--green); box-shadow: 0 0 0 3px rgba(118, 219, 155, 0.1); }
.status-pill.warning i { background: #ffbe5b; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  max-width: 1580px;
  margin: 0 auto;
  padding: 18px;
  align-items: start;
}

.editor-pane { min-width: 0; display: grid; gap: 18px; }
.panel {
  background: linear-gradient(155deg, rgba(26, 28, 32, 0.96), rgba(19, 21, 24, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.setup-card, .workspace, .timeline, .output-card { padding: 24px; }
.section-heading { display: flex; justify-content: space-between; margin-bottom: 22px; }
.eyebrow {
  display: block;
  color: var(--accent-bright);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 7px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(25px, 3vw, 38px); letter-spacing: -0.045em; line-height: 1.05; }
h2 { margin-bottom: 5px; font-size: 18px; letter-spacing: -0.025em; }
.section-heading p, .timeline-header p { color: var(--muted); margin: 0; font-size: 13px; line-height: 1.55; }

.source-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.drop-zone {
  min-height: 184px;
  border: 1px dashed #3a3d42;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  color: var(--muted);
  background: rgba(10, 11, 13, 0.35);
  cursor: pointer;
  transition: 160ms ease;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.drop-zone input { display: none; }
.drop-zone strong { color: var(--text); font-size: 14px; margin-bottom: 4px; }
.drop-zone span { font-size: 12px; }
.drop-zone small { margin-top: 14px; color: var(--muted-2); font-size: 10px; }
.upload-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent-bright);
  font-size: 21px !important;
  margin-bottom: 14px;
  background: var(--panel-raised);
}

.analysis-action { display: flex; }
.analysis-action .primary-button { width: 100%; min-height: 46px; }
.source-fields { display: flex; flex-direction: column; gap: 15px; }
label > span { color: #c8c7c3; display: block; font-size: 11px; font-weight: 650; margin-bottom: 7px; }
label em { color: var(--muted-2); font-style: normal; font-weight: 500; }
input, textarea, select {
  width: 100%;
  color: var(--text);
  background: #101215;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  transition: 150ms ease;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: rgba(255, 91, 53, 0.8); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: #5e6166; }
.inline-fields { display: grid; grid-template-columns: 1fr 1.1fr; gap: 12px; align-items: end; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 42px; }
.input-suffix b { position: absolute; right: 12px; top: 12px; color: var(--muted-2); font-size: 10px; }

.primary-button, .ghost-button, .download-button {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  font-weight: 750;
  font-size: 12px;
  cursor: pointer;
  transition: 150ms ease;
  text-decoration: none;
}
.primary-button { background: var(--accent); color: #1b100c; }
.primary-button:hover { background: var(--accent-bright); transform: translateY(-1px); }
.primary-button:disabled { opacity: 0.45; cursor: wait; transform: none; }
.primary-button i { font-style: normal; font-size: 17px; }
.primary-button.compact { min-height: 37px; padding: 8px 13px; }
.ghost-button { background: #121417; border-color: var(--line); color: #c9c8c5; }
.ghost-button:hover { border-color: #45494f; background: #1a1d21; }

.workspace-header, .timeline-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 17px; }
.video-meta { text-align: right; font-size: 11px; color: var(--muted); }
.video-meta span, .video-meta b { display: block; }
.video-meta b { color: var(--text); margin-top: 3px; font-variant-numeric: tabular-nums; }
.monitor-frame { aspect-ratio: 16 / 8.4; background: #050607; border-radius: 12px; overflow: hidden; position: relative; border: 1px solid #24262a; }
.monitor-frame video { width: 100%; height: 100%; display: block; object-fit: contain; }
.monitor-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted-2); font-size: 12px; pointer-events: none; }

.timeline-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.video-overview {
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 91, 53, 0.22);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(255, 91, 53, 0.09), rgba(17, 19, 22, 0.92));
}
.video-overview .eyebrow { margin-bottom: 5px; }
.video-overview h3 { margin-bottom: 7px; font-size: 15px; letter-spacing: -0.02em; }
.video-overview p { margin: 0; color: #cfcec9; font-size: 12px; line-height: 1.65; white-space: pre-wrap; }
.render-options { border: 1px solid var(--line-soft); border-radius: 10px; background: #111316; margin-bottom: 12px; padding: 11px 13px; }
.overlay-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.overlay-toggle input { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }
.overlay-toggle span, .overlay-toggle strong, .overlay-toggle small { display: block; }
.overlay-toggle strong { color: var(--text); font-size: 10px; }
.overlay-toggle small { color: var(--muted-2); font-size: 8px; line-height: 1.4; margin-top: 2px; }
.overlay-controls { display: grid; grid-template-columns: minmax(125px, 1.3fr) 82px 72px 72px minmax(120px, 1fr); align-items: end; gap: 10px; border-top: 1px solid var(--line-soft); margin-top: 10px; padding-top: 10px; }
.overlay-controls label > span { display: block; color: var(--muted); font-size: 8px; margin-bottom: 5px; }
.overlay-controls select, .overlay-controls input[type="number"] { padding: 7px 8px; border-radius: 7px; font-size: 10px; }
.overlay-controls input[type="color"] { width: 100%; height: 31px; border: 1px solid var(--line); border-radius: 7px; padding: 3px; background: #0f1113; cursor: pointer; }
.opacity-field output { color: var(--text); float: right; font-variant-numeric: tabular-nums; }
.opacity-field input { width: 100%; accent-color: var(--accent); }
.timeline-summary { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 10px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 12px 0; margin-bottom: 8px; }
.timeline-summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.sequence-strip { height: 5px; border-radius: 999px; overflow: hidden; display: flex; flex: 1; background: #23262a; }
.sequence-strip i { height: 100%; border-right: 2px solid var(--panel); min-width: 4px; }
.clip-list { display: grid; gap: 7px; padding-top: 5px; }
.clip-card {
  display: grid;
  grid-template-columns: 30px 35px minmax(150px, 1fr) auto;
  grid-template-areas:
    "handle number description controls"
    "handle number timing controls";
  align-items: start;
  gap: 9px;
  padding: 11px 10px;
  background: #111316;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  transition: 130ms ease;
}
.clip-card:hover { border-color: #3a3e44; background: #14171a; }
.clip-card.dragging { opacity: 0.4; }
.drag-handle { grid-area: handle; color: #555960; cursor: grab; font-size: 16px; letter-spacing: -3px; user-select: none; }
.clip-number { grid-area: number; width: 27px; height: 27px; border-radius: 7px; display: grid; place-items: center; background: var(--clip-color); color: #111; font-weight: 850; font-size: 10px; }
.clip-title { grid-area: description; min-width: 0; }
.clip-title textarea {
  display: block;
  min-height: 42px;
  overflow: hidden;
  resize: none;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 3px 4px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  white-space: pre-wrap;
}
.clip-title textarea:focus { background: rgba(255, 255, 255, 0.025); box-shadow: 0 0 0 2px var(--accent-soft); }
.clip-title small { display: block; color: var(--muted-2); font-size: 9px; padding: 0 2px; margin-top: 2px; }
.clip-timing { grid-area: timing; display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.time-field { position: relative; width: 112px; }
.time-field::after { content: "↔"; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: #666b72; font-size: 10px; pointer-events: none; transition: 120ms ease; }
.time-field:hover::after, .time-field:focus-within::after { color: var(--accent-bright); }
.time-field input { padding: 8px 25px 8px 9px; font-size: 11px; font-variant-numeric: tabular-nums; }
.time-field input.scrubbable-time { cursor: ew-resize; touch-action: none; }
.time-field input.scrubbable-time:focus:not(.scrubbing) { cursor: text; }
.time-field input.scrubbing { cursor: ew-resize; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); user-select: none; }
body.time-scrubbing, body.time-scrubbing * { cursor: ew-resize !important; user-select: none !important; }
.time-arrow { color: var(--muted-2); text-align: center; }
.clip-controls { grid-area: controls; display: flex; gap: 3px; margin-top: 1px; }
.clip-controls button, .icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 7px;
  cursor: pointer;
}
.clip-controls button:hover, .icon-button:hover { background: #25282d; color: var(--text); }
.clip-controls .delete:hover { color: var(--danger); background: rgba(255, 114, 114, 0.08); }
.empty-timeline { color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; padding: 28px; text-align: center; font-size: 12px; margin-top: 12px; }

.output-card { display: grid; grid-template-columns: 0.65fr 1.35fr; gap: 24px; align-items: center; border-color: rgba(118, 219, 155, 0.25); }
.output-copy p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.download-button { background: #e9e6de; color: #161719; margin-top: 5px; }
.download-button:hover { background: #fff; }
.output-card video { width: 100%; max-height: 360px; border-radius: 10px; background: #050607; }

.agent-pane {
  position: sticky;
  top: 84px;
  height: calc(100vh - 102px);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}
.agent-header { padding: 17px 18px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line-soft); }
.agent-header > div:nth-child(2) { min-width: 0; flex: 1; }
.agent-header h2 { font-size: 13px; margin: 0 0 3px; }
.agent-header p { margin: 0; color: var(--muted); font-size: 9px; display: flex; align-items: center; gap: 5px; }
.agent-header p i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.agent-avatar { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); border: 1px solid rgba(255, 91, 53, 0.3); display: grid; place-items: center; }
.agent-avatar span { width: 12px; height: 12px; border: 2px solid var(--accent); border-radius: 3px 7px 3px 7px; transform: rotate(45deg); }
.agent-header-actions { display: flex; align-items: center; gap: 2px; }
.model-settings { padding: 13px 15px 14px; background: #111316; border-bottom: 1px solid var(--line-soft); }
.settings-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 11px; }
.settings-heading strong, .settings-heading span { display: block; }
.settings-heading strong { font-size: 11px; }
.settings-heading span { color: var(--muted-2); font-size: 8px; margin-top: 2px; }
.settings-heading button { border: 0; background: transparent; color: var(--accent-bright); font-size: 9px; cursor: pointer; padding: 2px 0; }
.settings-actions { display: flex; gap: 10px; }
.model-settings label { display: block; margin-top: 9px; }
.model-settings label > span { font-size: 9px; margin-bottom: 5px; }
.model-settings select { padding: 8px 30px 8px 9px; border-radius: 8px; font-size: 10px; }
.model-settings label small { color: var(--muted-2); display: block; font-size: 8px; line-height: 1.4; margin-top: 4px; }
.model-settings > p { color: var(--muted-2); font-size: 8px; margin: 11px 0 0; }
.model-settings code { color: #bbbcbf; }

.chat-feed { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 15px; scrollbar-width: thin; scrollbar-color: #3a3d42 transparent; }
.message { max-width: 92%; font-size: 12px; line-height: 1.55; animation: rise 180ms ease both; }
.message p { margin: 4px 0 0; white-space: pre-wrap; }
.message-label { color: var(--muted-2); font-size: 8px; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.assistant-message { align-self: flex-start; }
.assistant-message p { color: #d1d0cc; background: #101215; border: 1px solid var(--line-soft); padding: 11px 12px; border-radius: 4px 12px 12px 12px; }
.user-message { align-self: flex-end; text-align: right; }
.user-message p { color: #1b100c; background: var(--accent); padding: 10px 12px; border-radius: 12px 4px 12px 12px; text-align: left; }
.thinking p { color: var(--muted); }
.thinking-dots { display: inline-flex; gap: 3px; }
.thinking-dots i { width: 4px; height: 4px; background: var(--muted); border-radius: 50%; animation: blink 1s infinite; }
.thinking-dots i:nth-child(2) { animation-delay: 150ms; }
.thinking-dots i:nth-child(3) { animation-delay: 300ms; }

.quick-prompts {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px 11px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #444950 #101215;
  border-top: 1px solid var(--line-soft);
  background: rgba(13, 15, 17, 0.55);
}
.quick-prompts::-webkit-scrollbar { height: 8px; }
.quick-prompts::-webkit-scrollbar-track { margin: 0 12px; background: #101215; border-radius: 999px; }
.quick-prompts::-webkit-scrollbar-thumb { background: #444950; border: 2px solid #101215; border-radius: 999px; }
.quick-prompts::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.quick-prompts::-webkit-scrollbar-button { width: 0; height: 0; display: none; }
.quick-prompts button {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-height: 29px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(180deg, #171a1e, #111316);
  color: #aaaeb4;
  padding: 7px 11px;
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}
.quick-prompts button:hover { color: var(--text); border-color: #565b63; background: #1b1e23; }
.chat-composer { flex: 0 0 auto; margin: 0 13px 13px; border: 1px solid var(--line); background: #101215; border-radius: 12px; padding: 8px 8px 6px 11px; display: grid; grid-template-columns: 1fr auto; align-items: end; }
.chat-composer:focus-within { border-color: rgba(255, 91, 53, 0.65); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-composer textarea { border: 0; padding: 5px 2px; resize: none; max-height: 130px; background: transparent; box-shadow: none; font-size: 12px; }
.chat-composer textarea:focus { box-shadow: none; }
.chat-composer button { width: 31px; height: 31px; border: 0; border-radius: 8px; background: var(--accent); color: #1b100c; font-size: 17px; cursor: pointer; }
.chat-composer button:disabled { opacity: 0.45; cursor: wait; }
.chat-composer small { grid-column: 1 / -1; color: #55585d; font-size: 8px; padding-top: 5px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(4, 5, 6, 0.78); backdrop-filter: blur(8px); }
.settings-modal { width: min(520px, 100%); padding: 22px; box-shadow: 0 30px 100px #000b; }
.settings-modal > header { display: flex; align-items: flex-start; gap: 18px; justify-content: space-between; margin-bottom: 18px; }
.settings-modal h2 { margin: 5px 0 5px; font-size: 20px; }
.settings-modal header p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.settings-modal form { display: grid; gap: 13px; }
.settings-modal label > span { display: block; margin-bottom: 6px; font-size: 10px; font-weight: 700; }
.settings-modal label em { color: var(--muted-2); font-size: 8px; font-style: normal; font-weight: 500; margin-left: 4px; }
.settings-modal label small { display: block; color: var(--muted-2); font-size: 8px; margin-top: 4px; }
.settings-location { color: var(--muted-2); font-size: 8px; line-height: 1.45; margin: 0; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 3px; }
.modal-actions button { min-height: 36px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; color: var(--text); background: #202329; border: 1px solid #3c4046; border-radius: 10px; padding: 10px 14px; font-size: 11px; box-shadow: 0 14px 40px #0008; }
.toast.error { color: #ffd0d0; border-color: rgba(255, 114, 114, 0.45); }
[hidden] { display: none !important; }

@keyframes rise { from { opacity: 0; transform: translateY(5px); } }
@keyframes blink { 0%, 70%, 100% { opacity: .3; } 35% { opacity: 1; } }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: minmax(0, 1fr) 340px; }
  .clip-card { grid-template-columns: 25px 31px minmax(120px, 1fr) auto; gap: 6px; }
  .overlay-controls { grid-template-columns: repeat(3, minmax(90px, 1fr)); }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .agent-pane { position: relative; top: 0; height: 680px; }
  .source-grid { grid-template-columns: 1fr; }
  .drop-zone { min-height: 180px; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 14px; }
  .brand small, .status-pill { display: none; }
  .app-shell { padding: 10px; gap: 10px; }
  .setup-card, .workspace, .timeline, .output-card { padding: 17px; }
  .inline-fields, .output-card { grid-template-columns: 1fr; }
  .workspace-header, .timeline-header { align-items: flex-start; flex-direction: column; }
  .timeline-actions { justify-content: flex-start; }
  .overlay-controls { grid-template-columns: repeat(2, minmax(110px, 1fr)); }
  .clip-card { grid-template-columns: 22px 29px minmax(0, 1fr) auto; }
  .clip-timing { flex-wrap: wrap; }
  .time-field { width: min(118px, 44%); }
  .clip-controls { flex-direction: column; }
  .sequence-strip { display: none; }
  .settings-modal { padding: 18px; }
}
