/* ThreadSave design system. Tokens and rules are documented in /DESIGN.md. */

:root {
  /* Color - dark is the primary theme; [data-theme="light"] below overrides it.
     Same token names carry inverted meaning by design, see DESIGN.md. */
  --paper: #121212;
  --surface: #1b1b19;
  --ink: #f5f4f1;
  --ink-soft: #dcdbd6;
  --muted: #8c8c85;
  --muted-strong: #c7c6c0;
  --line: #2c2c29;
  --line-strong: #3d3d39;
  /* Safety/footer stay dark (not a light flip) - a distinct neutral charcoal
     so they read as a different section without breaking the dark-primary
     aesthetic. See DESIGN.md. */
  --inverse: #17171a;
  --inverse-ink: #f5f4f1;
  --inverse-muted: #a8a8ac;
  --inverse-surface: #202024;
  --inverse-line: #38383c;
  --accent: #ddf24d;
  --danger: #ff8a80;
  --danger-surface: #2a1416;
  --danger-line: #4a2024;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, "Apple Color Emoji", sans-serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: clamp(22px, 2.4vw, 26px);
  --text-2xl: clamp(28px, 4vw, 40px);
  --text-3xl: clamp(38px, 7vw, 68px);
  --tracking-tight: -0.035em;
  --tracking-wide: 0.08em;

  /* Space */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 72px;
  --space-9: 104px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --radius-pill: 999px;

  /* Material */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 60px -32px rgba(0, 0, 0, 0.7);

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 260ms;

  /* Layout */
  --tap: 44px;
}

/* Light theme: opt-in override, toggled via #theme-toggle and persisted to
   localStorage("threadsave-theme"). Values match the original light palette. */
:root[data-theme="light"] {
  --paper: #f6f5f2;
  --surface: #ffffff;
  --ink: #111111;
  --ink-soft: #2e2e2c;
  --muted: #6b6b66;
  --muted-strong: #4a4a45;
  --line: #e2e1dc;
  --line-strong: #cfcec8;
  --inverse: #0d0d0c;
  --inverse-ink: #f6f5f2;
  --inverse-muted: #a3a39c;
  --inverse-surface: #151514;
  --inverse-line: #262624;
  --danger: #8a1c1c;
  --danger-surface: #fdf1f1;
  --danger-line: #f0cccc;
  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.06);
  --shadow-md: 0 8px 24px -12px rgba(17, 17, 17, 0.22);
  --shadow-lg: 0 24px 60px -32px rgba(17, 17, 17, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: var(--tracking-tight);
  line-height: 1.05;
  text-wrap: balance;
}

p {
  margin: 0;
  overflow-wrap: anywhere;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
video {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: 20;
  padding: var(--space-3) var(--space-4);
  background: var(--ink);
  /* Text on an --ink-filled control: always the inverse of --ink itself
     (--paper is that inverse in both themes), not --inverse-ink, which is
     tied to the always-dark safety/footer sections and would go invisible
     here in dark mode where --ink and --inverse-ink are both light. */
  color: var(--paper);
  border-radius: var(--radius-md);
  transform: translateY(-200%);
  transition: transform var(--duration-base) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.shell {
  width: min(1120px, 100% - 40px);
  margin-inline: auto;
}

/* Header ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-4) 0;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
}

.site-header::after {
  content: "";
  position: absolute;
  inset-inline: calc(50% - 50vw);
  bottom: 0;
  height: 1px;
  background: var(--line);
}

/* Nav links, the mobile hamburger, and the language selector are one
   grouped unit on the right of the header. */
.nav-cluster {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mobile-menu {
  display: none;
  position: relative;
}

@media (max-width: 560px) {
  .nav-cluster .nav {
    display: none;
  }
  .mobile-menu {
    display: block;
  }
}

.mobile-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}

.mobile-menu summary::-webkit-details-marker {
  display: none;
}

.mobile-menu summary svg {
  width: 20px;
  height: 20px;
}

.mobile-menu[open] summary {
  border-color: var(--ink);
}

/* The panel is a <nav>, and the earlier ".site-header nav { display: flex }"
   rule (meant for the desktop .nav links) matches it too via descendant
   selector - it wins over native <details> hiding whenever [open] isn't
   present, since that generic rule has no [open] condition to lose against.
   Force it closed explicitly rather than relying on the native default. */
.mobile-menu:not([open]) .mobile-menu-panel {
  display: none;
}
.mobile-menu[open] .mobile-menu-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  inset-inline-start: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 170px;
  padding: var(--space-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  z-index: 20;
}

.mobile-menu-panel a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--muted-strong);
  text-decoration: none;
}

