@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Material Symbols Rounded";
  src: url("/assets/fonts/material-symbols-rounded.ttf?v=3") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

:root {
  color-scheme: dark;
  --app-bg: #07111f;
  --topbar: #081321;
  --surface: #0b1727;
  --surface-raised: #101e30;
  --surface-soft: #142338;
  --surface-hover: #192a43;
  --border: rgba(184, 203, 229, 0.13);
  --border-strong: rgba(184, 203, 229, 0.24);
  --text: #eef3fb;
  --text-strong: #ffffff;
  --muted: #91a0b6;
  --faint: #65758d;
  --accent: #8065ff;
  --accent-hover: #927dff;
  --accent-soft: rgba(128, 101, 255, 0.15);
  --accent-border: rgba(128, 101, 255, 0.55);
  --success: #47d7a1;
  --danger: #ff738a;
  --warning: #f0b55a;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --topbar-height: 68px;
}

html[data-theme="light"] {
  color-scheme: light;
  --app-bg: #edf1f7;
  --topbar: #ffffff;
  --surface: #f8fafc;
  --surface-raised: #ffffff;
  --surface-soft: #eef2f8;
  --surface-hover: #e5eaf3;
  --border: rgba(36, 51, 75, 0.12);
  --border-strong: rgba(36, 51, 75, 0.22);
  --text: #24324a;
  --text-strong: #0b1424;
  --muted: #65738a;
  --faint: #8995a8;
  --accent: #6c4eff;
  --accent-hover: #5c3ce7;
  --accent-soft: rgba(108, 78, 255, 0.11);
  --accent-border: rgba(108, 78, 255, 0.42);
  --success: #17875f;
  --danger: #c93d58;
  --warning: #a86712;
  --shadow: 0 20px 70px rgba(37, 53, 78, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--app-bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.material-symbols-rounded {
  display: inline-block;
  direction: ltr;
  font-family: "Material Symbols Rounded";
  font-size: 21px;
  font-style: normal;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  font-weight: normal;
  letter-spacing: normal;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

.is-hidden {
  display: none !important;
}

.mobile-only {
  display: none !important;
}

.mobile-menu-tools {
  display: none;
}

.theme-icon-light {
  display: none;
}

html[data-theme="light"] .theme-icon-dark {
  display: none;
}

html[data-theme="light"] .theme-icon-light {
  display: inline-block;
}

.app-shell {
  height: 100%;
  min-width: 320px;
}

.topbar {
  align-items: center;
  background: var(--topbar);
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 18px;
  grid-template-columns: auto auto minmax(240px, 520px) 1fr;
  height: var(--topbar-height);
  padding: 0 20px;
  position: relative;
  z-index: 50;
}

.brand {
  align-items: center;
  color: var(--text-strong);
  display: inline-flex;
  font-size: 19px;
  font-weight: 700;
  gap: 10px;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.brand img {
  height: 36px;
  width: 36px;
}

.project-chip,
.icon-button,
.rail-button,
.text-button,
.primary-button,
.secondary-button,
.play-button,
.stage-arrow,
.filmstrip-arrow,
.drop-zone {
  border: 0;
}

.project-chip {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  display: inline-flex;
  gap: 8px;
  min-height: 40px;
  padding: 0 13px;
}

.search-box {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  width: 100%;
}

.search-box:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box input {
  background: transparent;
  border: 0;
  color: var(--text);
  min-width: 0;
  outline: 0;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--faint);
}

.search-box kbd {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--faint);
  font-family: inherit;
  font-size: 11px;
  padding: 2px 6px;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 9px;
  justify-self: end;
}

.account-form {
  margin: 0;
}

.account-chip {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  gap: 7px;
  height: 40px;
  padding: 0 10px;
}

.account-chip:hover {
  background: var(--surface-hover);
  border-color: var(--accent-border);
}

.account-chip .material-symbols-rounded {
  color: var(--accent-hover);
  font-size: 19px;
}

.account-chip .logout-icon {
  color: var(--muted);
  font-size: 17px;
}

.admin-tag {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-hover);
  font-size: 9px;
  letter-spacing: 0.06em;
  padding: 3px 6px;
  text-transform: uppercase;
}

.icon-button,
.rail-button {
  align-items: center;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  display: inline-flex;
  height: 40px;
  justify-content: center;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
  width: 40px;
}

.icon-button:hover,
.rail-button:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.icon-button:active,
.rail-button:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.icon-button.compact {
  height: 34px;
  width: 34px;
}

.icon-button.is-active,
.rail-button.is-active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.primary-button,
.secondary-button {
  align-items: center;
  border-radius: var(--radius-sm);
  display: inline-flex;
  font-weight: 600;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-hover);
}

