[hidden] { display: none !important; }

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --ink: #1c1b19;
  --ink-soft: #5c5852;
  --ink-faint: #8a857c;
  --paper: #ebe8e3;
  --paper-top: #f0ede8;
  --paper-bottom: #e6e2db;
  --paper-deep: #e0dbd3;
  --surface: #f7f5f1;
  --surface-raised: #fffcf7;
  --line: #d2cdc4;
  --line-strong: #b8b2a7;
  --accent: #c4501a;
  --accent-ink: #9a3c12;
  --accent-soft: #f3e4d8;
  --glow: rgba(196, 80, 26, 0.07);
  --danger: #a1281f;
  --warn-bg: #f3ead8;
  --warn-ink: #6e4e16;
  --video-void: #161513;
  --radius: 6px;
  --radius-lg: 10px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: 160ms ease;
  --preview-max-height: min(70vh, 32rem);

  color: var(--ink);
  background: var(--paper);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

:root[data-accent="warm"] {
  --accent: #c4501a;
  --accent-ink: #9a3c12;
  --accent-soft: #f3e4d8;
  --glow: rgba(196, 80, 26, 0.07);
}

:root[data-accent="teal"] {
  --accent: #0f766e;
  --accent-ink: #0d5f59;
  --accent-soft: #d7f1ee;
  --glow: rgba(15, 118, 110, 0.1);
}

:root[data-theme="dark"],
:root[data-theme="system"] {
  /* dark tokens applied below via media / explicit dark */
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --ink: #eceae6;
    --ink-soft: #b0aaa1;
    --ink-faint: #7f796f;
    --paper: #141311;
    --paper-top: #141311;
    --paper-bottom: #141311;
    --paper-deep: #2a2723;
    --surface: #1c1a17;
    --surface-raised: #23201c;
    --line: #3a3630;
    --line-strong: #524d45;
    --accent: #e26a2c;
    --accent-ink: #f0a06e;
    --accent-soft: rgba(226, 106, 44, 0.16);
    --danger: #f07167;
    --warn-bg: #2e2618;
    --warn-ink: #e0c48a;
    --video-void: #0a0908;
    --glow: rgba(226, 106, 44, 0.14);
  }

  :root[data-theme="system"][data-accent="teal"] {
    --accent: #2dd4bf;
    --accent-ink: #5eead4;
    --accent-soft: rgba(45, 212, 191, 0.14);
    --glow: rgba(45, 212, 191, 0.12);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eceae6;
  --ink-soft: #b0aaa1;
  --ink-faint: #7f796f;
  --paper: #141311;
  --paper-top: #141311;
  --paper-bottom: #141311;
  --paper-deep: #2a2723;
  --surface: #1c1a17;
  --surface-raised: #23201c;
  --line: #3a3630;
  --line-strong: #524d45;
  --danger: #f07167;
  --warn-bg: #2e2618;
  --warn-ink: #e0c48a;
  --video-void: #0a0908;
  --glow: rgba(196, 80, 26, 0.14);
}

:root[data-theme="dark"][data-accent="warm"],
:root[data-theme="dark"]:not([data-accent]) {
  --accent: #e26a2c;
  --accent-ink: #f0a06e;
  --accent-soft: rgba(226, 106, 44, 0.16);
}

:root[data-theme="dark"][data-accent="teal"] {
  --accent: #2dd4bf;
  --accent-ink: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --glow: rgba(45, 212, 191, 0.12);
}

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

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--paper-top) 0%, var(--paper) 48%, var(--paper-bottom) 100%);
}

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

.app-shell {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: 64px 0 96px;
}

.prefs-fab {
  position: fixed;
  z-index: 40;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.prefs-tune {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface-raised) 90%, transparent);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(28, 27, 25, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}