.mobile-menu-panel a:hover,
.mobile-menu-panel a:focus-visible {
  background: var(--paper);
  color: var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  font-weight: 650;
  letter-spacing: var(--tracking-tight);
  font-size: var(--text-lg);
}

.brand-logo {
  display: block;
  border-radius: var(--radius-sm);
  flex: none;
}

.brand-logo-sm {
  border-radius: calc(var(--radius-sm) * 0.8);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--accent);
  font-weight: 700;
  font-size: var(--text-sm);
}

.brand-light {
  color: var(--inverse-ink);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
}

.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--muted-strong);
  transition: color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.site-header nav a.nav-app {
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.theme-toggle {
  position: fixed;
  right: var(--space-5);
  bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  z-index: 15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.theme-toggle:active {
  transform: scale(0.97);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

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

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

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

/* Hero -------------------------------------------------------------------- */

.hero {
  position: relative;
  padding: var(--space-8) 0 var(--space-7);
  text-align: center;
  overflow: hidden;
}

/* Decorative glow only - no effect on layout or content, safe to hide from AT. */
.hero::before {
  content: "";
  position: absolute;
  top: -140px;
  left: 50%;
  width: 760px;
  height: 480px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, color-mix(in srgb, #ffffff 16%, transparent), transparent 70%);
  filter: blur(50px);
  pointer-events: none;
  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero h1 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-3xl);
  font-weight: 680;
}

.hero h1 span {
  display: block;
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: normal;
}

.hero-copy {
  max-width: 56ch;
  margin-inline: auto;
  color: var(--muted-strong);
  font-size: var(--text-lg);
}

.hero-downloader {
  max-width: 640px;
  margin: var(--space-6) auto 0;
  padding: var(--space-5);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.hero-downloader .download-form {
  margin: 0;
}

.hero-downloader .results {
  padding: var(--space-5) 0 0;
}

/* Form -------------------------------------------------------------------- */

.download-form {
  display: flex;
  gap: var(--space-3);
  max-width: 720px;
  margin: var(--space-6) auto var(--space-4);
  flex-wrap: wrap;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 320px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.input-wrap:focus-within {
  border-color: var(--ink);
  box-shadow: var(--shadow-md);
}

.input-icon {
  display: inline-flex;
  padding-inline: var(--space-4) var(--space-1);
  color: var(--muted);
}

.input-icon svg {
  width: 17px;
  height: 17px;
}

#post-url {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: var(--space-3) var(--space-2);
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--text-base);
  text-overflow: ellipsis;
}

#post-url:focus {
  outline: none;
}

#post-url::placeholder {
  color: var(--muted);
}

.paste-button,
.resolve-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    opacity var(--duration-fast) var(--ease-out);
}

.paste-button {
  margin: var(--space-1) var(--space-1) var(--space-1) 0;
  padding: 0 var(--space-4);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-soft);
}

.resolve-button {
  flex: 0 0 auto;
  min-width: 210px;
  padding: 0 var(--space-6);
  border: 1px solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-md);
}

.resolve-button[disabled],
.paste-button[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.resolve-button[disabled]:active,
.paste-button[disabled]:active {
  transform: none;
}

.button-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.button-label svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--paper) 35%, transparent);
  border-top-color: var(--paper);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Status ------------------------------------------------------------------ */