.secondary-button {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.secondary-button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent-border);
}

.full-width {
  width: 100%;
}

.app-layout {
  display: grid;
  grid-template-columns: 64px minmax(250px, 300px) minmax(0, 1fr) minmax(280px, 300px);
  height: calc(100vh - var(--topbar-height));
  min-height: 0;
}

.icon-rail,
.history-panel,
.viewer-panel,
.inspector-panel {
  min-height: 0;
}

.icon-rail {
  align-items: center;
  background: var(--topbar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 10px;
}

.rail-spacer {
  flex: 1;
}

.history-panel,
.inspector-panel {
  background: var(--surface);
  overflow: hidden;
}

.history-panel {
  border-right: 1px solid var(--border);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}

.panel-heading,
.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.panel-heading {
  padding: 20px 18px 12px;
}

.eyebrow {
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.panel-heading h2,
.section-heading h2 {
  color: var(--text-strong);
  font-size: 15px;
  margin: 0;
}

.history-summary {
  align-items: center;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  margin: 0 18px;
  padding: 0 0 12px;
}

.text-button {
  align-items: center;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  gap: 4px;
  padding: 4px;
}

.text-button .material-symbols-rounded {
  font-size: 17px;
}

.text-button:hover {
  color: var(--text-strong);
}

.history-list {
  overflow-y: auto;
  padding: 12px 10px 24px;
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

.history-group-label {
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 14px 8px 8px;
  text-transform: uppercase;
}

.history-card {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  display: grid;
  gap: 10px;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  margin-bottom: 6px;
  min-height: 74px;
  padding: 8px;
  text-align: left;
  width: 100%;
}

.history-card:hover {
  background: var(--surface-soft);
}

.history-card.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.history-thumbnail {
  align-items: center;
  background: var(--app-bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  display: flex;
  height: 56px;
  justify-content: center;
  overflow: hidden;
  width: 64px;
}

.history-thumbnail img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.history-thumbnail .material-symbols-rounded {
  color: var(--faint);
}

.history-card-copy {
  min-width: 0;
}

.history-card-copy strong,
.history-card-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card-copy strong {
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
}

.history-card-copy span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.history-card-state {
  background: var(--faint);
  border-radius: 50%;
  height: 7px;
  width: 7px;
}

.history-card-state.is-running {
  animation: pulse 1.3s ease-in-out infinite;
  background: var(--accent);
}

.history-card-state.is-done {
  background: var(--success);
}

@keyframes pulse {
  50% { opacity: 0.35; }
}

.history-empty {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 7px;
  justify-content: center;
  padding: 28px;
  text-align: center;
}

.history-empty .material-symbols-rounded {
  color: var(--faint);
  font-size: 30px;
}

.history-empty strong {
  color: var(--text);
}

.history-empty span:last-child {
  font-size: 12px;
  line-height: 1.5;
}

.history-footer {
  align-items: center;
  border-top: 1px solid var(--border);
  color: var(--faint);
  display: flex;
  font-size: 11px;
  justify-content: space-between;
  padding: 14px 18px;
}

.engine-status,
.status-line {
  align-items: center;
  display: flex;
  gap: 8px;
}

.status-dot {
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(71, 215, 161, 0.1);
  height: 7px;
  width: 7px;
}

.viewer-panel {
  background: var(--app-bg);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.viewer-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 94px;
  padding: 17px 24px;
}

.viewer-title-block {
  min-width: 0;
}

.viewer-title-row {
  align-items: center;
  display: flex;
  gap: 9px;
  min-width: 0;
}

.viewer-title-row h1 {
  color: var(--text-strong);
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0;
  max-width: min(48vw, 620px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 7px 0 0;
}

.state-badge,
.engine-chip {
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 5px 8px;
  text-transform: uppercase;
}

.state-badge {
  background: var(--surface-soft);
  color: var(--muted);
}

.state-badge.is-running {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.state-badge.is-done {
  background: rgba(71, 215, 161, 0.1);
  color: var(--success);
}

.state-badge.is-error {
  background: rgba(255, 115, 138, 0.1);
  color: var(--danger);
}

.view-switcher {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  padding: 3px;
}

.empty-state {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  padding: 36px;
}

.drop-zone {
  align-items: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-width: 620px;
  min-height: 330px;
  padding: 38px;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
  width: min(100%, 620px);
}

.drop-zone:hover,
.drop-zone.is-dragging {
  background: var(--surface-raised);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.drop-zone img {
  height: 80px;
  margin-bottom: 10px;
  width: 80px;
}

.drop-zone strong {
  color: var(--text-strong);
  font-size: 24px;
  letter-spacing: -0.025em;
}

.drop-kicker {
  color: var(--accent-hover);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.drop-action {
  align-items: center;
  background: var(--accent);
  border-radius: var(--radius-sm);
  color: #ffffff;
  display: inline-flex;
  font-weight: 650;
  gap: 8px;
  margin-top: 16px;
  padding: 11px 16px;
}

.empty-features {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 22px;
  justify-content: center;
  margin-top: 24px;
}

.empty-features > span {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.empty-features .material-symbols-rounded {
  color: var(--accent-hover);
  font-size: 18px;
}

.carousel-view {
  display: grid;
  grid-template-rows: minmax(250px, 1fr) auto auto auto auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 24px 14px;
}

.media-stage {
  align-items: center;
  display: grid;
  gap: clamp(10px, 1.5vw, 22px);
  grid-template-columns: auto minmax(64px, 0.5fr) minmax(220px, 2fr) minmax(64px, 0.5fr) auto;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  padding: 4px 0 12px;
}

.video-frame {
  align-items: center;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  grid-column: 2 / 5;
  grid-row: 1;
  justify-content: center;
  margin: 0;
  min-height: 0;
  overflow: hidden;
}

.video-frame video {
  background: #030914;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
  max-height: calc(100% - 34px);
  max-width: 100%;
  object-fit: contain;
}

.video-frame figcaption {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 6px;
  margin-top: 8px;
}

.video-frame figcaption .material-symbols-rounded {
  color: var(--accent-hover);
  font-size: 16px;
}

.media-stage.is-video-mode .stage-arrow,
.media-stage.is-video-mode .primary-frame,
.media-stage.is-video-mode .neighbor-frame {
  display: none;
}

.primary-frame,
.neighbor-frame {
  align-items: center;
  display: flex;
  justify-content: center;
  margin: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.primary-frame {
  align-self: center;
  aspect-ratio: var(--frame-ratio, 16 / 9);
  background: #030914;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  justify-self: center;
  max-height: 100%;
  max-width: 100%;
  height: auto;
  min-width: 0;
  width: auto;
}

.neighbor-frame {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-height: 78%;
  opacity: 0.72;
}

.primary-frame img,
.neighbor-frame img {
  display: block;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.primary-frame[data-ratio="portrait"] {
  max-width: min(100%, 420px);
}

.primary-frame figcaption {
  background: rgba(7, 17, 31, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  bottom: 12px;
  color: #b8a8ff;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  left: 50%;
  padding: 7px 12px;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.media-overlay-button {
  align-items: center;
  backdrop-filter: blur(12px);
  background: rgba(7, 17, 31, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  color: #ffffff;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  position: absolute;
  right: 10px;
  top: 10px;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
  width: 38px;
  z-index: 3;
}

.media-overlay-button:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent-hover);
}

.stage-arrow,
.filmstrip-arrow {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 auto;
  height: 38px;
  justify-content: center;
  transition: background 140ms ease, border-color 140ms ease;
  width: 38px;
}

.stage-arrow-left {
  grid-column: 1;
  grid-row: 1;
}

#previousCard {
  grid-column: 2;
  grid-row: 1;
}

#primaryCard {
  grid-column: 3;
  grid-row: 1;
}

#nextCard {
  grid-column: 4;
  grid-row: 1;
}

.stage-arrow-right {
  grid-column: 5;
  grid-row: 1;
}

.stage-arrow:hover:not(:disabled),
.filmstrip-arrow:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent-border);
}

.timeline-block {
  padding: 0 6px 10px;
}

.timeline-labels {
  color: var(--muted);
  display: grid;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 8px;
}

.timeline-labels span:nth-child(2) {
  color: var(--accent-hover);
  text-align: center;
}

.timeline-labels span:last-child {
  text-align: right;
}

input[type="range"] {
  accent-color: var(--accent);
  cursor: ew-resize;
  width: 100%;
}

.filmstrip-shell {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.filmstrip-arrow {
  height: 32px;
  width: 32px;
}

.filmstrip {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(9, minmax(58px, 1fr));
  min-height: 82px;
  overflow: hidden;
}

.filmstrip-item {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  padding: 3px;
}

.filmstrip-item:hover {
  border-color: var(--border-strong);
}

.filmstrip-item.is-selected {
  border: 2px solid var(--accent);
  color: var(--accent-hover);
  padding: 2px;
}

.filmstrip-item img {
  background: #030914;
  border-radius: 4px;
  height: 54px;
  object-fit: contain;
  width: 100%;
}

.filmstrip-item span {
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.transport-bar {
  align-items: center;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr auto 1fr;
  margin-top: 12px;
  min-height: 52px;
  padding-top: 10px;
}

.transport-controls {
  align-items: center;
  display: flex;
  gap: 6px;
}

.play-button {
  align-items: center;
  background: var(--accent);
  border-radius: 50%;
  color: #ffffff;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.frame-readout {
  min-width: 0;
  text-align: center;
}

.frame-readout strong,
.frame-readout span {
  display: block;
}

.frame-readout strong {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.frame-readout span {
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transport-bar > .icon-button:last-child {
  justify-self: end;
}

.grid-view {
  overflow-y: auto;
  padding: 22px 24px 32px;
}

.grid-selection-bar {
  align-items: center;
  backdrop-filter: blur(14px);
  background: rgba(11, 23, 39, 0.94);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.24);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin: 0 0 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 10px;
  pointer-events: none;
  position: sticky;
  top: 0;
  transform: translateY(-10px);
  transition: max-height 180ms ease, margin 180ms ease, opacity 150ms ease, padding 180ms ease, transform 180ms ease;
  z-index: 30;
}

html[data-theme="light"] .grid-selection-bar {
  background: rgba(255, 255, 255, 0.94);
}

.grid-selection-bar.is-visible {
  margin-bottom: 12px;
  max-height: 64px;
  opacity: 1;
  padding-block: 8px;
  pointer-events: auto;
  transform: translateY(0);
}

.grid-selection-bar > span {
  color: var(--muted);
  font-size: 12px;
  margin-right: auto;
}

.grid-selection-bar > span strong {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.frame-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.grid-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  overflow: hidden;
  padding: 6px;
  position: relative;
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.grid-item:hover {
  border-color: var(--accent-border);
}

.grid-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.grid-frame-button {
  background: transparent;
  border: 0;
  color: inherit;
  display: block;
  padding: 0;
  text-align: left;
  width: 100%;
}

.grid-frame-button img {
  background: #030914;
  border-radius: 7px;
  display: block;
  height: 130px;
  object-fit: contain;
  width: 100%;
}

.grid-frame-button > span {
  display: block;
  font-size: 10px;
  margin-top: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-checkbox {
  align-items: center;
  background: rgba(7, 17, 31, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  height: 28px;
  justify-content: center;
  position: absolute;
  right: 12px;
  top: 12px;
  width: 28px;
}

.grid-checkbox input {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.grid-checkbox .material-symbols-rounded {
  color: #ffffff;
  font-size: 19px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.grid-checkbox:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent-hover);
}

.grid-checkbox:has(input:checked) .material-symbols-rounded {
  opacity: 1;
}

.grid-checkbox:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.load-more {
  display: flex;
  margin: 20px auto 0;
}

.inspector-panel {
  border-left: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

.inspector-section {
  border-bottom: 1px solid var(--border);
  padding: 20px;
}

.engine-chip {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.source-stats {
  display: grid;
  gap: 11px;
  margin: 17px 0 0;
}

.source-stats > div {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.source-stats dt {
  color: var(--muted);
  font-size: 12px;
}

.source-stats dd {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.field-label {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 600;
  margin: 16px 0 7px;
}

.field-help {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  margin: 7px 0 0;
}

.provider-settings {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 2px;
}

.inspector-panel input:not([type="checkbox"]):not([type="range"]),
.inspector-panel textarea {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
}

.credential-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 42px;
}

.credential-row .icon-button {
  height: 42px;
  width: 42px;
}

.advanced-settings {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  overflow: hidden;
}

.advanced-settings summary {
  color: var(--text-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  list-style-position: inside;
  padding: 12px;
}

.advanced-settings[open] summary {
  border-bottom: 1px solid var(--border);
}

.advanced-settings-body {
  padding: 0 12px 14px;
}

.toggle-stack {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.toggle-stack label,
.format-options label,
.settings-pair label {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.toggle-stack label,
.format-options label {
  align-items: flex-start;
  display: flex;
  gap: 8px;
}

.toggle-stack input[type="checkbox"],
.format-options input[type="checkbox"] {
  accent-color: var(--accent);
  flex: 0 0 auto;
  height: 15px;
  margin: 0;
  width: 15px;
}

.cost-note {
  color: var(--warning);
  font-size: 9px;
  margin-left: 3px;
}

.settings-pair {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.settings-pair label {
  display: grid;
  gap: 6px;
}

.settings-pair input:not([type="checkbox"]) {
  min-width: 0;
}

.format-options {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0 0;
  padding: 10px;
}

.format-options legend {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
}

.provider-save-button {
  margin-top: 16px;
}

.transcript-export-links {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.transcript-export-links a {
  font-size: 10px;
  justify-content: flex-start;
}

.transcribe-button {
  margin-top: 16px;
}

.transcription-status {
  align-items: flex-start;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 8px;
  line-height: 1.45;
  margin: 13px 0;
}

.transcription-status .status-dot {
  flex: 0 0 auto;
  margin-top: 5px;
}

.transcription-status[data-state="running"] .status-dot,
.transcription-status[data-state="queued"] .status-dot {
  animation: pulse 1.3s ease-in-out infinite;
  background: var(--accent);
}

.transcription-status[data-state="error"] .status-dot {
  background: var(--danger);
}

.transcription-status[data-state="done"] .status-dot {
  background: var(--success);
}

.auto-transcription-note {
  align-items: center;
  color: var(--success);
  display: flex;
  font-size: 10px;
  font-weight: 650;
  gap: 7px;
  margin-top: 10px;
}

.auto-transcription-note .status-dot,
.live-transcript-badge .status-dot {
  background: var(--success);
  flex: 0 0 auto;
}

.transcript-workspace {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  margin: 0 6px 12px;
  min-height: 188px;
  min-width: 0;
  overflow: hidden;
}

.transcript-heading,
.transcript-save-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.transcript-heading {
  border-bottom: 1px solid var(--border);
  min-height: 48px;
  padding: 9px 14px;
}

.transcript-heading strong {
  color: var(--text-strong);
  font-size: 14px;
}

.transcript-title,
.transcript-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.transcript-count {
  color: var(--muted);
  font-size: 10px;
}

.compact-button {
  gap: 5px;
  min-height: 30px;
  padding: 0 9px;
}

.compact-button .material-symbols-rounded {
  font-size: 15px;
}

.transcript-actions #saveTranscript:disabled {
  display: none;
}

.live-transcript-badge {
  align-items: center;
  background: rgba(71, 215, 161, 0.08);
  border: 1px solid rgba(71, 215, 161, 0.2);
  border-radius: 999px;
  color: var(--success);
  display: inline-flex;
  font-size: 9px;
  font-weight: 650;
  gap: 5px;
  padding: 5px 7px;
}

.transcript-cues {
  display: grid;
  flex: 1 1 auto;
  max-height: 230px;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 0;
  scroll-behavior: smooth;
}

.transcript-line {
  align-items: start;
  border-left: 2px solid transparent;
  display: grid;
  gap: 14px;
  grid-template-columns: 64px minmax(0, 1fr);
  padding: 7px 14px 7px 12px;
  transition: background 120ms ease, border-color 120ms ease;
}

.transcript-line:has(.transcript-word.is-active) {
  background: rgba(128, 101, 255, 0.045);
  border-color: var(--accent);
}

.transcript-time {
  background: transparent;
  border: 0;
  color: var(--faint);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1.8;
  padding: 1px 0;
  text-align: left;
}

.transcript-time:hover {
  color: var(--accent-hover);
}

.transcript-line-text {
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.8;
}

.transcript-word {
  border-radius: 4px;
  margin-right: 0.48em;
  outline: 0;
  padding: 1px 2px;
  transition: background 100ms ease, color 100ms ease, box-shadow 100ms ease;
}

.transcript-word.is-active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.transcript-word:focus {
  background: var(--surface-raised);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.transcript-save-row {
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 9px;
  gap: 14px;
  min-height: 34px;
  padding: 7px 14px;
}

.inspector-section a.secondary-button {
  text-decoration: none;
}

.auth-page {
  background: var(--bg);
  min-height: 100vh;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 500px);
  margin: 0 auto;
  min-height: 100vh;
  width: min(1120px, 100%);
}

.auth-brand {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(40px, 8vw, 110px);
}

.auth-brand img {
  height: 96px;
  margin-bottom: 30px;
  width: 96px;
}

.auth-brand h1 {
  color: var(--text-strong);
  font-size: clamp(34px, 5vw, 58px);
  letter-spacing: -0.045em;
  line-height: 1.02;
  margin: 10px 0 18px;
  max-width: 620px;
}

.auth-brand > p:last-child {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
  margin: 0;
  max-width: 560px;
}

.auth-card {
  align-self: center;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin: 28px;
  padding: clamp(28px, 5vw, 48px);
}

.auth-card h2 {
  color: var(--text-strong);
  font-size: 28px;
  letter-spacing: -0.03em;
  margin: 7px 0;
}

.auth-intro,
.auth-switch {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-form {
  display: grid;
  margin-top: 24px;
}

.auth-form label {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  margin: 14px 0 7px;
}

.auth-form input:not([type="hidden"]) {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font: inherit;
  min-height: 46px;
  padding: 0 13px;
}

.auth-submit {
  margin-top: 24px;
}

.input-help {
  color: var(--faint);
  font-size: 10px;
  line-height: 1.45;
  margin-top: 6px;
}

.auth-error {
  background: rgba(255, 115, 138, 0.1);
  border: 1px solid rgba(255, 115, 138, 0.32);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 18px;
  padding: 11px 12px;
}

.auth-switch {
  margin: 22px 0 0;
  text-align: center;
}

.auth-switch a {
  color: var(--accent-hover);
  font-weight: 650;
}

select {
  appearance: auto;
  background-color: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

html[data-theme="light"] select {
  color-scheme: light;
}

.info-callout {
  align-items: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 8px;
  line-height: 1.5;
  margin-top: 16px;
  padding: 11px;
}

.info-callout .material-symbols-rounded {
  color: var(--accent-hover);
  flex: 0 0 auto;
  font-size: 18px;
}

.inspector-section .secondary-button + .secondary-button {
  margin-top: 8px;
}

.status-section {
  border-bottom: 0;
}

.status-section p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  margin: 10px 0 0;
}

.status-section[data-tone="running"] .status-dot {
  animation: pulse 1.3s ease-in-out infinite;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.status-section[data-tone="error"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 115, 138, 0.1);
}

.progress-track {
  background: var(--surface-soft);
  border-radius: 999px;
  height: 6px;
  margin-top: 14px;
  overflow: hidden;
}

.progress-track span {
  background: var(--accent);
  display: block;
  height: 100%;
  transition: width 180ms ease;
  width: 0;
}

.progress-label {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  margin-top: 7px;
  text-align: right;
}

.drawer-backdrop {
  background: rgba(0, 0, 0, 0.52);
  inset: var(--topbar-height) 0 0;
  position: fixed;
  z-index: 70;
}

.toast-region {
  bottom: 18px;
  display: grid;
  gap: 9px;
  pointer-events: none;
  position: fixed;
  right: 18px;
  width: min(380px, calc(100vw - 36px));
  z-index: 100;
}

.toast {
  align-items: flex-start;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  display: flex;
  gap: 10px;
  padding: 13px 14px;
}

.toast.is-error {
  border-color: rgba(255, 115, 138, 0.45);
}

.toast .material-symbols-rounded {
  color: var(--accent-hover);
}

.toast.is-error .material-symbols-rounded {
  color: var(--danger);
}

@media (max-width: 1220px) {
  .app-layout {
    grid-template-columns: 56px 250px minmax(0, 1fr) 270px;
  }

  .topbar {
    gap: 12px;
    grid-template-columns: auto auto minmax(220px, 1fr) auto;
  }

  .carousel-view {
    padding-left: 16px;
    padding-right: 16px;
  }

  .filmstrip {
    grid-template-columns: repeat(7, minmax(58px, 1fr));
  }

  .filmstrip-item:nth-child(n + 8) {
    display: none;
  }
}

@media (max-width: 1080px) {
  .desktop-only {
    display: none !important;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    display: none;
  }

  .auth-card {
    justify-self: center;
    width: min(500px, calc(100% - 32px));
  }

  .mobile-only {
    display: inline-flex !important;
  }

  .topbar {
    grid-template-columns: auto minmax(180px, 1fr) auto;
  }

  .project-chip {
    display: none;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .icon-rail {
    display: none;
  }

  .history-panel,
  .inspector-panel {
    bottom: 0;
    box-shadow: var(--shadow);
    max-width: calc(100vw - 40px);
    position: fixed;
    top: var(--topbar-height);
    transition: transform 180ms ease;
    width: 330px;
    z-index: 80;
  }

  .history-panel {
    left: 0;
    transform: translateX(-105%);
  }

  .history-panel.is-open {
    transform: translateX(0);
  }

  .inspector-panel {
    right: 0;
    transform: translateX(105%);
  }

  .inspector-panel.is-open {
    transform: translateX(0);
  }

  .viewer-title-row h1 {
    max-width: 58vw;
  }
}

@media (max-width: 700px) {
  :root {
    --topbar-height: 0px;
  }

  .topbar {
    background: transparent;
    border: 0;
    display: block;
    height: 0;
    padding: 0;
    position: absolute;
    width: 100%;
    z-index: 90;
  }

  .topbar .brand,
  .topbar .project-chip,
  .search-box,
  .topbar #themeToggle,
  .topbar #importButton,
  .topbar #inspectorToggle {
    display: none !important;
  }

  .top-actions {
    display: block;
    pointer-events: none;
  }

  #historyToggle {
    backdrop-filter: blur(14px);
    background: rgba(7, 17, 31, 0.82);
    border: 1px solid var(--accent-border);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    color: var(--text-strong);
    height: 42px;
    left: 10px;
    pointer-events: auto;
    position: fixed;
    top: 10px;
    width: 42px;
    z-index: 100;
  }

  #historyToggle .material-symbols-rounded {
    font-size: 24px;
  }

  .viewer-header {
    display: none;
  }

  .viewer-panel {
    grid-template-rows: minmax(0, 1fr);
  }

  .history-panel,
  .inspector-panel {
    max-width: min(88vw, 350px);
    top: 0;
  }

  .history-panel .panel-heading {
    min-height: 62px;
    padding: 12px 16px 10px 64px;
  }

  .history-panel {
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  }

  .mobile-menu-tools {
    border-bottom: 1px solid var(--border);
    display: grid;
    gap: 9px;
    padding: 0 14px 13px;
  }

  .mobile-mode-switcher,
  .mobile-menu-actions {
    display: grid;
    gap: 7px;
  }

  .mobile-mode-switcher {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mobile-menu-actions {
    grid-template-columns: 1fr;
  }

  .mobile-menu-button {
    align-items: center;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--muted);
    display: inline-flex;
    font: inherit;
    font-size: 11px;
    gap: 7px;
    justify-content: center;
    min-height: 38px;
    padding: 0 9px;
  }

  .mobile-menu-actions .mobile-menu-button {
    justify-content: flex-start;
    padding-inline: 12px;
  }

  .mobile-menu-button.is-active {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent-hover);
  }

  .mobile-menu-button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
  }

  .mobile-menu-button .material-symbols-rounded {
    font-size: 18px;
  }

  .carousel-view {
    grid-template-rows: minmax(280px, 1fr) auto auto auto auto;
    padding: 6px 8px 8px;
  }

  .transcript-workspace {
    margin-inline: 0;
    max-height: 190px;
    min-height: 0;
    position: relative;
  }

  .transcript-heading {
    border: 0;
    min-height: 0;
    padding: 0;
    position: absolute;
    right: 8px;
    top: 8px;
    z-index: 4;
  }

  .transcript-title {
    display: none;
  }

  .transcript-actions {
    gap: 6px;
  }

  .transcript-actions .compact-button {
    border-radius: 50%;
    height: 34px;
    min-height: 34px;
    padding: 0;
    width: 34px;
  }

  .transcript-actions .copy-label,
  .transcript-actions .download-label,
  .transcript-actions .save-label {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }

  .transcript-cues {
    max-height: 190px;
    padding-block: 6px;
  }

  .transcript-line {
    gap: 9px;
    grid-template-columns: 54px minmax(0, 1fr);
    padding-left: 9px;
    padding-right: 50px;
  }

  .transcript-line-text {
    font-size: 11px;
  }

  .transcript-save-row {
    display: none;
  }

  .media-stage {
    display: flex;
    gap: 6px;
    justify-content: center;
    justify-items: center;
    padding-bottom: 8px;
    width: 100%;
  }

  .video-frame {
    grid-column: 1;
    width: 100%;
  }

  .video-frame video {
    width: 100%;
  }

  .auth-card {
    margin: 16px;
    padding: 26px 22px;
  }

  .stage-arrow {
    display: none;
  }

  .neighbor-frame {
    display: none;
  }

  .primary-frame {
    justify-self: center;
    margin-inline: 0;
    max-width: 100%;
  }

  .primary-frame[data-ratio="portrait"] {
    max-width: min(88vw, 360px);
  }

  .grid-view {
    padding: 8px 10px 24px;
  }

  .grid-selection-bar {
    border-radius: 0 0 var(--radius) var(--radius);
    margin-inline: -10px;
    padding-left: 58px;
    top: 0;
  }

  .grid-selection-bar.is-visible {
    margin-bottom: 10px;
  }

  .grid-selection-bar > span {
    display: none;
  }

  .grid-selection-bar .primary-button {
    margin-left: auto;
  }

  .frame-grid {
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-frame-button img {
    height: 118px;
  }

  .filmstrip {
    grid-template-columns: repeat(5, minmax(44px, 1fr));
  }

  .filmstrip-item:nth-child(n + 6) {
    display: none;
  }

  .transport-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .frame-readout span {
    max-width: 150px;
  }

  .drop-zone {
    min-height: 290px;
    padding: 28px 20px;
  }

  .drop-zone strong {
    font-size: 21px;
  }

  .empty-features {
    align-items: center;
    flex-direction: column;
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
