@charset "UTF-8";

/*
 * DystO — single stylesheet.
 *
 * Cascade layers keep specificity flat: nothing here needs !important, and a
 * component rule always wins over a base rule regardless of selector weight.
 * Themes are driven by data-theme on <html>, set server-side, so the correct
 * palette paints on the first frame with no flash and no JavaScript.
 */

@layer reset, tokens, base, layout, components, utilities;

/* ========================================================================
   RESET
   ======================================================================== */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body,
  h1, h2, h3, h4, p, figure, blockquote, dl, dd, ol, ul {
    margin: 0;
    padding: 0;
  }

  ol, ul {
    list-style: none;
  }

  img, svg, video {
    display: block;
    max-width: 100%;
    /*
     * Without this, an <img> carrying width/height attributes keeps its
     * declared pixel height while max-width squeezes its width — a 1200×800
     * thumbnail becomes a 176px-wide, 800px-tall sliver. It is the single
     * most common image bug in CSS and it is why every reset includes this
     * line.
     */
    height: auto;
  }

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

  button {
    background: none;
    border: 0;
    cursor: pointer;
  }

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

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
  }

  :focus:not(:focus-visible) {
    outline: none;
  }

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

/* ========================================================================
   TOKENS
   ======================================================================== */
@layer tokens {
  :root {
    /* Brand — unchanged from the original DystO identity. */
    --accent: #e74c3c;
    --accent-soft: color-mix(in oklab, var(--accent) 16%, transparent);
    --accent-strong: color-mix(in oklab, var(--accent) 82%, #000);

    /* Light palette (default) */
    --bg: #fbfbfc;
    --bg-deep: #f2f3f5;
    --bg-glow-a: color-mix(in oklab, var(--accent) 10%, transparent);
    --bg-glow-b: color-mix(in oklab, #6c8cff 10%, transparent);

    --surface: rgb(255 255 255 / 0.72);
    --surface-solid: #ffffff;
    --surface-hover: rgb(255 255 255 / 0.92);
    --border: rgb(15 18 25 / 0.10);
    --border-strong: rgb(15 18 25 / 0.18);

    --text: #14171c;
    --text-soft: #4a5058;
    --text-muted: #767d87;
    --link-visited: #7a4fb5;

    --shadow-sm: 0 1px 2px rgb(15 18 25 / 0.06);
    --shadow-md: 0 4px 16px -4px rgb(15 18 25 / 0.12);
    --shadow-lg: 0 18px 48px -18px rgb(15 18 25 / 0.28);

    /* Geometry */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    /*
     * Wide enough to use the screen, narrow enough that a line of text stays
     * readable. The results column keeps its own limit because prose past
     * ~45rem is measurably harder to scan — the extra width goes to the info
     * panel and the media strip, not to longer lines.
     */
    --content-width: 78rem;
    --result-width: 45rem;

    /* Type */
    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter,
      Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
      "Apple Color Emoji", "Segoe UI Emoji";
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
      "Liberation Mono", monospace;

    --blur: 14px;
    --ease: cubic-bezier(0.2, 0, 0, 1);

    color-scheme: light;
  }

  :root[data-theme="dark"] {
    --bg: #0c0d10;
    --bg-deep: #08090b;
    --bg-glow-a: color-mix(in oklab, var(--accent) 16%, transparent);
    --bg-glow-b: color-mix(in oklab, #4d6fff 14%, transparent);

    --surface: rgb(255 255 255 / 0.055);
    --surface-solid: #16181d;
    --surface-hover: rgb(255 255 255 / 0.09);
    --border: rgb(255 255 255 / 0.10);
    --border-strong: rgb(255 255 255 / 0.18);

    --text: #eceef2;
    --text-soft: #b3b9c4;
    --text-muted: #858d9a;
    --link-visited: #b79bff;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 18px -4px rgb(0 0 0 / 0.55);
    --shadow-lg: 0 20px 52px -20px rgb(0 0 0 / 0.8);

    color-scheme: dark;
  }

  /* "Auto" follows the operating system. */
  @media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] {
      --bg: #0c0d10;
      --bg-deep: #08090b;
      --bg-glow-a: color-mix(in oklab, var(--accent) 16%, transparent);
      --bg-glow-b: color-mix(in oklab, #4d6fff 14%, transparent);

      --surface: rgb(255 255 255 / 0.055);
      --surface-solid: #16181d;
      --surface-hover: rgb(255 255 255 / 0.09);
      --border: rgb(255 255 255 / 0.10);
      --border-strong: rgb(255 255 255 / 0.18);

      --text: #eceef2;
      --text-soft: #b3b9c4;
      --text-muted: #858d9a;
      --link-visited: #b79bff;

      --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
      --shadow-md: 0 4px 18px -4px rgb(0 0 0 / 0.55);
      --shadow-lg: 0 20px 52px -20px rgb(0 0 0 / 0.8);

      color-scheme: dark;
    }
  }
}

/* ========================================================================
   BASE
   ======================================================================== */
@layer base {
  html {
    font-family: var(--font-sans);
    font-size: 100%;
    line-height: 1.55;
    background-color: var(--bg);
    color: var(--text);
    scroll-behavior: smooth;
  }

  body {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    background-image:
      radial-gradient(60rem 40rem at 12% -12%, var(--bg-glow-a), transparent 60%),
      radial-gradient(50rem 36rem at 92% 6%, var(--bg-glow-b), transparent 62%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }

  a:where(:not([class])) {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.16em;
  }

  ::selection {
    background: var(--accent);
    color: #fff;
  }

  ::placeholder {
    color: var(--text-muted);
    opacity: 1;
  }

  code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.1em 0.35em;
    border-radius: var(--radius-xs);
    background: color-mix(in oklab, var(--text) 8%, transparent);
  }

  /* Firefox keeps the native clear button; hide the WebKit one for parity. */
  input[type="search"]::-webkit-search-cancel-button {
    appearance: none;
  }
}

/* ========================================================================
   LAYOUT
   ======================================================================== */
@layer layout {
  .dysto-main {
    flex: 1;
    width: 100%;
    max-width: var(--content-width);
    margin-inline: auto;
    padding: var(--space-5) var(--space-4) var(--space-7);
  }

  /* ---- Header ---------------------------------------------------------- */
  .dysto-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in oklab, var(--bg) 78%, transparent);
    backdrop-filter: blur(var(--blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
    border-bottom: 1px solid var(--border);
  }

  .header-inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--space-5);
    max-width: var(--content-width);
    margin-inline: auto;
    padding: var(--space-3) var(--space-4);
  }

  /* The field should not stretch to the full header on a very wide screen. */
  .header-search .search-form {
    max-width: 46rem;
  }

  .header-brand {
    padding-block-start: 0.35rem;
  }

  .header-search {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
  }

  .header-controls {
    display: flex;
    justify-content: flex-end;
    padding-block-start: 0.2rem;
  }

  /* Static pages need the header for navigation, not for the tab row. */
  .dysto-header--slim .header-inner {
    padding-block: var(--space-2);
  }

  /* ---- Home ------------------------------------------------------------ */
  /*
   * Home page proportions follow the convention every search engine settled
   * on: the wordmark sits roughly a quarter of the way down, the field
   * directly beneath it, and nothing else competes for attention. The point
   * is that the cursor lands in the right place without the eye having to
   * look for it.
   */
  .home {
    display: grid;
    place-items: start center;
    padding-block: clamp(4rem, 22vh, 12rem) var(--space-7);
  }

  .home-inner {
    width: 100%;
    max-width: 40rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
    text-align: center;
  }

  .home-controls {
    display: flex;
    justify-content: flex-end;
    padding: var(--space-4) var(--space-4) 0;
  }

  .home-note {
    color: var(--text-muted);
    font-size: 0.75rem;
  }

  /* ---- Web results: list + optional aside ------------------------------ */
  /*
   * `minmax(0, 1fr)`, not `1fr`.
   *
   * A grid track defaults to a minimum of `auto`, which means "at least as
   * wide as my content" — so a single long word, a URL or an unbreakable
   * string pushes the track past the container and the whole page scrolls
   * sideways. On a phone that is the difference between a readable panel and
   * one hanging off the edge of the screen.
   */
  .layout-web {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    min-width: 0;
  }

  .layout-web > * {
    min-width: 0;
  }

  /*
   * Stacked on a narrow screen, the panel sits last in the DOM and therefore
   * at the very bottom of the page — below every result, where nobody will
   * ever see it. It is the answer to the question, so on mobile it goes first;
   * on desktop `order` returns to normal and it takes the right-hand column.
   */
  .layout-aside {
    order: -1;
    min-width: 0;
  }

  @media (min-width: 62rem) {
    .layout-web--aside {
      grid-template-columns: minmax(0, var(--result-width)) minmax(18rem, 26rem);
      align-items: start;
      gap: var(--space-7);
    }

    .layout-aside {
      order: 0;
      position: sticky;
      top: 9rem;
    }
  }
}