.status {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  max-width: 720px;
  margin: 0 auto var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  text-align: left;
  overflow-wrap: anywhere;
}

.status[hidden] {
  display: none;
}

.status.error {
  border: 1px solid var(--danger-line);
  background: var(--danger-surface);
  color: var(--danger);
}

/* The glyph carries the same meaning as the color, so state is never color-only. */
.status.error::before {
  content: "!";
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--danger-surface);
  font-size: var(--text-xs);
  font-weight: 700;
}

.trust-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  color: var(--muted);
  font-size: var(--text-sm);
}

.trust-row span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.trust-row svg {
  width: 15px;
  height: 15px;
  flex: none;
}

/* Section furniture -------------------------------------------------------- */

.section-kicker {
  display: block;
  margin-bottom: var(--space-3);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.section-kicker.light {
  color: var(--inverse-muted);
}

.section-heading {
  margin-bottom: var(--space-6);
}

/* Cap the intro paragraph's measure, not the heading's - a short H2 like
   "What Can You Download?" has no reason to wrap early just because it
   shares a wrapper with body text. */
.section-heading p {
  max-width: 60ch;
  margin-top: var(--space-2);
}

.section-heading h2,
.results-header h2,
.safety h2,
.android h2 {
  font-size: var(--text-2xl);
  font-weight: 660;
}

/* Results ------------------------------------------------------------------ */

.results {
  padding: var(--space-6) 0 var(--space-7);
  scroll-margin-top: 88px;
}

.results[hidden] {
  display: none;
}

.results-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
}

.results-header > div {
  min-width: 0;
}

.results-header h2 {
  overflow-wrap: anywhere;
}

.results-header p {
  max-width: 62ch;
  margin-top: var(--space-3);
  color: var(--muted-strong);
}

.media-summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-sm);
}

.media-summary span {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted-strong);
}

.media-summary a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding-inline: var(--space-2);
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.quality-toggle {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.media-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.preview {
  position: relative;
  /* Reserved before media loads so cards never shift. */
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: #101010;
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-placeholder {
  padding: var(--space-4);
  color: #d4d4d0;
  font-size: var(--text-sm);
  text-align: center;
}

.media-type {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: rgba(10, 10, 10, 0.72);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
}

.media-type-symbol {
  font-size: var(--text-xs);
}

.media-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  min-width: 0;
}

.media-actions > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.media-actions b {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.media-actions span {
  color: var(--muted);
  font-size: var(--text-xs);
}

.download-button {
  flex: 0 0 auto;
  padding: 0 var(--space-4);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
}

/* Steps -------------------------------------------------------------------- */

.steps {
  padding: var(--space-8) 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 72px;
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}

.step-grid article {
  position: relative;
  padding: var(--space-6) var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.step-grid article::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, color-mix(in srgb, #ffffff 65%, transparent), transparent);
}

.step-number {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  color: var(--line-strong);
  font-size: var(--text-sm);
  font-weight: 700;
}

.step-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, #ffffff 12%, var(--paper));
  border: 1px solid color-mix(in srgb, #ffffff 28%, var(--line));
  color: var(--ink);
}

.step-icon svg,
.card-icon svg {
  width: 20px;
  height: 20px;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.step-grid h3 {
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
  font-weight: 640;
}

.step-grid p {
  color: var(--muted-strong);
  font-size: var(--text-sm);
}

/* Safety ------------------------------------------------------------------- */

.safety {
  padding: var(--space-8) 0;
  background: var(--inverse);
  color: var(--inverse-ink);
  scroll-margin-top: 72px;
}

.safety-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--space-7);
  align-items: start;
}

.safety p {
  max-width: 56ch;
  margin-top: var(--space-4);
  color: var(--inverse-muted);
}

.safety-list {
  display: grid;
  gap: var(--space-3);
}

.safety-list span {
  padding: var(--space-4);
  border: 1px solid var(--inverse-line);
  border-radius: var(--radius-md);
  background: var(--inverse-surface);
  color: var(--inverse-ink);
  font-size: var(--text-sm);
}

/* Android ------------------------------------------------------------------ */

.android {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: var(--space-7);
  align-items: center;
  padding: var(--space-8) 0;
  scroll-margin-top: 72px;
}

.phone-card {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.phone-top {
  width: 84px;
  height: 5px;
  margin: 0 auto var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--line-strong);
}

.mini-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 640;
  font-size: var(--text-sm);
}

.mini-brand span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 700;
}

