:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: #172033;
  --panel-2: #202a3d;
  --line: #36445b;
  --text: #f8fafc;
  --muted: #a9b5c7;
  --blue: #2f80ed;
  --blue-strong: #1768d9;
  --red: #f04438;
  --green: #12b981;
  --amber: #f59e0b;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(47, 128, 237, 0.16), transparent 30%),
    linear-gradient(135deg, #101827 0%, #141c2b 52%, #1b2636 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  min-height: 100vh;
  padding: 28px;
}

.stage,
.clips-panel {
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(23, 32, 51, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: clamp(18px, 3vw, 34px);
  border-radius: 8px;
}

.topbar,
.clips-header,
.storage-line,
.main-actions,
.settings,
.clip-actions,
.clip-meta {
  display: flex;
  align-items: center;
}

.topbar,
.clips-header,
.storage-line {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #8fd3c7;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.7rem);
}

h2 {
  font-size: 1.25rem;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 260px;
  padding: 9px 12px;
  border: 1px solid rgba(143, 211, 199, 0.32);
  border-radius: 999px;
  background: rgba(18, 185, 129, 0.1);
  color: #c7f9ee;
  font-size: 0.85rem;
  text-align: center;
}

.preview-wrap {
  position: relative;
  overflow: hidden;
  width: min(100%, 980px);
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #020617;
}

.preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 1.1rem;
}

.empty-state span {
  max-width: 320px;
  line-height: 1.45;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 50%;
  color: #8fd3c7;
  background: rgba(143, 211, 199, 0.08);
}

.empty-icon svg {
  width: 30px;
  height: 30px;
}

.recording-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(8, 13, 22, 0.82);
  color: white;
  font-variant-numeric: tabular-nums;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(240, 68, 56, 0.18);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.82);
  }
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(32, 42, 61, 0.9);
}

.main-actions,
.settings {
  flex-wrap: wrap;
  gap: 10px;
}

.btn,
.icon-btn,
.mini-btn {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: white;
  text-decoration: none;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 750;
}

.btn:hover,
.icon-btn:hover,
.mini-btn:hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--blue);
}

.primary:hover {
  background: var(--blue-strong);
}

.danger {
  background: var(--red);
}

.secondary,
.icon-btn {
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #3b4659;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

.settings {
  justify-content: flex-end;
}

.switch-row,
.field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.switch-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--green);
}

.field select {
  min-width: 112px;
  height: 36px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  background: #101827;
  color: var(--text);
  padding: 0 9px;
}

.message {
  width: min(100%, 980px);
  min-height: 22px;
  margin: 0 auto;
  color: #bed0e5;
  text-align: center;
}

.clips-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: 8px;
}

.storage-line {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--muted);
  font-size: 0.88rem;
}

.clips-list {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding-right: 4px;
}

.clip-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
}

.clip-card video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #000;
}

.clip-name {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: #101827;
  color: var(--text);
  padding: 0 10px;
}

.clip-meta,
.clip-actions {
  justify-content: space-between;
  gap: 10px;
}

.clip-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 11px;
  font-size: 0.85rem;
  font-weight: 750;
}

.download {
  background: rgba(18, 185, 129, 0.18);
  color: #96f7cf;
}

.delete {
  background: rgba(240, 68, 56, 0.16);
  color: #ffc3bd;
}

.empty-library {
  padding: 38px 18px;
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .clips-panel {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .control-panel {
    grid-template-columns: 1fr;
  }

  .topbar,
  .storage-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-panel {
    display: grid;
  }

  .main-actions,
  .settings {
    justify-content: stretch;
  }

  .btn {
    flex: 1 1 160px;
  }

  .icon-btn {
    flex: 0 0 42px;
  }
}