/* ========================================================================
   COMPONENTS
   ======================================================================== */
@layer components {

  /* ---- Surfaces & buttons ---------------------------------------------- */
  .surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(var(--blur)) saturate(150%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
    box-shadow: var(--shadow-sm);
  }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
      transform 0.18s var(--ease);
  }

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

  .btn:active {
    transform: translateY(1px);
  }

  .btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .btn--primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
  }

  .btn--magnet {
    border-color: color-mix(in oklab, var(--accent) 45%, var(--border-strong));
    color: var(--accent);
  }

  .badge {
    display: inline-flex;
    align-items: center;
    padding: 0.08rem 0.5rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--text) 5%, transparent);
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  /* Consensus indicator — the one thing DystO shows that no single engine can. */
  .consensus {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.08rem 0.5rem;
    border-radius: var(--radius-pill);
    border: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.6875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: help;
  }

  .consensus-dots {
    letter-spacing: -0.12em;
    font-size: 0.55rem;
    line-height: 1;
  }

  .badge--source {
    border-color: color-mix(in oklab, var(--text) 14%, transparent);
    text-transform: none;
    font-weight: 500;
    letter-spacing: 0;
  }

  .status-consensus {
    padding: 0.05rem 0.5rem;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
  }

  .badge--frontend {
    border-color: color-mix(in oklab, var(--accent) 40%, transparent);
    color: var(--accent);
  }

  /* ---- Brand ----------------------------------------------------------- */
  .brand {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    line-height: 1.1;
  }

  .brand-word {
    display: inline-block;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: var(--text);
    transition: opacity 0.18s var(--ease);
  }

  .brand-word:hover {
    opacity: 0.78;
  }

  .brand-accent {
    color: var(--accent);
  }

  .brand-tagline {
    font-size: 0.6875rem;
    color: var(--text-muted);
    letter-spacing: 0.01em;
  }

  .brand--hero {
    align-items: center;
    gap: var(--space-3);
  }

  .brand--hero .brand-word {
    font-size: clamp(3.5rem, 11vw, 6.5rem);
    letter-spacing: -0.055em;
    line-height: 0.95;
    /* A very soft glow keeps the wordmark from looking flat on the glass. */
    text-shadow: 0 8px 40px color-mix(in oklab, var(--accent) 22%, transparent);
  }

  .brand--hero .brand-tagline {
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    font-weight: 500;
    color: var(--text-muted);
    max-width: 34rem;
    text-wrap: balance;
  }

  /* ---- Search form ----------------------------------------------------- */
  .search-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: 100%;
  }

  .search-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.3rem 0.3rem 0.3rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface-solid);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  }

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

  .home .search-form {
    gap: var(--space-4);
  }

  .home .search-bar {
    padding-block: 0.45rem;
    font-size: 1.0625rem;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-md);
  }

  .home .search-bar:hover {
    box-shadow: var(--shadow-lg);
  }

  .search-input {
    flex: 1;
    min-width: 0;
    padding: 0.55rem 0;
    border: 0;
    background: transparent;
    font-size: inherit;
  }

  .search-input:focus {
    outline: none;
  }

  .search-submit {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: background 0.18s var(--ease), transform 0.18s var(--ease);
  }

  .search-submit:hover {
    background: var(--accent-strong);
  }

  .search-submit:active {
    transform: translateY(1px);
  }

  .search-submit-icon {
    font-size: 1.15em;
    line-height: 1;
  }

  .search-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
  }

  .search-form--compact .search-options {
    justify-content: flex-start;
  }

  .field {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }

  .field-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .field-select {
    appearance: none;
    padding: 0.3rem 1.75rem 0.3rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: right 0.85rem center, right 0.6rem center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    color: var(--text-soft);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
  }

  .field-select:hover {
    border-color: var(--accent);
    color: var(--text);
  }

  .field-select option {
    /* Native popups do not inherit the glass; force a readable pair. */
    background: var(--surface-solid);
    color: var(--text);
  }

  .field-select--ghost {
    max-width: 9rem;
    border-color: transparent;
    background-color: transparent;
  }

  /* ---- Tabs ------------------------------------------------------------ */
  .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    padding: 0.2rem;
    border-radius: var(--radius-pill);
    background: color-mix(in oklab, var(--text) 5%, transparent);
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .home .tabs {
    margin-inline: auto;
  }

  .tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.18s var(--ease), color 0.18s var(--ease);
  }

  .tab:hover {
    color: var(--text);
    background: var(--surface-hover);
  }

  .tab.is-active {
    background: var(--surface-solid);
    color: var(--accent);
    font-weight: 650;
    box-shadow: var(--shadow-sm);
  }

  .tab-icon {
    font-size: 0.9em;
    opacity: 0.85;
  }

  .tab-label {
    /* Kept as a hook so very narrow viewports can fall back to icons only. */
    display: inline;
  }

  @media (max-width: 24rem) {
    .tab-label {
      display: none;
    }

    .tab {
      padding-inline: 0.7rem;
    }
  }

  /* ---- Controls (theme / language / erase) ----------------------------- */
  .controls {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .control-group {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.15rem;
    border-radius: var(--radius-pill);
    background: color-mix(in oklab, var(--text) 5%, transparent);
  }

  .control-btn {
    display: inline-grid;
    place-items: center;
    inline-size: 1.9rem;
    block-size: 1.9rem;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1;
    transition: background 0.18s var(--ease), color 0.18s var(--ease);
  }

  .control-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
  }

  .control-btn.is-active {
    background: var(--surface-solid);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
  }

  .control-btn--danger:hover {
    color: var(--accent);
  }

  .control-btn--apply {
    font-size: 0.8rem;
  }

  /* ---- Status line ------------------------------------------------------ */
  .result-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin-block-end: var(--space-5);
    padding-block-end: var(--space-3);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
  }

  .status-sources {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-time {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /*
   * Flex `gap` separates these visually but produces nothing when the line is
   * copied, so a status line pasted into a bug report reads
   * "Merged from Google, Openversein 1.13 s". A real character fixes that and
   * costs one glyph.
   */
  .status-sep {
    opacity: 0.4;
  }

  .status-failures {
    display: inline-flex;
    gap: 0.35rem;
    margin-inline-start: auto;
  }

  .status-chip {
    padding: 0.05rem 0.5rem;
    border-radius: var(--radius-pill);
    border: 1px dashed color-mix(in oklab, var(--accent) 45%, var(--border));
    color: color-mix(in oklab, var(--accent) 78%, var(--text-muted));
    font-size: 0.6875rem;
  }

  .correction {
    margin-block-end: var(--space-4);
    font-size: 0.9375rem;
    color: var(--text-soft);
  }

  .correction a {
    color: var(--accent);
    font-weight: 600;
    font-style: italic;
  }

  /* ---- Web results ------------------------------------------------------ */
  .result-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    max-width: var(--result-width);
  }

  .layout-web--aside .result-list {
    max-width: none;
  }

  /*
   * Two columns of results once there is genuinely room for them and no info
   * panel taking the right-hand side. Below that width a single column reads
   * better, and with a panel present the space is already spoken for.
   */
  @media (min-width: 82rem) {
    .layout-web:not(.layout-web--aside) .result-list {
      max-width: none;
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--space-5) var(--space-7);
      align-content: start;
    }
  }

  .result {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
  }

  .result-url {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
  }

  .result-host {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
  }

  .result-title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
  }

  .result-title a {
    color: var(--accent);
    text-decoration-color: transparent;
    text-decoration-line: underline;
    text-underline-offset: 0.14em;
    transition: text-decoration-color 0.18s var(--ease);
  }

  .result-title a:hover {
    text-decoration-color: currentColor;
  }

  .result-title a:visited {
    color: color-mix(in oklab, var(--accent) 55%, var(--link-visited));
  }

  .result-snippet {
    color: var(--text-soft);
    font-size: 0.875rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
  }

  .result-date {
    color: var(--text-muted);
  }

  .result-date::after {
    content: " — ";
  }

  .result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-block-start: 0.2rem;
  }

  .result--onion .result-host {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
  }

  /* ---- Info box --------------------------------------------------------- */
  .infobox {
    overflow: hidden;
    min-width: 0;
  }

  .infobox-text,
  .infobox-heading,
  .infobox-facts dd {
    overflow-wrap: anywhere;
  }

  /*
   * An explicit height, not a computed one.
   *
   * Two earlier attempts failed here, both for the same reason: anything that
   * leaves the height to be derived — from the source's own proportions, from
   * a declared ratio, from a max-height — can end up deriving zero. A
   * MediaWiki thumbnail can be a wide banner or a tall portrait, and the
   * column it sits in changes width with the layout.
   *
   * A stated height cannot collapse. object-fit does the rest.
   */
  .infobox-image {
    display: block;
    inline-size: 100%;
    block-size: 11rem;
    object-fit: cover;
    object-position: center top;
    background: color-mix(in oklab, var(--text) 6%, transparent);
    border-bottom: 1px solid var(--border);
  }

  @media (min-width: 62rem) {
    .infobox-image {
      block-size: 13rem;
    }
  }

  .infobox-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
  }

  .infobox-heading {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .infobox-heading--big {
    font-size: clamp(1.5rem, 5vw, 2.25rem);
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
  }

  .infobox-expression {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
  }

  .infobox-text {
    color: var(--text-soft);
    font-size: 0.875rem;
    line-height: 1.6;
  }

  .infobox-facts {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem;
    font-size: 0.8125rem;
  }

  .infobox-facts dt {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: capitalize;
  }

  .infobox-facts dd {
    color: var(--text-soft);
  }

  .infobox-source {
    padding-block-start: var(--space-2);
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
  }

  .infobox-source a {
    color: var(--accent);
    overflow-wrap: anywhere;
  }

  /* ---- Media strip (above the web results) ------------------------------ */
  /*
   * Images and videos share one row on wide screens and stack on narrow ones.
   * The images block is given more room than the videos block because four
   * square tiles need it and two 16:9 cards do not.
   */
  .media-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
    margin-block-end: var(--space-6);
    padding-block-end: var(--space-5);
    border-bottom: 1px solid var(--border);
  }

  .media-strip > * {
    min-width: 0;
  }

  @media (min-width: 56rem) {
    .media-strip {
      grid-template-columns: 1.5fr 1fr;
      align-items: start;
      gap: var(--space-6);
    }
  }

  .strip-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block-end: var(--space-3);
  }

  .strip-title {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    color: var(--text-soft);
  }

  .strip-icon {
    color: var(--accent);
    font-size: 0.9em;
  }

  .strip-more {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color 0.18s var(--ease);
  }

  .strip-more:hover {
    color: var(--accent);
  }

  /* -- images -- */
  .strip-images {
    display: grid;
    /*
     * As many tiles as the width allows rather than a fixed four: on a wide
     * screen the strip was leaving half its row empty, which is the same
     * wasted space the results column had.
     */
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: var(--space-2);
  }

  .strip-image {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--text) 6%, transparent);
    transition: transform 0.2s var(--ease), border-color 0.2s var(--ease),
      box-shadow 0.2s var(--ease);
  }

  .strip-image:hover,
  .strip-image:focus-within {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
  }

  .strip-image a {
    display: block;
    block-size: 100%;
  }

  .strip-image img {
    inline-size: 100%;
    block-size: 100%;
    min-block-size: 100%;
    object-fit: cover;
  }

  .strip-image-caption {
    position: absolute;
    inset-inline: 0;
    inset-block-end: 0;
    padding: 1.4rem 0.5rem 0.4rem;
    background: linear-gradient(to top, rgb(0 0 0 / 0.85), transparent);
    color: #fff;
    font-size: 0.6875rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s var(--ease);
  }

  .strip-image:hover .strip-image-caption,
  .strip-image:focus-within .strip-image-caption {
    opacity: 1;
  }

  /* -- videos -- */
  .strip-videos {
    display: grid;
    gap: var(--space-2);
  }

  .strip-video {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--surface);
    transition: transform 0.2s var(--ease), border-color 0.2s var(--ease),
      box-shadow 0.2s var(--ease);
  }

  .strip-video:hover,
  .strip-video:focus-within {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
  }

  .strip-video a {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    min-width: 0;
    align-items: stretch;
  }

  .strip-video-thumb {
    position: relative;
    display: block;
    background: color-mix(in oklab, var(--text) 8%, transparent);
  }

  .strip-video-thumb img {
    inline-size: 100%;
    block-size: 100%;
    min-block-size: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
  }

  .strip-video-duration {
    position: absolute;
    inset-block-end: 0.3rem;
    inset-inline-end: 0.3rem;
    padding: 0.02rem 0.35rem;
    border-radius: var(--radius-xs);
    background: rgb(0 0 0 / 0.8);
    color: #fff;
    font-size: 0.625rem;
    font-variant-numeric: tabular-nums;
  }

  .strip-video-play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    color: #fff;
    background: rgb(0 0 0 / 0.2);
    text-shadow: 0 2px 10px rgb(0 0 0 / 0.7);
    opacity: 0;
    transition: opacity 0.2s var(--ease);
  }

  .strip-video:hover .strip-video-play {
    opacity: 1;
  }

  .strip-video-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    padding: var(--space-2) var(--space-3);
    min-width: 0;
  }

  .strip-video-title {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .strip-video:hover .strip-video-title {
    color: var(--accent);
  }

  .strip-video-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-muted);
    font-size: 0.6875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ---- Image grid ------------------------------------------------------- */
  .grid-note {
    margin-block-end: var(--space-4);
    color: var(--text-muted);
    font-size: 0.75rem;
  }

  /*
   * Masonry, via CSS columns.
   *
   * Image results have wildly different shapes — a panorama next to a portrait
   * next to a square. In a CSS grid every row is as tall as its tallest cell,
   * so variable ratios produce ragged rows separated by large empty gaps.
   * Columns instead let each image keep its own height and stack tightly, which
   * is both what image search should look like and what removes the gaps.
   *
   * The trade-off is reading order: columns fill top-to-bottom before moving
   * right, so results read down each column rather than across. For a picture
   * grid that is the accepted convention and nobody reads it linearly anyway.
   */
  .image-grid {
    columns: 5 12rem;
    column-gap: var(--space-3);
  }

  @media (min-width: 90rem) {
    .image-grid {
      columns: 6 12rem;
    }
  }

  .image-cell {
    position: relative;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    margin-block-end: var(--space-3);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: color-mix(in oklab, var(--text) 6%, transparent);
    border: 1px solid var(--border);
    transition: transform 0.2s var(--ease), border-color 0.2s var(--ease),
      box-shadow 0.2s var(--ease);
  }

  .image-cell:hover,
  .image-cell:focus-within {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
  }

  .image-link {
    display: block;
    block-size: 100%;
  }

  .image-thumb {
    inline-size: 100%;
    block-size: auto;
    /*
     * A minimum ratio, not a fixed one: the image keeps its natural shape, and
     * only genuinely extreme slivers — banners, sprite sheets — are cropped to
     * something a column can hold.
     */
    max-block-size: 32rem;
    object-fit: cover;
    background: color-mix(in oklab, var(--text) 8%, transparent);
  }

  .image-caption {
    position: absolute;
    inset-inline: 0;
    inset-block-end: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 1.6rem 0.6rem 0.5rem;
    background: linear-gradient(to top, rgb(0 0 0 / 0.82), transparent);
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s var(--ease);
  }

  .image-cell:hover .image-caption,
  .image-cell:focus-within .image-caption {
    opacity: 1;
  }

  .image-title {
    font-size: 0.75rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .image-dims {
    font-size: 0.6875rem;
    opacity: 0.75;
    font-variant-numeric: tabular-nums;
  }

  .image-original {
    position: absolute;
    inset-block-start: 0.4rem;
    inset-inline-end: 0.4rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
    background: rgb(0 0 0 / 0.6);
    color: #fff;
    font-size: 0.6875rem;
    opacity: 0;
    transition: opacity 0.2s var(--ease);
  }

  .image-cell:hover .image-original,
  .image-original:focus-visible {
    opacity: 1;
  }

  /* ---- Video grid ------------------------------------------------------- */
  .video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
    gap: var(--space-4) var(--space-5);
  }

  .video-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s var(--ease), border-color 0.2s var(--ease),
      box-shadow 0.2s var(--ease);
  }

  .video-card:hover,
  .video-card:focus-within {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
  }

  .video-thumb-link {
    position: relative;
    display: block;
    background: color-mix(in oklab, var(--text) 8%, transparent);
  }

  .video-thumb {
    inline-size: 100%;
    block-size: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
  }

  .video-duration {
    position: absolute;
    inset-block-end: 0.4rem;
    inset-inline-end: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: var(--radius-xs);
    background: rgb(0 0 0 / 0.78);
    color: #fff;
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
  }

  .video-play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.75rem;
    color: #fff;
    background: rgb(0 0 0 / 0.18);
    opacity: 0;
    transition: opacity 0.2s var(--ease);
    text-shadow: 0 2px 12px rgb(0 0 0 / 0.6);
  }

  .video-card:hover .video-play {
    opacity: 1;
  }

  .video-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: var(--space-3) var(--space-4) var(--space-4);
  }

  .video-title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .video-title a:hover {
    color: var(--accent);
  }

  .video-desc {
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .video-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    color: var(--text-muted);
    font-size: 0.6875rem;
  }

  /* ---- Pagination ------------------------------------------------------- */
  .pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-block-start: var(--space-7);
  }

  .page-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 0.875rem;
    transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
  }

  .page-link:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  .page-numbers {
    display: inline-flex;
    gap: 0.15rem;
  }

  .page-number {
    display: inline-grid;
    place-items: center;
    inline-size: 2rem;
    block-size: 2rem;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    transition: background 0.18s var(--ease), color 0.18s var(--ease);
  }

  .page-number:hover {
    background: var(--surface-hover);
    color: var(--text);
  }

  .page-number.is-active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
  }

  .standalone-infobox {
    max-width: 34rem;
    margin-block-end: var(--space-5);
  }

  /* ---- Empty / notices --------------------------------------------------- */
  .empty {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: center;
    text-align: center;
    padding: var(--space-7) var(--space-5);
  }

  .empty-title {
    font-size: 1.0625rem;
    font-weight: 600;
  }

  .empty-note {
    max-width: 34rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-wrap: pretty;
  }

  .notice {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-4);
    margin-block-end: var(--space-5);
    color: var(--text-soft);
    font-size: 0.875rem;
    line-height: 1.6;
  }

  /* ---- Prose (about / help / privacy) ------------------------------------ */
  .prose {
    max-width: 48rem;
    margin-inline: auto;
    padding: var(--space-6);
    color: var(--text-soft);
    font-size: 0.9375rem;
    line-height: 1.7;
  }

  .prose > * + * {
    margin-block-start: var(--space-4);
  }

  .prose h1 {
    color: var(--text);
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .prose h2 {
    color: var(--text);
    font-size: 1.0625rem;
    font-weight: 650;
    margin-block-start: var(--space-6);
  }

  .prose a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.16em;
  }

  /* ---- Error page --------------------------------------------------------- */
  .error-page {
    display: grid;
    place-items: center;
  }

  .error-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    text-align: center;
    padding-block: var(--space-7);
  }

  .error-heading {
    font-size: clamp(3rem, 12vw, 5rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--accent);
    line-height: 1;
  }

  .error-message {
    color: var(--text-muted);
  }

  /* ---- Footer -------------------------------------------------------------- */
  .dysto-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    background: color-mix(in oklab, var(--bg-deep) 70%, transparent);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    color: var(--text-muted);
    font-size: 0.75rem;
  }

  .footer-cell {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
  }

  .footer-cell--center {
    justify-content: center;
  }

  .footer-cell--end {
    justify-content: flex-end;
    text-align: end;
  }

  .footer-icon {
    display: inline-grid;
    place-items: center;
    color: var(--text-muted);
    transition: color 0.18s var(--ease);
  }

  .footer-icon:hover {
    color: var(--accent);
  }

  .footer-link {
    color: var(--text-muted);
    transition: color 0.18s var(--ease);
  }

  .footer-link:hover {
    color: var(--accent);
  }

  .footer-dot {
    opacity: 0.45;
  }

  .footer-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (max-width: 40rem) {
    .footer-text {
      white-space: normal;
    }
  }
}