.mini-copy {
  color: var(--muted);
  font-size: var(--text-xs);
}

.mini-input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.mini-button {
  display: grid;
  place-items: center;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--text-xs);
  font-weight: 600;
}

.mini-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.mini-result div {
  display: grid;
}

.mini-result b {
  font-size: var(--text-xs);
}

.mini-result span {
  color: var(--muted);
  font-size: 11px;
}

.mini-thumb {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1c1c1a, #4a4a45);
}

.android p {
  max-width: 56ch;
  margin-top: var(--space-4);
  color: var(--muted-strong);
}

.android-points {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-5);
  font-size: var(--text-sm);
}

.android-points span {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted-strong);
}

.later-note {
  display: block;
  margin-top: var(--space-4);
  color: var(--muted);
  font-size: var(--text-xs);
}

/* Final band - closing CTA above the footer -------------------------------- */

.final-band {
  margin-top: var(--space-6);
  padding: var(--space-8) var(--space-6);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  text-align: center;
}

.final-band h2 {
  font-size: var(--text-2xl);
  font-weight: 680;
}

.final-band p {
  max-width: 48ch;
  margin: var(--space-3) auto 0;
  color: var(--muted-strong);
}

.final-band-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  margin-top: var(--space-6);
  padding: 0 var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: var(--paper);
  font-weight: 650;
  box-shadow: var(--shadow-md);
  transition: background-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.final-band-cta svg {
  width: 18px;
  height: 18px;
}

@media (hover: hover) and (pointer: fine) {
  .final-band-cta:hover {
    background: var(--ink-soft);
  }
}

.final-band-cta:active {
  transform: scale(0.97);
}

/* Footer ------------------------------------------------------------------- */

footer {
  padding: var(--space-7) 0 var(--space-6);
  background: var(--inverse);
  color: var(--inverse-ink);
}

.footer-mega {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  gap: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--inverse-line);
}

