/* styles.css */
:root {
  --bg: #0b1020;
  --bg-soft: #131a31;
  --panel: rgba(16, 23, 45, 0.82);
  --panel-2: rgba(20, 28, 52, 0.9);
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3ff;
  --muted: #9fb0d6;
  --accent: #7c9cff;
  --accent-2: #8f7cff;
  --green: #50d890;
  --yellow: #ffd56a;
  --red: #ff7f90;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --radius-sm: 14px;
  --blur: blur(16px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 156, 255, 0.20), transparent 30%),
    radial-gradient(circle at top right, rgba(143, 124, 255, 0.18), transparent 32%),
    linear-gradient(180deg, #080c18 0%, #0b1020 100%);
}

body {
  padding: 18px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: 8px;
}

.app-shell {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 36px);
}

.sidebar,
.workspace {
  min-height: 0;
}

.sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 4px 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.pill {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 6px;
  margin-bottom: 14px;
}

.tab,
.chip {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 12px;
  transition: 160ms ease;
}

.tab.active,
.chip.active {
  color: white;
  background: linear-gradient(135deg, rgba(124, 156, 255, 0.22), rgba(143, 124, 255, 0.16));
  border-color: rgba(124, 156, 255, 0.22);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.field > span {
  color: var(--muted);
  font-size: 0.88rem;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: rgba(124, 156, 255, 0.6);
  background: rgba(255, 255, 255, 0.06);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.inline-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.dual-input {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.toggles {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.help {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 11px 14px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, opacity 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.14);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: white;
  font-weight: 700;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
}

.btn-ghost {
  background: transparent;
}

.btn-lg {
  padding: 14px 16px;
}

.dropzone {
  display: block;
  border: 1.5px dashed rgba(124, 156, 255, 0.35);
  border-radius: 18px;
  background: rgba(124, 156, 255, 0.08);
  cursor: pointer;
}

.dropzone.dragging {
  border-color: rgba(124, 156, 255, 0.8);
  background: rgba(124, 156, 255, 0.14);
}

.dropzone-inner {
  padding: 26px 18px;
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
}

.dropzone-inner strong {
  font-size: 1rem;
}

.dropzone-inner span {
  color: var(--muted);
  font-size: 0.9rem;
}

.trim-actions,
.preset-row,
.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-stack {
  display: grid;
  gap: 10px;
}

.progress-wrap {
  margin-top: 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.progress-bar {
  height: 11px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

#progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: width 120ms linear;
}

.hero {
  display: grid;
  gap: 16px;
}

.hero-copy h2 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
  max-width: 72ch;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: var(--panel-2);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.stat-card strong {
  font-size: 1.02rem;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  gap: 16px;
  min-height: 0;
}

.player-panel,
.output-panel {
  display: grid;
  align-content: start;
}

.player-controls-inline {
  display: flex;
  gap: 8px;
}

.video-stage,
.gif-stage {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)),
    #090d18;
  min-height: 420px;
}

.video-stage {
  display: grid;
  place-items: center;
}

video,
#gifPreview {
  width: 100%;
  height: 100%;
  max-height: 70vh;
  display: block;
  object-fit: contain;
  background: #05070e;
}

.video-overlay,
.gif-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.overlay-card,
.gif-placeholder {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.overlay-card h3 {
  color: white;
  margin: 0 0 8px;
}

.crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.12) 1px, transparent 1px);
  background-size: 33.333% 100%, 100% 33.333%;
}

.crop-grid.visible {
  display: block;
}

.timeline-wrap {
  margin-top: 14px;
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 8px;
}

.output-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.output-meta > div {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.output-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 50;
}

.toast {
  min-width: 280px;
  max-width: 380px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(10, 16, 30, 0.95);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.toast strong {
  display: block;
  margin-bottom: 4px;
}

.toast span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.toast.success {
  border-color: rgba(80, 216, 144, 0.28);
}

.toast.warn {
  border-color: rgba(255, 213, 106, 0.28);
}

.toast.error {
  border-color: rgba(255, 127, 144, 0.28);
}

@media (max-width: 1260px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    padding: 12px;
  }

  .grid-2,
  .hero-stats,
  .output-meta {
    grid-template-columns: 1fr;
  }

  .dual-input,
  .inline-input {
    grid-template-columns: 1fr;
  }

  .video-stage,
  .gif-stage {
    min-height: 280px;
  }
}