/* xvid — a focused media utility. No fonts, frameworks or image requests. */
:root {
  color-scheme: light dark;
  --canvas: #ffffff;
  --surface: #ffffff;
  --soft: #f5f5f7;
  --ink: #18181b;
  --muted: #62626b;
  --line: #dedee3;
  --control-line: #8d8d96;
  --accent: #e10600;
  --accent-hover: #bd0803;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --warning: #805300;
  --success: #187046;
  --focus: #1769db;
  --radius-control: 0.75rem;
  --radius-surface: 1.5rem;
  --tap: 3rem;
  font: 16px/1.5 "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0b0b0b;
    --surface: #141416;
    --soft: #202023;
    --ink: #fafafa;
    --muted: #afafb8;
    --line: #39393f;
    --control-line: #72727d;
    --accent: #ff453a;
    --accent-hover: #ff6258;
    --accent-ink: #0b0b0b;
    --danger: #ff938b;
    --warning: #efc46b;
    --success: #86d4a6;
    --focus: #91baff;
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
button, input, summary { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button, a { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.6; }
a { text-underline-offset: 0.2em; }
button, input, .primary-link, .download-action, .share-action { touch-action: manipulation; }
:where(button, a, input, summary):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}
::selection { background: var(--accent); color: var(--accent-ink); }

.app-shell {
  width: min(100%, 74rem);
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
}
.app-header {
  display: flex;
  min-height: 3rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.25rem;
}
.brand {
  display: inline-flex;
  min-height: 3.5rem;
  padding-inline: 0.25rem;
  align-items: center;
  color: var(--ink);
  font-size: 2.625rem;
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 1.2;
  text-decoration: none;
}
.brand::after {
  content: "";
  width: 0.22em;
  height: 0.22em;
  margin-left: 0.14em;
  align-self: center;
  transform: translateY(0.25em);
  border-radius: 50%;
  background: var(--accent);
}
.connection-state { color: var(--muted); font-size: 0.8125rem; font-weight: 600; }

.compose-shell { max-width: 38rem; }
.source-summary h1,
.problem-view h1,
.problem-view h2,
.ready-heading h2,
.choice-heading h2 {
  margin: 0;
  font-weight: 750;
  letter-spacing: -0.045em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.persistent-composer {
  min-width: 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.25rem;
  background: var(--canvas);
}
.compose-shell .persistent-composer {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-surface);
  padding: 1.5rem;
  background: var(--soft);
}
.link-form { display: grid; gap: 0.75rem; }
.link-form > label,
fieldset legend { color: var(--ink); font-size: 0.875rem; font-weight: 650; }
.url-control { position: relative; min-width: 0; }
.url-control input {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  border: 1px solid var(--control-line);
  border-radius: var(--radius-control);
  padding: 0.875rem 3.25rem 0.875rem 1rem;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  appearance: none;
}
.url-control input::placeholder { color: var(--muted); opacity: 1; }
.url-control input:focus { border-color: var(--focus); }
.url-control input[aria-invalid="true"] { border-color: var(--danger); }
.clear-input {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  transform: translateY(-50%);
  border: 0;
  border-radius: 0.5rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}
.field-error { margin: 0; color: var(--danger); font-size: 0.875rem; overflow-wrap: anywhere; }
button, .primary-link, .download-action, .share-action {
  min-height: var(--tap);
  border-radius: var(--radius-control);
  font-weight: 650;
}
.primary-action, .primary-link {
  display: inline-flex;
  width: 100%;
  min-height: 3.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  padding: 0.875rem 1.25rem;
  background: var(--accent);
  color: var(--accent-ink);
  text-align: center;
  text-decoration: none;
}
.text-action, .danger-action {
  min-height: var(--tap);
  border: 0;
  padding: 0.625rem 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
.privacy-note { margin: 1rem 0 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.7; }
.link-form [data-navigation-status] { margin: 0; }

#job-state, .state-view { min-width: 0; width: 100%; }
.source-summary { margin-bottom: 1.75rem; }
.source-meta, .section-kicker { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.source-summary h1 { max-width: 30ch; font-size: clamp(1.75rem, 5vw, 2.5rem); line-height: 1.15; }
.progress-panel {
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.25rem;
  background: var(--soft);
}
.progress-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.progress-heading strong { min-width: 0; font-weight: 650; overflow-wrap: anywhere; }
.progress-heading span { flex: none; color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
progress {
  display: block;
  width: 100%;
  height: 0.5rem;
  margin-top: 1rem;
  border: 0;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--line);
  accent-color: var(--accent);
}
progress::-webkit-progress-bar { border-radius: 1rem; background: var(--line); }
progress::-webkit-progress-value { border-radius: 1rem; background: var(--accent); }
progress::-moz-progress-bar { border-radius: 1rem; background: var(--accent); }
.progress-detail { min-height: 1.25rem; margin: 0.875rem 0 0; color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cancel-form { margin-top: 0.5rem; }
.cancel-form .text-action { color: var(--muted); font-size: 0.875rem; }
.inline-message { margin: 1.25rem 0; border-left: 3px solid var(--line); padding: 0.25rem 0 0.25rem 1rem; }
.inline-message.warning { border-left-color: var(--warning); }
.inline-message.error { border-left-color: var(--danger); }
.inline-message.source-ready { border-left-color: var(--success); }
.inline-message p, .choice-heading p, .problem-view > p { margin: 0.625rem 0 0; color: var(--muted); line-height: 1.65; }
.inline-message p { font-size: 0.9375rem; }

.choice-heading { margin-bottom: 1.75rem; }
.choice-heading h2, .ready-heading h2, .problem-view h2 { font-size: 1.75rem; }
.choice-heading p { font-size: 0.9375rem; }
.resolution-options { display: grid; gap: 0.625rem; }
.resolution-row {
  display: flex;
  width: 100%;
  min-height: 3.5rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--control-line);
  padding: 0.875rem 1rem;
  background: var(--surface);
  text-align: left;
}
.row-value { color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.resolution-toggle { display: flex; align-items: center; justify-content: space-between; min-height: 3rem; gap: 1rem; cursor: pointer; }
.resolution-toggle input {
  appearance: none;
  flex: none;
  width: 2.75rem;
  height: 1.625rem;
  margin: 0;
  border: 1px solid var(--control-line);
  border-radius: 2rem;
  background: var(--surface);
  cursor: pointer;
}
.resolution-toggle input::before { content: ""; display: block; width: 1.125rem; height: 1.125rem; margin: 0.1875rem; border-radius: 50%; background: var(--muted); }
.resolution-toggle input:checked { background: var(--accent); border-color: var(--accent); }
.resolution-toggle input:checked::before { transform: translateX(1.125rem); background: var(--accent-ink); }
.link-form .secondary-action { width: 100%; min-height: 3.5rem; padding: 0.875rem 1.25rem; }

.ready-heading { margin-bottom: 1.25rem; }
.ready-view > .primary-action, .ready-view > .primary-link { margin-bottom: 1rem; }
.artifact-list { display: grid; gap: 0; }
.artifact-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.75rem 1rem; border-top: 1px solid var(--line); padding: 1rem 0; }
.artifact-row:last-child { border-bottom: 1px solid var(--line); }
.artifact-copy { min-width: 0; }
.artifact-copy strong, .artifact-copy span { display: block; overflow-wrap: anywhere; }
.artifact-copy strong { font-size: 0.9375rem; font-weight: 600; }
.artifact-copy span { margin-top: 0.25rem; color: var(--muted); font-size: 0.8125rem; }
.artifact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.download-action, .share-action { display: inline-flex; min-height: 3rem; align-items: center; justify-content: center; border: 1px solid var(--control-line); padding: 0.625rem 1rem; background: var(--surface); color: var(--ink); font-size: 0.875rem; text-decoration: none; }
.share-action[data-share-primary], .artifact-row:only-child .download-action { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.artifact-row:only-child .share-action:not([hidden]) + .download-action { border-color: var(--control-line); background: var(--surface); color: var(--ink); }
.device-preparation { grid-column: 1 / -1; margin-top: 0.25rem; padding-top: 0.5rem; }
.device-preparation > div { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.8125rem; }
.device-preparation progress { margin-top: 0.625rem; }
.playback { display: block; width: 100%; max-height: min(65vh, 38rem); margin-top: 1.5rem; border-radius: 1rem; background: #000000; object-fit: contain; }
.audio-playback { min-height: 3.5rem; background: transparent; }
.image-playback { height: auto; }
.expiry-note { margin: 1rem 0 0; color: var(--muted); font-size: 0.8125rem; }
.secondary-form { margin: 1rem 0; }
.secondary-action { width: 100%; border: 1px solid var(--control-line); padding: 0.75rem 1rem; background: var(--surface); }
.problem-view { min-width: 0; max-width: 38rem; }
.problem-view h1 { font-size: clamp(2rem, 7vw, 3.25rem); }
.problem-view > p { margin-bottom: 1.5rem; }
.problem-view .primary-link { max-width: 24rem; }
.problem-view.calm { margin-top: 1rem; }
.job-utilities { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 0.75rem; font-size: 0.8125rem; }
.job-utilities a { display: inline-flex; min-height: var(--tap); align-items: center; }
.job-utilities form { margin: 0; }
.danger-action { color: var(--danger); font-size: 0.8125rem; }
.app-shell[aria-busy="true"] .link-form { opacity: 0.65; pointer-events: none; }

@media (hover: hover) {
  .primary-action:hover, .primary-link:hover { background: var(--accent-hover); }
  .resolution-row:hover, .clear-input:hover, .secondary-action:hover, .download-action:hover, .share-action:hover { background: var(--soft); }
  .share-action[data-share-primary]:hover, .artifact-row:only-child .download-action:hover { background: var(--accent-hover); }
  .artifact-row:only-child .share-action:not([hidden]) + .download-action:hover { background: var(--soft); }
  .text-action:hover, .danger-action:hover, .job-utilities a:hover { text-decoration-thickness: 2px; }
}

@media (min-width: 40rem) and (max-width: 59.999rem) {
  .app-shell { max-width: 44rem; padding-inline: 2rem; }
  .compose-shell .persistent-composer { padding: 2rem; }
}

@media (min-width: 60rem) {
  .app-shell { padding: max(2rem, env(safe-area-inset-top)) max(2.5rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(2.5rem, env(safe-area-inset-left)); }
  .compose-shell .app-header { margin-bottom: 3rem; }
  .compose-shell .persistent-composer { padding: 2rem; }
  .job-shell, .problem-shell { display: grid; grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr); grid-template-rows: auto 1fr; column-gap: 3.5rem; align-content: start; }
  .job-shell .app-header, .problem-shell .app-header { grid-column: 1 / -1; margin-bottom: 3rem; }
  .job-shell > .persistent-composer, .problem-shell > .persistent-composer { position: sticky; top: 2rem; align-self: start; grid-column: 1; grid-row: 2; margin: 0; border: 1px solid var(--line); border-radius: var(--radius-surface); padding: 1.5rem; background: var(--soft); }
  #job-state, .problem-shell > .problem-view { grid-column: 2; grid-row: 2; }
}

@media (max-width: 25rem) {
  .compose-shell .persistent-composer { padding: 1.25rem; }
  .artifact-row { grid-template-columns: minmax(0, 1fr); }
  .artifact-actions { width: 100%; }
  .artifact-actions > * { flex: 1; }
  .row-value { font-size: 0.75rem; }
}
@media (max-height: 35rem) and (min-width: 60rem) {
  .job-shell > .persistent-composer, .problem-shell > .persistent-composer { position: static; }
}
@media (prefers-reduced-motion: no-preference) {
  progress:not([value]) { animation: working 1.2s ease-in-out infinite alternate; }
  @keyframes working { from { opacity: 0.4; } to { opacity: 1; } }
  button, .primary-link, .download-action, .share-action { transition: background-color 120ms ease-out; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .resolution-toggle input { appearance: auto; }
  .resolution-toggle input::before { display: none; }
  progress { border: 1px solid CanvasText; }
}

/* Instagram's picker is a bounded list of ordinary forms, not a client store. */
.instagram-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-block: 1.5rem; }
.instagram-item { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-control); padding: 1rem; }
.instagram-thumbnail { display: block; width: 100%; height: 20rem; object-fit: contain; background: var(--soft); border-radius: 0.5rem; }
.instagram-placeholder { display: grid; place-items: center; color: var(--muted); }
.instagram-item .primary-action { width: 100%; }
.instagram-item.is-suggested { border: 2px solid var(--accent); }
.instagram-hint { color: var(--muted); font-size: 0.875rem; }
@media (max-width: 40rem) { .instagram-grid { grid-template-columns: 1fr; } .instagram-thumbnail { height: min(70vh, 30rem); } }