@media (max-width: 860px) {
  .footer-mega {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* Brand takes its own full-width row so the 4 nav columns (Product,
     Resources, Languages, Legal) fill the 2-column grid evenly below it -
     otherwise brand's short tagline stretches to match a nav column's
     height, and the last column (Legal) is orphaned alone in its row. */
  .footer-brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .footer-mega {
    grid-template-columns: 1fr;
  }
}

.footer-brand p {
  max-width: 32ch;
  margin-top: var(--space-3);
  color: var(--inverse-muted);
  font-size: var(--text-sm);
}

.footer-col h3 {
  margin-bottom: var(--space-3);
  color: var(--inverse-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer-col a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--inverse-muted);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

.footer-col a:hover {
  color: var(--inverse-ink);
}

.disclaimer {
  max-width: 60ch;
  margin-top: var(--space-5);
  color: var(--inverse-muted);
  font-size: var(--text-xs);
}

/* Legal pages -------------------------------------------------------------- */

.legal-page {
  min-height: 100vh;
  background: var(--paper);
}

.legal-main {
  max-width: 820px;
  padding: var(--space-7) 0 var(--space-9);
}

.legal-main h1 {
  margin: var(--space-4) 0 var(--space-6);
  font-size: var(--text-3xl);
  font-weight: 680;
  text-align: left;
}

.legal-main h2 {
  margin: var(--space-7) 0 var(--space-3);
  font-size: var(--text-xl);
  font-weight: 640;
}

.legal-main p,
.legal-main li {
  color: var(--muted-strong);
  line-height: 1.75;
}

.legal-main p + p {
  margin-top: var(--space-3);
}

.legal-main ul {
  padding-left: var(--space-5);
}

.legal-main li + li {
  margin-top: var(--space-2);
}

.legal-note {
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* Interaction states ------------------------------------------------------- */

/* Pointer-down feedback lands immediately, on touch and mouse alike. */
.paste-button:active,
.resolve-button:active,
.download-button:active,
.site-header nav a:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .site-header nav a:hover {
    background: color-mix(in srgb, var(--ink) 6%, transparent);
    color: var(--ink);
  }

  .paste-button:hover:not([disabled]) {
    border-color: var(--ink);
    background: var(--surface);
  }

  .theme-toggle:hover {
    border-color: var(--ink);
  }

  .resolve-button:hover:not([disabled]),
  .download-button:hover {
    background: var(--ink-soft);
  }

  .footer-links a:hover {
    color: var(--inverse-ink);
  }

  .media-summary a:hover {
    color: var(--muted-strong);
  }
}

/* Responsive --------------------------------------------------------------- */

@media (max-width: 1023px) {
  .safety-inner,
  .android {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }

  .phone-card {
    max-width: 320px;
  }
}

@media (max-width: 767px) {
  .shell {
    width: min(1120px, 100% - 32px);
  }

  .hero {
    padding: var(--space-7) 0 var(--space-6);
  }

  .steps,
  .safety,
  .android {
    padding: var(--space-7) 0;
  }

  .results-header {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .site-header {
    padding: var(--space-3) 0;
  }

  .site-header nav {
    width: 100%;
    justify-content: space-between;
  }

  .resolve-button {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

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

  .media-actions {
    flex-wrap: wrap;
  }

  .download-button {
    width: 100%;
  }

  .trust-row {
    gap: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
  }
}

/* User preferences --------------------------------------------------------- */

@media (prefers-reduced-transparency: reduce) {
  .site-header {
    background: var(--paper);
    backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #c7c6c0;
    --muted-strong: #f5f4f1;
    --line: #5a5a54;
    --line-strong: #7a7a72;
    --inverse-muted: #d6d6d0;
  }

  :root[data-theme="light"] {
    --muted: #454541;
    --muted-strong: #1f1f1d;
    --line: #b9b8b2;
    --line-strong: #8f8e88;
    --inverse-muted: #d6d6d0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  .paste-button:active,
  .resolve-button:active,
  .download-button:active,
  .site-header nav a:active,
  .theme-toggle:active {
    transform: none;
  }

  .spinner {
    animation: none;
    border-top-color: transparent;
  }
}

/* FAQ */
.faq {
  padding-block: var(--space-9);
}

.faq-list {
  display: grid;
  gap: var(--space-3);
  max-width: 820px;
}

.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5);
  cursor: pointer;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.faq-item summary::after {
  content: "+";
  flex-shrink: 0;
  color: var(--muted);
  font-size: var(--text-xl);
  line-height: 1;
}

.faq-item[open] summary::after {
  content: "\2013";
}

.faq-item summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
  border-radius: var(--radius-lg);
}

.faq-item p {
  padding: 0 var(--space-5) var(--space-5);
  color: var(--muted-strong);
  max-width: 68ch;
}

/* Long-form SEO article */
.seo-article { padding: var(--space-7) 0 var(--space-8); }
.article-lede { max-width: 780px; margin: 0 auto; }
.article-header h1 {
  font-size: var(--text-3xl);
  font-weight: 680;
  margin-bottom: var(--space-4);
}
.article-intro p {
  color: var(--muted-strong);
  font-size: var(--text-lg);
  line-height: 1.7;
}
.article-intro p + p { margin-top: var(--space-4); }
.article-featured {
  position: relative;
  margin-top: var(--space-6);
}
.article-featured-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 675;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
/* The generated illustration always reserves its left third as empty space
   on a near-black background, regardless of site theme - so this title
   uses a fixed off-white, not a theme token, to stay legible in both. */
.article-featured-title {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 34%;
  display: flex;
  align-items: center;
  padding-inline-start: var(--space-6);
  color: #f5f4f1;
  font-size: var(--text-xl);
  font-weight: 680;
  line-height: 1.15;
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}
@media (max-width: 640px) {
  .article-featured-title {
    width: 55%;
    font-size: var(--text-base);
    padding-inline-start: var(--space-4);
  }
}
.prose-section {
  margin-top: var(--space-6);
  max-width: 72ch;
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.prose-section h2 {
  font-size: var(--text-2xl);
  font-weight: 640;
  margin-bottom: var(--space-4);
}
.prose-section p {
  color: var(--muted-strong);
  line-height: 1.75;
  font-size: var(--text-base);
}
.prose-section p + p { margin-top: var(--space-4); }

/* Contact page's Tally embed and the GetTerms cookies/acceptable-use embeds -
   fixed non-zero height so the page is usable before their JS resizes it. */
.contact-form-wrap {
  margin-top: var(--space-6);
}
.contact-form-wrap iframe {
  display: block;
  width: 100%;
  border: none;
  border-radius: var(--radius-lg);
}
.legal-embed-wrap {
  margin-top: var(--space-6);
  min-height: 600px;
}

/* The homepage's intro paragraph (build.mjs's introHtml) reads as
   free-flowing centered text, not a bordered card. */
.prose-intro {
  border: none;
  background: none;
  padding: 0;
  text-align: center;
}
.steps-list {
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-4);
  counter-reset: steps;
}
.steps-list li {
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  counter-increment: steps;
}
.steps-list li h3::before {
  content: counter(steps, decimal-leading-zero) ". ";
  color: var(--muted);
  font-weight: 700;
}
.steps-list li h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.steps-list li p { color: var(--muted-strong); font-size: var(--text-sm); }
.breadcrumbs {
  padding: var(--space-4) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-6);
}
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  padding: 0; margin: 0;
}
.breadcrumbs li + li::before {
  content: "/";
  margin-inline-end: var(--space-2);
  color: var(--muted);
}
.breadcrumbs a { color: var(--muted-strong); text-decoration: underline; text-underline-offset: 3px; }
.breadcrumbs li[aria-current="page"] span { color: var(--ink); font-weight: 600; }
.related-links {
  margin-top: var(--space-7);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.related-links h2 { font-size: var(--text-lg); margin-bottom: var(--space-3); }
.related-links ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.related-links a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: var(--text-sm); }
.article-downloader { margin: var(--space-6) 0 var(--space-7); }
.article-downloader .results { padding: var(--space-5) 0; }

/* Language selector */
.lang-selector {
  position: relative;
  font-size: var(--text-sm);
}
.lang-selector summary {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--tap); padding: 0 var(--space-3);
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  background: var(--surface); cursor: pointer; list-style: none;
}
.lang-selector summary::-webkit-details-marker { display: none; }
.lang-selector[open] summary { border-color: var(--ink); }
.lang-selector ul {
  position: absolute; top: calc(100% + var(--space-2)); inset-inline-end: 0;
  min-width: 200px; max-height: 320px; overflow-y: auto;
  padding: var(--space-2); margin: 0; list-style: none;
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  background: var(--surface); box-shadow: var(--shadow-md); z-index: 20;
}
.lang-selector li a {
  display: flex; align-items: center; min-height: 36px;
  padding: 0 var(--space-3); border-radius: var(--radius-sm);
  color: var(--muted-strong); text-decoration: none;
}
.lang-selector li a:hover, .lang-selector li a:focus-visible { background: var(--paper); color: var(--ink); }
.lang-selector li a[aria-current="page"] { font-weight: 700; color: var(--ink); background: var(--paper); }

