/* MCX1 Media Codec X1 - Precision Cinema & Broadcast Studio Stylesheet */
:root,
html[data-theme="night"] {
  --bg: #080A0E;
  --surface: #10141C;
  --surface-2: #161C27;
  --border: #222B3A;
  --border-strong: #334155;
  --text: #EDF2F7;
  --muted: #94A3B8;
  --accent: #38BDF8;
  --on-accent: #04121B;
  --emerald: #10B981;
  --emerald-bg: rgba(16, 185, 129, 0.14);
  --cyan-bg: rgba(56, 189, 248, 0.14);
  --amber: #F59E0B;
  --amber-bg: rgba(245, 158, 11, 0.15);
  --red: #EF4444;
  --red-bg: rgba(239, 68, 68, 0.16);
  --focus: #38BDF8;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

html[data-theme="day"] {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --border: #CBD5E1;
  --border-strong: #94A3B8;
  --text: #0F172A;
  --muted: #475569;
  --accent: #0369A1;
  --on-accent: #FFFFFF;
  --emerald: #065F46;
  --emerald-bg: rgba(6, 95, 70, 0.10);
  --cyan-bg: rgba(3, 105, 161, 0.10);
  --amber: #92400E;
  --amber-bg: rgba(146, 64, 14, 0.11);
  --red: #B91C1C;
  --red-bg: rgba(185, 28, 28, 0.10);
  --focus: #0369A1;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-family: var(--sans); background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); line-height: 1.5; font-size: 15px; overflow-x: clip; }
[hidden] { display: none !important; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { opacity: 0.88; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 700;
  z-index: 200;
}
.skip-link:focus { left: 12px; }

.wrap {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 18px;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.xs { font-size: 12.5px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Header */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
header.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding-block: 6px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex: none;
}
.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
}
.brand-sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
nav.top-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
}
nav.top-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 10px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  white-space: nowrap;
}
nav.top-nav a:hover,
nav.top-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
}
.spacer { flex: 1; min-width: 4px; }
.zero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--emerald-bg);
  color: var(--emerald);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.menu-btn { display: none; }

/* Mobile drawer */
#nav-drawer {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 18px 16px;
}
.drawer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.drawer-grid a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
}

/* Studio Workspace (Above-the-Fold Priority) */
.studio-section {
  padding: 14px 0 24px;
}
.studio-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 10px;
}
.studio-head h1 {
  margin: 0;
  font-size: clamp(20px, 2.4vw, 26px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.studio-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Preset Bar */
.preset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
}
.preset-pill {
  min-height: 44px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.preset-pill:hover { border-color: var(--accent); }
.preset-pill.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.custom-mb-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.custom-mb-wrap input {
  width: 84px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
}
.preset-note {
  margin: 0 0 0 auto;
  font-size: 12.5px;
  color: var(--muted);
}

.noscript-box {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--amber);
  background: var(--amber-bg);
  color: var(--text);
  font-size: 13.5px;
}

/* Dropzone */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 220px;
  padding: 22px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--cyan-bg);
}
.dropzone.is-loading { opacity: 0.72; }
.dropzone-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}
.dropzone-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 56ch;
}
.dropzone-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* Telemetry Status Strip */
.cap-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}
.cap-strip.cap-ok .cap-dot { background: var(--emerald); }
.cap-strip.cap-warn .cap-dot { background: var(--amber); }
.cap-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
}

/* Buttons & Form Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { opacity: 0.92; }
.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}
.btn.sm { min-height: 44px; padding: 0 12px; font-size: 13px; }
.btn.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

select, input[type="number"], input[type="text"] {
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.error-box {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--red);
  background: var(--red-bg);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

/* Active Studio Deck */
.studio-deck {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 10px;
}
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}
.panel h2, .panel h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
}

/* Viewport Stage + Blur Overlay */
.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.stage-wrap video,
.stage-wrap img.stage-gif {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.blur-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
}
.blur-canvas.is-drawing {
  pointer-events: auto;
  cursor: crosshair;
}

.transport-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.timecode-pill {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
}

/* Blur Toolbar */
.blur-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Trim & Filmstrip */
.filmstrip {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 2px;
  margin-top: 12px;
  min-height: 42px;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  align-items: center;
}
.thumb-btn {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  border-radius: 3px;
  display: block;
}
.thumb-btn img {
  width: 100%;
  height: 36px;
  object-fit: cover;
  display: block;
}
.trim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.trim-box {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.trim-box label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 4px;
}
.trim-box input[type="range"] {
  width: 100%;
  min-height: 36px;
  accent-color: var(--accent);
}
.trim-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

/* Right Rail: Path Badge, SVG Fuel Gauge, Controls */
.path-badge {
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.path-lossless {
  background: var(--emerald-bg);
  border-color: var(--emerald);
  color: var(--emerald);
}
.path-gpu {
  background: var(--cyan-bg);
  border-color: var(--accent);
  color: var(--accent);
}
.path-warn {
  background: var(--amber-bg);
  border-color: var(--amber);
  color: var(--amber);
}

.gauge-box {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.gauge-svg {
  width: 100%;
  height: 12px;
  display: block;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
}
.seg-video { fill: var(--accent); }
.seg-audio { fill: var(--emerald); }
.seg-mux { fill: var(--amber); }
.gauge-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 10px;
}
.check-lbl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 13.5px;
  cursor: pointer;
}
.check-lbl input { width: 18px; height: 18px; accent-color: var(--accent); }