.prefs-tune:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.prefs-tune[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.prefs-tune svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.prefs-menu {
  width: min(240px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-raised) 94%, transparent);
  box-shadow: 0 12px 32px rgba(28, 27, 25, 0.16);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.prefs-menu-section + .prefs-menu-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.prefs-menu-label {
  margin: 0 0 8px;
  color: var(--ink-faint);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.prefs-group {
  display: flex;
  width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  gap: 2px;
}

.prefs-group button {
  flex: 1 1 0;
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.prefs-group button:hover {
  color: var(--ink);
}

.prefs-group button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface-raised);
}

.prefs-group.accent-group button[data-accent-choice="warm"][aria-pressed="true"] {
  background: #c4501a;
  color: #fffaf6;
}

.prefs-group.accent-group button[data-accent-choice="teal"][aria-pressed="true"] {
  background: #0f766e;
  color: #f3fffd;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .prefs-tune,
  :root[data-theme="system"] .prefs-menu {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  }

  :root[data-theme="system"] .prefs-group.accent-group button[data-accent-choice="teal"][aria-pressed="true"] {
    background: #2dd4bf;
    color: #06221e;
  }
}

:root[data-theme="dark"] .prefs-tune,
:root[data-theme="dark"] .prefs-menu {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .prefs-group.accent-group button[data-accent-choice="warm"][aria-pressed="true"] {
  background: #e26a2c;
  color: #1a100a;
}

:root[data-theme="dark"] .prefs-group.accent-group button[data-accent-choice="teal"][aria-pressed="true"] {
  background: #2dd4bf;
  color: #06221e;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 28px 48px;
  align-items: end;
  margin-bottom: 40px;
}

.hero-lead {
  min-width: 0;
}

.brand {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.4rem, 6vw, 3.75rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.045em;
}

.hero h1 {
  margin: 14px 0 0;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero-copy {
  margin: 0;
  max-width: none;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.65;
  font-weight: 400;
  text-wrap: pretty;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: 0 1px 0 rgba(28, 27, 25, 0.04);
}

.controls-panel { padding: 28px; }

.file-picker {
  display: flex;
  min-height: 188px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
  text-align: center;
  transition: border-color var(--ease), background var(--ease);
}

.file-picker:hover,
.file-picker.dragging {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
}

.file-picker.has-file {
  border-style: solid;
  border-color: var(--line-strong);
  background: var(--surface);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--ink);
}

.upload-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-picker strong {
  max-width: 100%;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.picker-action {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface-raised);
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.file-picker:hover .picker-action,
.file-picker.dragging .picker-action {
  background: var(--accent);
  border-color: var(--accent);
}

.selected-file {
  max-width: 100%;
  color: var(--ink-soft);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.preset-group {
  border: 0;
  margin: 28px 0 0;
  padding: 0;
}

.preset-group legend,
.section-label {
  margin-bottom: 12px;
  padding: 0;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.preset-card {
  display: flex;
  gap: 10px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}

.preset-card:hover { border-color: var(--line-strong); }

.preset-card.selected {
  border-color: var(--ink);
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.preset-card input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.preset-card span { display: grid; gap: 6px; align-content: start; }

.preset-card strong {
  font-size: 0.95rem;
  font-weight: 500;
}

.preset-card small {
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.custom-settings {
  margin: 14px 0 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  min-inline-size: 0;
}

.custom-settings .section-label {
  display: block;
  margin: 0 0 14px;
}

.custom-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.custom-grid label {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.custom-grid label > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.custom-grid output,
.thread-heading output {
  min-width: 32px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
}

.custom-grid select {
  width: 100%;
  min-height: 40px;
  padding: 8px 32px 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--ink);
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.crf-slider,
.performance-settings .modern-range,
.media-controls input {
  width: 100%;
  margin: 0;
}

/* Magnetic minimal slider */
.mag-slider {
  --range-fill: 0%;
  --thumb-size: 18px;
  position: relative;
  width: 100%;
  height: 44px;
  touch-action: none;
}

.mag-slider.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.mag-slider-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mag-slider-rail {
  position: absolute;
  left: calc(var(--thumb-size) / 2);
  right: calc(var(--thumb-size) / 2);
  top: 50%;
  height: 6px;
  border-radius: 999px;
  background: var(--paper-deep);
  transform: translateY(-50%);
}

.mag-slider-fill {
  position: absolute;
  left: calc(var(--thumb-size) / 2);
  top: 50%;
  width: calc((100% - var(--thumb-size)) * var(--range-fill, 0) / 100);
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateY(-50%);
  transform-origin: left center;
}

.mag-slider-ticks {
  position: absolute;
  left: calc(var(--thumb-size) / 2);
  right: calc(var(--thumb-size) / 2);
  top: calc(50% + 11px);
  height: 0;
  opacity: 0;
  transition: opacity 160ms ease;
}

.mag-slider.is-dragging .mag-slider-ticks {
  opacity: 1;
}

.mag-slider-tick {
  position: absolute;
  top: 0;
  width: 1.5px;
  height: 7px;
  border-radius: 1px;
  background: var(--line-strong);
  opacity: 0.5;
  transform: translateX(-50%);
  transition: background 160ms ease, opacity 160ms ease, height 160ms ease;
}

.mag-slider-tick.is-active {
  background: var(--accent);
  opacity: 0.95;
  height: 9px;
}

.mag-slider-thumb {
  position: absolute;
  top: 50%;
  left: calc(
    var(--thumb-size) / 2 + (100% - var(--thumb-size)) * var(--range-fill, 0) / 100
  );
  width: var(--thumb-size);
  height: var(--thumb-size);
  border-radius: 999px;
  background: var(--surface-raised);
  border: 2px solid var(--accent);
  box-shadow:
    0 0 0 3px var(--accent-soft),
    0 2px 10px rgba(28, 27, 25, 0.12);
  transform: translate(-50%, -50%);
  transition: left 220ms cubic-bezier(0.22, 1.2, 0.36, 1), border-color 160ms ease, box-shadow 160ms ease;
  will-change: left;
}

.mag-slider.is-dragging .mag-slider-thumb {
  transition: none;
  border-color: var(--accent-ink);
  box-shadow:
    0 0 0 5px var(--accent-soft),
    0 4px 14px rgba(28, 27, 25, 0.16);
  transform: translate(-50%, -50%) scale(1.08);
}

.mag-slider.is-dragging .mag-slider-fill {
  transition: none;
}

.mag-slider:not(.is-dragging) .mag-slider-fill {
  transition: width 220ms cubic-bezier(0.22, 1.2, 0.36, 1);
}

.mag-slider .modern-range {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.mag-slider .modern-range:focus {
  outline: none;
}

.mag-slider:focus-within .mag-slider-thumb {
  box-shadow:
    0 0 0 4px var(--accent-soft),
    0 2px 10px rgba(28, 27, 25, 0.12);
}

.media-controls input[type="range"] {
  --range-fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 28px;
  background: transparent;
  cursor: pointer;
}

.media-controls input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    var(--accent) var(--range-fill),
    var(--paper-deep) var(--range-fill),
    var(--paper-deep) 100%
  );
}

.media-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 2px solid var(--surface-raised);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(28, 27, 25, 0.2);
}

.media-controls input[type="range"]::-moz-range-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--paper-deep);
}

.media-controls input[type="range"]::-moz-range-progress {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
}

.media-controls input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--surface-raised);
  border-radius: 50%;
  background: var(--accent);
}

.performance-settings { margin: 28px 0; }

.performance-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: start;
}

.performance-col {
  min-width: 0;
}

.speed-heading,
.thread-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.speed-heading strong,
.thread-heading strong {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.speed-heading output {
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 400;
  text-align: right;
  max-width: 65%;
  line-height: 1.35;
}

.thread-control {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.thread-warning {
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid #e0d2b4;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 0.8rem;
  line-height: 1.45;
}

.primary-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fffaf6;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background var(--ease), border-color var(--ease), opacity var(--ease);
}

.primary-button:hover:not(:disabled),
.download-button:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}

.primary-button {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 0.95rem;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.download-button {
  padding: 8px 12px;
  font-size: 0.84rem;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fullscreen-button,
.media-controls button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}

.fullscreen-button:hover,
.media-controls button:hover {
  border-color: var(--ink);
  background: var(--surface-raised);
}

.fullscreen-button svg,
.icon-control svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#progress-section { margin-top: 18px; }

.progress-track {
  height: 3px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 0;
  background: var(--paper-deep);
}

.progress-value {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.encoding-timing {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.encoding-timing strong {
  display: inline-block;
  min-width: 4.5em;
  margin-left: 6px;
  color: var(--ink);
  font-weight: 500;
  text-align: right;
}

.status {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 500;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  overflow: hidden;
}

.stat-card {
  padding: 18px 20px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.stat-card:last-child { border-right: 0; }

.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-card strong {
  font-size: 1.35rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.comparison-card { overflow: hidden; }

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.preview-title {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.video-comparison {
  position: relative;
  width: 100%;
  height: var(--preview-max-height);
  max-height: var(--preview-max-height);
  overflow: hidden;
  background: var(--video-void);
  user-select: none;
}

.video-comparison video {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--video-void);
  object-fit: contain;
}

.compressed-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.comparison-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 24px;
  background: linear-gradient(transparent 45%, rgba(22, 21, 19, 0.88));
  color: #e8e4dc;
  font-size: 0.9rem;
  text-align: center;
}

.comparison-label {
  position: absolute;
  z-index: 3;
  top: 14px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 252, 247, 0.28);
  border-radius: 3px;
  background: rgba(22, 21, 19, 0.72);
  color: #fffcf7;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
}

.compressed-label { left: 14px; }
.original-label { right: 14px; }

.comparison-divider {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #fffcf7;
  transform: translateX(-50%);
  pointer-events: none;
}

.comparison-divider span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #fffcf7;
  border-radius: 50%;
  background: var(--ink);
  color: #fffcf7;
  font-size: 0.95rem;
  transform: translate(-50%, -50%);
}

.comparison-slider {
  position: absolute;
  z-index: 5;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: ew-resize;
  opacity: 0;
}

.media-controls {
  display: grid;
  grid-template-columns: auto auto minmax(80px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-raised);
}

.media-controls .icon-control {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
}

.icon-control .play-shape {
  fill: currentColor;
  stroke: currentColor;
}

#play-btn[aria-pressed="true"] #play-icon,
#play-btn:not([aria-pressed="true"]) #pause-icon {
  display: none !important;
}

.media-controls span {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.comparison-card:fullscreen {
  position: relative;
  display: block;
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  background: #000;
}

.comparison-card:fullscreen .preview-heading {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px 22px 44px;
  border: 0;
  background: linear-gradient(rgba(2, 6, 14, 0.82), transparent);
  color: #fff;
  pointer-events: none;
}

.comparison-card:fullscreen .preview-actions { pointer-events: auto; }
.comparison-card:fullscreen .download-button { display: none; }

.comparison-card:fullscreen .fullscreen-button {
  border-color: rgba(255, 255, 255, 0.32);
  border-radius: var(--radius);
  background: rgba(9, 15, 28, 0.58);
  color: #fff;
}

.comparison-card:fullscreen .video-comparison {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  background: #000;
}

.comparison-card:fullscreen .video-comparison video { background: #000; }
.comparison-card:fullscreen .comparison-label { top: 74px; }

.comparison-card:fullscreen .media-controls {
  position: absolute;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 44px 22px 20px;
  border: 0;
  background: linear-gradient(transparent, rgba(2, 6, 14, 0.86));
}

.comparison-card:fullscreen .media-controls button {
  border-color: rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  background: rgba(9, 15, 28, 0.62);
  color: #fff;
}

.comparison-card:fullscreen .media-controls span { color: #c4ccda; }

.note {
  margin-top: 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.6;
}

.note strong {
  color: var(--ink);
  font-weight: 500;
}

.note code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.84em;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1040px);
    padding-top: 36px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
  }

  .prefs-fab {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .controls-panel { padding: 20px; }

  .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .custom-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-card:nth-child(2) { border-right: 0; }
  .stat-card:nth-child(1),
  .stat-card:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 430px) {
  .controls-panel { padding: 16px; }
  .preset-grid,
  .custom-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }

  .stat-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stat-card:last-child { border-bottom: 0; }

  .preview-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-actions { width: 100%; }
  .preview-actions .download-button,
  .preview-actions .fullscreen-button { flex: 1; }

  .comparison-label { top: 10px; }
  .compressed-label { left: 10px; }
  .original-label { right: 10px; }

  .media-controls {
    grid-template-columns: auto 1fr auto;
    gap: 9px;
  }

  .media-controls span { display: none; }
}