/* RTL: logical properties already used above; specific tweaks */
[dir="rtl"] .site-header nav { flex-direction: row-reverse; }
[dir="rtl"] .breadcrumbs li + li::before { content: "/"; }
[dir="rtl"] .lang-selector ul { inset-inline-end: auto; inset-inline-start: 0; }


/* Homepage sections — what-you-can-download, why-use, device hub, Android
   badge, guides directory, latest guides. Shared grid/card treatment. */
.what-you-can-download, .why-use, .device-hub, .guides-directory, .latest-guides { padding: var(--space-6) 0; }
.wycd-grid, .benefit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-5); }
/* benefit-grid has 6 cards (divides evenly by 2 and 3); wycd-grid has 3
   (a 2-column state would always orphan the third card), so it jumps
   straight from 3 columns to 1 instead of passing through 2. */
@media (max-width: 860px) { .benefit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .wycd-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .benefit-grid { grid-template-columns: 1fr; } }
.wycd-card, .benefit-card, .device-card {
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.wycd-card h3, .benefit-card h3, .device-card h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.wycd-card p, .benefit-card p { color: var(--muted-strong); font-size: var(--text-sm); line-height: 1.6; }
.device-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
.device-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.device-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-5); }
@media (max-width: 720px) { .device-grid { grid-template-columns: 1fr; } }
.app-cta-inner { display:flex; align-items:center; justify-content:space-between; gap: var(--space-6); padding: var(--space-6); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); flex-wrap:wrap; }
.app-cta-inner h2 { font-size: var(--text-xl); }
.app-cta-inner p { color: var(--muted-strong); margin-top: var(--space-2); }
.badge-soon {
  flex: none;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--muted-strong);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}