.run-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.run-row .btn-primary { flex: 1; }

/* Progress & Result */
.progress-box, .result-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.result-box {
  border-color: var(--emerald);
  background: var(--surface);
}
.progress-box progress {
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.result-headline {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--emerald);
  margin: 0 0 4px;
}
.result-preview {
  width: 100%;
  max-height: 240px;
  margin-top: 10px;
  border-radius: 8px;
  background: #000000;
}
.result-audio {
  width: 100%;
  margin-top: 10px;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

/* Frames gallery */
.frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.frame-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.frame-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}
.frame-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  gap: 6px;
}

/* Inspector & Metadata Tables */
.data-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data-table th,
table.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data-table th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.tag-stripped {
  font-family: var(--mono);
  color: var(--emerald);
  font-weight: 700;
}

/* Below-the-Fold Tool Directory, Explainer & FAQ */
.content-section {
  padding: 20px 0 32px;
  border-top: 1px solid var(--border);
}
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.tool-card {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.tool-card:hover { border-color: var(--accent); }
.tool-card-title { font-weight: 700; font-size: 14px; margin: 0 0 4px; }
.tool-card-desc { margin: 0; font-size: 12.5px; color: var(--muted); }

.faq-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
}
.faq-item summary {
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
  display: flex;
  align-items: center;
}
.faq-item p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* Offline Verifier Page */
.probe-status {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 13px;
}
.probe-pass { border-color: var(--emerald); background: var(--emerald-bg); color: var(--emerald); }
.probe-fail { border-color: var(--red); background: var(--red-bg); color: var(--red); }

/* Footer */
footer.site-foot {
  border-top: 1px solid var(--border);
  padding: 20px 0 32px;
  color: var(--muted);
  font-size: 13px;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 10px;
}
.foot-links a {
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.foot-links a:hover { text-decoration: underline; }
.disclaimer-line {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 960px) {
  nav.top-nav { display: none; }
  .menu-btn { display: inline-flex; }
  .studio-deck { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .wrap { padding-inline: 12px; }
  .brand-sub { display: none; }
  .zero-pill { font-size: 11.5px; padding: 4px 8px; }
  .studio-section { padding: 8px 0 18px; }
  .studio-head { margin-bottom: 8px; }
  .studio-head h1 { font-size: 19px; }
  .studio-sub { font-size: 13px; }
  .preset-bar { padding: 7px 8px; gap: 5px; margin-bottom: 8px; }
  .preset-pill { min-height: 44px; padding: 0 9px; font-size: 12px; }
  .preset-note { width: 100%; margin-left: 0; font-size: 12px; }
  .dropzone { min-height: 144px; padding: 14px 12px; }
  .dropzone-title { font-size: 15px; }
  .dropzone-sub { font-size: 12.5px; margin-bottom: 10px; }
  .keys-hint { display: none; }
  .trim-grid, .controls-grid { grid-template-columns: 1fr; }
  select, input[type="number"], input[type="text"] { font-size: 16px; }
}

@media (max-width: 359px) {
  header.topbar .wrap { gap: 4px; padding-inline: 10px; min-height: 50px; }
  .spacer { min-width: 0; }
  .zero-pill { font-size: 10.5px; padding: 4px 6px; }
  .icon-btn { padding: 0 8px; font-size: 12px; }
  .preset-bar { padding: 6px; gap: 4px; }
  .preset-pill { padding: 0 7px; font-size: 11.5px; }
  .preset-note { display: none; }
  .dropzone { min-height: 118px; padding: 10px; }
  .dropzone-sub { display: none; }
  .dropzone-title { font-size: 14px; margin-bottom: 8px; }
}

/* Landscape phone (e.g. 844x390): keep preset bar + dropzone 100% above the fold */
@media (max-height: 500px) and (orientation: landscape) {
  header.topbar .wrap { min-height: 46px; padding-block: 2px; gap: 8px; }
  .studio-section { padding: 6px 0 16px; }
  .studio-head { margin-bottom: 6px; }
  .studio-head h1 { font-size: 18px; }
  .studio-sub { display: none; }
  .preset-bar { padding: 6px 8px; gap: 6px; margin-bottom: 6px; }
  .preset-pill { min-height: 44px; padding: 0 9px; font-size: 12px; }
  .preset-note { display: none; }
  .dropzone { min-height: 104px; padding: 10px 14px; }
  .dropzone-title { font-size: 15px; margin-bottom: 4px; }
  .dropzone-sub { font-size: 12.5px; margin-bottom: 8px; }
  .cap-strip { margin-top: 6px; padding: 5px 10px; font-size: 11.5px; }
  .keys-hint { display: none; }
}

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

/* Print Stylesheet: clean black on white */
@media print {
  :root, html, html[data-theme="night"], html[data-theme="day"] {
    color-scheme: light;
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  header.topbar, #nav-drawer, .dropzone, .transport-row, .blur-toolbar, .trim-actions, .run-row, .btn {
    display: none !important;
  }
  body, .panel, .faq-item, .tool-card {
    background: #FFFFFF !important;
    color: #000000 !important;
    border-color: #CCCCCC !important;
  }
  .muted, .disclaimer-line { color: #333333 !important; }
}