/* ========================================================================
   UTILITIES
   ======================================================================== */
@layer utilities {
  .visually-hidden {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: absolute;
    inset-block-start: -3rem;
    inset-inline-start: var(--space-4);
    z-index: 50;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    transition: inset-block-start 0.18s var(--ease);
  }

  .skip-link:focus {
    inset-block-start: var(--space-2);
  }
}

/* ========================================================================
   RESPONSIVE
   ======================================================================== */
@media (max-width: 60rem) {
  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand controls"
      "search search";
    gap: var(--space-3);
  }

  .header-brand { grid-area: brand; }
  .header-controls { grid-area: controls; }
  .header-search { grid-area: search; }

}

@media (max-width: 40rem) {
  .dysto-main {
    padding-inline: var(--space-3);
  }

  .brand-tagline {
    display: none;
  }

  .home .brand-tagline {
    display: block;
  }

  .search-submit-label {
    display: none;
  }

  .search-submit {
    padding-inline: 0.85rem;
  }

  .search-options {
    gap: var(--space-2);
  }

  .field-label {
    display: none;
  }

  .image-grid {
    columns: 2 8rem;
  }

  /*
   * On a phone, four tiles in a row would be thumbnails of nothing. Scroll
   * them instead, which also keeps the strip from pushing the text results
   * off the first screen.
   */
  .strip-images {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding-block-end: 0.15rem;
  }

  .strip-images::-webkit-scrollbar {
    display: none;
  }

  .strip-image {
    flex: 0 0 42%;
    scroll-snap-align: start;
  }

  .strip-video a {
    grid-template-columns: 7rem minmax(0, 1fr);
  }

  .media-strip {
    gap: var(--space-5);
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  .dysto-footer {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: var(--space-3);
  }

  .footer-cell--end,
  .footer-cell--center {
    justify-content: center;
    text-align: center;
  }

  .status-failures {
    margin-inline-start: 0;
  }
}

/* Touch devices have no hover: reveal captions and actions permanently. */
@media (hover: none) {
  .image-caption,
  .image-original,
  .video-play,
  .strip-image-caption {
    opacity: 1;
  }

  .video-play {
    opacity: 0.85;
  }
}

@media print {
  .dysto-header,
  .dysto-footer,
  .controls,
  .tabs,
  .pagination,
  .media-strip {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