.guide-cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-5); }
@media (max-width: 560px) { .guide-cat-grid { grid-template-columns: 1fr; } }
.guide-cat-link {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
.guide-cat-link:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.latest-guides-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-5); }
@media (max-width: 860px) { .latest-guides-grid { grid-template-columns: 1fr; } }
.guide-card {
  display: block;
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
.guide-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.guide-card h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.guide-card p { color: var(--muted-strong); font-size: var(--text-sm); line-height: 1.6; }
.ad-slot {
  min-height: 90px;
  margin: var(--space-6) 0;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}


/* Article body + right rail (TOC, then ad). Rail sits beside the main
   column on desktop and collapses above it on narrow viewports - see
   PROJECT_STATUS.md for the <details>-closed-by-default trap this avoids. */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: var(--space-6);
  align-items: start;
}
.article-main { min-width: 0; }
.article-rail { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.article-rail .ad-slot { margin: 0; }
@media (max-width: 979px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-rail { order: -1; }
}

/* TOC per brief 41 — sticky rail on desktop, collapsible above the article
   on narrow viewports, H2 only. Two <details> instances share the same list
   (see renderToc in build.mjs); only one is ever shown, toggled by display
   below, so exactly one open/closed default is visible per breakpoint. */
.toc-panel { margin: 0; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.toc-panel summary { font-weight: 700; cursor: pointer; }
.toc-panel ol { margin: var(--space-3) 0 0; padding-left: var(--space-5); }
.toc-panel li { margin-top: var(--space-2); }
.toc-panel a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: var(--text-sm); }
.toc-desktop { display: none; }
.toc-mobile { display: block; }
@media (min-width: 980px) {
  .article-rail {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 72px - var(--space-6));
    overflow-y: auto;
  }
  .toc-desktop { display: block; }
  .toc-mobile { display: none; }
}

/* Cross-language hint rendered under Related */
.also-in { margin-top: var(--space-6); font-size: var(--text-sm); color: var(--muted); }
.also-in a { color: var(--muted-strong); text-decoration: underline; text-underline-offset: 3px; }
.also-in-kicker { font-weight: 700; letter-spacing: var(--tracking-wide); text-transform: uppercase; font-size: var(--text-xs); margin-right: var(--space-2); }


