    /* ──────────────────────────────────────────────────────────────────────
       Theme — tweak these to restyle the demo
       ────────────────────────────────────────────────────────────────────── */
    :root {
      --bg-start: #0b1020;
      --bg-mid:   #1e1b4b;
      --bg-end:   #581c87;
      --panel:        rgba(255, 255, 255, 0.05);
      --panel-border: rgba(255, 255, 255, 0.10);
      --text:    #f1f5f9;
      --muted:   #94a3b8;
      --accent:       #818cf8;
      --accent-hover: #a5b4fc;
      --accent-2:     #ec4899;
      --field-bg:     rgba(15, 23, 42, 0.6);
      --field-border: rgba(255, 255, 255, 0.12);
      --shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6);
      --radius: 18px;

      /* Mobile breakpoint — below this width the layout stacks */
      --stack-breakpoint: 880px;
    }

    * { box-sizing: border-box; }
    html, body { margin: 0; padding: 0; }

    body {
      min-height: 100vh;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      color: var(--text);
      background:
        radial-gradient(ellipse at top left,     rgba(99, 102, 241, 0.25), transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(168, 85, 247, 0.25), transparent 50%),
        linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
      background-attachment: fixed;
      padding: 24px;
    }

    .container { max-width: 1400px; margin: 0 auto; }

    /* ── Header ──────────────────────────────────────────────────────────── */
    .header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 24px;
      gap: 16px;
      flex-wrap: wrap;
    }
    .brand { display: flex; align-items: center; gap: clamp(40px, 10vw, 140px); }
    .brand-logo {
      height: 40px;
      width: auto;
      display: block;
      /* The PNG is white-on-transparent; a soft glow lifts it off the bg */
      filter: drop-shadow(0 6px 20px rgba(129, 140, 248, 0.35));
    }
    h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; }
    .subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }

    /* ── Demo tabs ───────────────────────────────────────────────────────── */
    .tabs {
      display: flex;
      gap: 6px;
      margin-bottom: 24px;
      padding: 6px;
      background: var(--panel);
      border: 1px solid var(--panel-border);
      border-radius: 14px;
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      overflow-x: auto;
    }
    .tab {
      padding: 10px 18px;
      border-radius: 10px;
      color: var(--muted);
      text-decoration: none;
      font-size: 0.9rem;
      font-weight: 500;
      white-space: nowrap;
      transition: color 0.15s, background 0.15s;
    }
    .tab:hover:not(.active) { color: var(--text); background: rgba(255, 255, 255, 0.04); }
    .tab.active {
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      color: white;
      box-shadow: 0 6px 16px rgba(129, 140, 248, 0.35);
    }

    /* Narrow-screen demo picker — replaces the pill tabs (markup in tabs.php).
       Hidden by default; the media query below swaps the two. */
    .tabs-select {
      display: none;
      width: 100%;
      margin-bottom: 24px;
      padding: 13px 44px 13px 16px;
      background-color: var(--panel);
      color: var(--text);
      border: 1px solid var(--panel-border);
      border-radius: 14px;
      font-family: inherit;
      font-size: 0.95rem;
      font-weight: 600;
      cursor: pointer;
      -webkit-appearance: none;
      appearance: none;
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      /* custom chevron (accent-coloured) */
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a5b4fc' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 15px center;
      background-size: 16px;
    }
    /* Native option list renders on a light system background — keep it dark. */
    .tabs-select option { color: #0b1020; }

    /* ── Very narrow / phone: restack header + switch tabs to the dropdown ── */
    @media (max-width: 600px) {
      /* Row 1: logo (left) + actions (right). Row 2: title + subtitle. */
      .header {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-areas:
          "logo actions"
          "text text";
        align-items: center;
        column-gap: 12px;
        row-gap: 14px;
      }
      .brand { display: contents; }   /* lift logo + text into the header grid */
      .brand-logo     { grid-area: logo; }
      .brand-text     { grid-area: text; }
      .header-actions { grid-area: actions; justify-self: end; }

      /* Tabs → tap-to-pick dropdown (no horizontal scrolling). */
      .tabs        { display: none; }
      .tabs-select { display: block; }
    }

    /* ──────────────────────────────────────────────────────────────────────
       Layout — desktop: dropdowns left (380px) | video right (1fr).
       Mobile / narrow (< --stack-breakpoint): single column, VIDEO ALWAYS ON
       TOP so the player is the first thing you see; the options sit beneath it
       and you scroll down to reach them. Applies to both 16:9 and 9:16 demos.
       ────────────────────────────────────────────────────────────────────── */
    .layout {
      display: grid;
      grid-template-columns: 380px 1fr;
      gap: 24px;
      align-items: start;
    }
    @media (max-width: 880px) {
      .layout { grid-template-columns: 1fr; }
      .layout .panel.video    { order: 1; }
      .layout .panel.controls { order: 2; }
      /* Copy URL + player console, relocated here by demo-core.js, sit last. */
      .layout .console-panel.active {
        order: 3;
        display: flex;
        flex-direction: column;
        gap: 14px;
      }
      /* Standalone single-demo build: drop the Copy URL + console on mobile. */
      body.standalone .layout .console-panel.active { display: none; }
    }
    /* Desktop: this panel is empty (its content lives in the video panel). */
    .console-panel { display: none; }

    .panel {
      background: var(--panel);
      border: 1px solid var(--panel-border);
      border-radius: var(--radius);
      padding: 24px;
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      box-shadow: var(--shadow);
      /* Grid items default to min-width:auto, so a wide non-wrapping child (the
         event console logging long player URLs) would force the whole column —
         and the page — wider than a phone viewport. Allow panels to shrink. */
      min-width: 0;
    }
    .panel-title {
      margin: 0 0 4px;
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.14em;
      color: var(--accent);
      font-weight: 700;
    }
    .panel-desc {
      margin: 0 0 20px;
      font-size: 0.85rem;
      color: var(--muted);
      line-height: 1.55;
    }

    /* ── Dropdown field ──────────────────────────────────────────────────── */
    .field { margin-bottom: 14px; }
    /* Group header between sets of dropdowns in the Personalisation panel.
       Driven by `group:` on each DATASOURCE_FIELDS entry. */
    .field-group-title {
      font-size: 0.68rem;
      text-transform: uppercase;
      letter-spacing: 0.10em;
      color: var(--accent);
      font-weight: 700;
      margin: 18px 0 6px;
      padding-top: 14px;
      border-top: 1px solid rgba(255, 255, 255, 0.10);
    }
    /* Collapsible region — used for per-destination "Configure more" and
       for entirely-collapsed groups (Voice-overs). Open state is toggled
       by JS adding/removing `.open` on the wrapper. */
    .field-collapsible           { margin-top: 4px; }
    .field-collapsible-toggle {
      background: none;
      border: 0;
      color: var(--muted);
      font-family: inherit;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      padding: 6px 0;
      display: flex; align-items: center; gap: 6px;
      width: 100%; text-align: left;
      transition: color 0.15s;
    }
    .field-collapsible-toggle:hover { color: var(--text); }
    .field-collapsible-toggle::before {
      content: "▸";
      font-size: 0.7rem;
      transition: transform 0.2s;
      display: inline-block;
      width: 10px;
    }
    .field-collapsible.open > .field-collapsible-toggle::before {
      transform: rotate(90deg);
    }
    .field-collapsible-body { display: none; padding-top: 8px; }
    .field-collapsible.open > .field-collapsible-body { display: block; }
    /* When the whole group is the collapsible (e.g. Voice-overs), the
       toggle styles itself like the regular group title. */
    .field-collapsible.is-group > .field-collapsible-toggle {
      font-size: 0.68rem;
      text-transform: uppercase;
      letter-spacing: 0.10em;
      color: var(--accent);
      font-weight: 700;
      margin: 18px 0 0;
      padding-top: 14px;
      border-top: 1px solid rgba(255, 255, 255, 0.10);
    }
    .field-collapsible.is-group > .field-collapsible-toggle:hover { color: var(--accent-hover); }

    .field-label {
      display: block;
      font-size: 0.72rem;
      color: var(--muted);
      margin-bottom: 6px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }
    .field-select {
      width: 100%;
      appearance: none;
      -webkit-appearance: none;
      background-color: var(--field-bg);
      border: 1px solid var(--field-border);
      border-radius: 10px;
      color: var(--text);
      padding: 12px 38px 12px 14px;
      font-family: inherit;
      font-size: 0.9rem;
      cursor: pointer;
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23818cf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
      background-repeat: no-repeat;
      background-position: right 12px center;
      background-size: 16px;
      transition: border-color 0.15s, box-shadow 0.15s;
    }
    .field-select:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.22);
    }
    .field-select option { background: #0f172a; color: var(--text); }

    /* Plain text input — used when a DATASOURCE_FIELDS entry has
       type:"text" (e.g. the user-typed price). Matches the .field-select
       styling without the dropdown caret. */
    .field-input {
      width: 100%;
      appearance: none;
      -webkit-appearance: none;
      background-color: var(--field-bg);
      border: 1px solid var(--field-border);
      border-radius: 10px;
      color: var(--text);
      padding: 12px 14px;
      font-family: inherit;
      font-size: 0.9rem;
      transition: border-color 0.15s, box-shadow 0.15s;
    }
    .field-input:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.22);
    }

    /* Applied via JS when a DATASOURCE_FIELDS entry has hidden:true. The
       field stays in the DOM (so its value is still sent to the player),
       but it's not visible. Used e.g. to keep `country_X` populating the
       JWT while only exposing `city_X` in the panel UI. */
    .field-hidden { display: none !important; }

    /* ── Load button ─────────────────────────────────────────────────────── */
    .load-button {
      width: 100%;
      margin-top: 10px;
      padding: 13px 20px;
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      color: white;
      border: 0;
      border-radius: 11px;
      font-family: inherit;
      font-size: 0.95rem;
      font-weight: 600;
      cursor: pointer;
      transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
      box-shadow: 0 10px 24px rgba(129, 140, 248, 0.35);
    }
    .load-button:hover   { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(129, 140, 248, 0.45); }
    .load-button:active  { transform: translateY(0); }
    .load-button:disabled { opacity: 0.65; cursor: wait; transform: none; }

    /* ── Video panel ─────────────────────────────────────────────────────── */
    .panel.video {
      padding: 20px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 14px;
    }

    /*
       The video wrapper enforces the exact aspect ratio. The iframe inside
       is absolutely positioned to fill the wrapper exactly.
       - horizontal => 16:9, fills the column width
       - vertical   => 9:16, capped by viewport height so it doesn't get huge
    */
    .video-wrapper {
      position: relative;
      background: #000;
      border-radius: 14px;
      overflow: hidden;
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    }
    .video-wrapper[data-orientation="horizontal"] {
      width: 100%;
      aspect-ratio: 16 / 9;
    }
    .video-wrapper[data-orientation="vertical"] {
      aspect-ratio: 9 / 16;
      height: min(78vh, 720px);
      max-width: 100%;
      margin-inline: auto;   /* centre when the column is wider than the video */
    }
    .video-wrapper iframe {
      position: absolute;
      /* Bleed 1px past every edge — clipped by the wrapper's overflow:hidden —
         so a subpixel gap between the iframe and the player's inner <video>
         can't reveal a hairline of the player page's background at the edge. */
      inset: -1px;
      width: calc(100% + 2px);
      height: calc(100% + 2px);
      border: 0;
      display: block;
    }
    /* Stacked / narrow screens: size the 9:16 player by WIDTH (height follows
       the aspect ratio) instead of the desktop height cap — otherwise the
       height-derived width fights max-width and the video is mis-sized or
       off-centre. Capped so it doesn't get gigantic on tablet-width screens.
       Must come after the base rule above to win by source order. */
    @media (max-width: 880px) {
      .video-wrapper[data-orientation="vertical"] {
        height: auto;
        width: 100%;
        max-width: 430px;
      }
    }

    .placeholder {
      position: absolute;
      inset: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 12px;
      color: var(--muted);
      text-align: center;
      padding: 24px;
    }
    .placeholder .icon {
      width: 60px; height: 60px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.07);
      display: flex; align-items: center; justify-content: center;
      font-size: 22px; color: var(--accent-hover);
    }

    /* ── Below-video layout ──────────────────────────────────────────────
       row 1: engagement strip (full width)
       row 2: segment details (grows) + Copy URL button (right)
       row 3: event console (full width)
       ────────────────────────────────────────────────────────────────── */
    .details-row {
      display: flex;
      width: 100%;
      gap: 12px;
      align-items: stretch;
      flex-wrap: wrap;
    }
    .copy-button {
      flex: 0 0 auto;
      padding: 9px 16px;
      background: rgba(255, 255, 255, 0.08);
      color: var(--text);
      border: 1px solid var(--field-border);
      border-radius: 9px;
      cursor: pointer;
      font-family: inherit;
      font-size: 0.82rem;
      font-weight: 500;
      white-space: nowrap;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }
    .copy-button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
    .copy-button:disabled             { opacity: 0.4; cursor: not-allowed; }
    .copy-button.copied {
      background: rgba(34, 197, 94, 0.25);
      border-color: rgba(74, 222, 128, 0.55);
      color: #bbf7d0;
    }

    /* Engagement strip — Instagram stories style */
    .engagement-strip {
      width: 100%;
      display: flex;
      gap: 4px;
      align-items: center;
      min-height: 18px;
    }
    /* ── Bar — the always-visible coloured pill ─────────────────────────
       Solid background-color drives the unwatched/completed/skipped look.
       Watching state adds scale + glow; the rainbow overlay lives in a
       child div (see .seg-bar-overlay below). */
    .seg-bar {
      flex: 1;
      height: 10px;
      min-width: 8px;
      border-radius: 4px;
      background-color: #3a4651;     /* default = unwatched */
      cursor: pointer;
      position: relative;
      overflow: hidden;
      transition:
        background-color 450ms ease,
        transform        450ms cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow       450ms ease;
    }
    .seg-bar:hover { transform: scaleY(1.6); }
    .seg-bar[data-status="completed"]     { background-color: #57f0a3; }
    .seg-bar[data-status="skipped-once"]  { background-color: #ffd24a; }
    .seg-bar[data-status="skipped-twice"] { background-color: #ff5577; }

    .seg-bar[data-status="watching"] {
      transform: scaleY(1.6);
      box-shadow: 0 0 14px 2px rgba(248, 130, 80, 0.55);
    }

    /* ── Watching gradient overlay ───────────────────────────────────────
       A real child element (NOT a pseudo-element) so JS can set its
       inline `filter` directly. The overlay is 200% wide and contains
       exactly TWO copies of the same colour pattern; we slide it by
       -50% (one pattern's worth) over 2.4s, so the loop seam is pixel-
       identical and never visibly resets. JS rotates the whole gradient
       through green via `filter: hue-rotate(...)`. */
    .seg-bar-overlay {
      position: absolute;
      inset: 0;
      width: 200%;
      background-color: hsl(8, 95%, 58%);    /* fallback if gradients blocked */
      /* Initial red gradient — JS overwrites background-image with new
         hsl() stops as the segment progresses, instead of using
         filter: hue-rotate() (which desaturates as it rotates). */
      background-image: linear-gradient(90deg,
        hsl(0,  95%, 58%)   0%,
        hsl(8, 100%, 62%)  12.5%,
        hsl(15, 95%, 58%)  25%,
        hsl(8, 100%, 62%)  37.5%,
        hsl(0,  95%, 58%)  50%,
        hsl(8, 100%, 62%)  62.5%,
        hsl(15, 95%, 58%)  75%,
        hsl(8, 100%, 62%)  87.5%,
        hsl(0,  95%, 58%) 100%
      );
      opacity: 0;
      pointer-events: none;
      animation: segSlide 2.4s linear infinite;
      transition: opacity 450ms ease;
    }
    .seg-bar[data-status="watching"] > .seg-bar-overlay { opacity: 1; }

    .seg-bar.pinned { outline: 2px solid var(--accent); outline-offset: 2px; }

    @keyframes segSlide {
      0%   { transform: translateX(0); }
      100% { transform: translateX(-50%); }   /* exactly one pattern repeat */
    }

    /* Segment details panel — updates on hover/click of a bar */
    .segment-details {
      flex: 1;
      min-width: 0;
      background: rgba(0, 0, 0, 0.25);
      border: 1px solid var(--field-border);
      border-radius: 10px;
      padding: 10px 14px;
      font-size: 0.82rem;
      color: var(--muted);
      display: flex;
      gap: 18px;
      flex-wrap: wrap;
      align-items: center;
    }
    .segment-details .seg-name { color: var(--text); font-weight: 600; }
    .segment-details .seg-stat { display: inline-flex; gap: 6px; }
    .segment-details .seg-stat strong { color: var(--text); font-weight: 600; }
    .segment-details .seg-swatch {
      width: 10px; height: 10px; border-radius: 3px;
      display: inline-block; vertical-align: middle; margin-right: 6px;
    }

    /* Real-time event console */
    .event-console {
      width: 100%;
      min-width: 0;            /* shrink with the panel instead of dictating width */
      background: rgba(0, 0, 0, 0.45);
      border: 1px solid var(--field-border);
      border-radius: 10px;
      padding: 10px 14px;
      height: 150px;
      overflow-y: auto;
      overflow-x: auto;        /* long event lines scroll inside, not out */
      font-family: 'SF Mono', 'Monaco', 'Menlo', ui-monospace, monospace;
      font-size: 0.72rem;
      color: var(--muted);
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .event-console .event-line { white-space: nowrap; }
    .event-console .event-line.error .event-name { color: #fca5a5; }
    .event-console .event-time { color: rgba(129, 140, 248, 0.7); margin-right: 8px; }
    .event-console .event-name { color: var(--accent-hover); font-weight: 600; margin-right: 8px; }
    .event-console .event-payload { color: var(--muted); }
    .event-console .event-count {
      color: var(--accent-hover);
      margin-left: 8px;
      font-style: italic;
      opacity: 0.85;
    }
    .event-console:empty::before {
      content: "Player events will appear here once playback starts…";
      color: rgba(148, 163, 184, 0.5);
      font-style: italic;
    }

    /* ── Spinner ─────────────────────────────────────────────────────────── */
    .spinner {
      display: inline-block;
      width: 14px; height: 14px;
      border: 2px solid rgba(255, 255, 255, 0.3);
      border-top-color: white;
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
      margin-right: 8px;
      vertical-align: -2px;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* ═══ Top-right action buttons + lightboxes ════════════════════════════ */
    .header-actions {
      display: flex;
      align-items: center;
      gap: 10px;
      position: relative;
      z-index: 62;            /* keep buttons clickable above the backdrop */
    }
    .icon-button {
      position: relative;
      width: 46px; height: 46px;
      border-radius: 12px;
      background: var(--panel);
      border: 1px solid var(--panel-border);
      color: var(--text);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      transition: background 0.15s, border-color 0.15s, transform 0.08s;
    }
    .icon-button:hover  { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.22); }
    .icon-button:active { transform: scale(0.93); }
    .icon-button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
    .icon-button svg    { width: 21px; height: 21px; }

    /* Cart item-count badge */
    .cart-badge {
      position: absolute;
      top: -7px; right: -7px;
      min-width: 20px; height: 20px;
      padding: 0 5px;
      border-radius: 10px;
      background: var(--accent-2);
      color: #fff;
      font-size: 0.72rem; font-weight: 700;
      display: flex; align-items: center; justify-content: center;
      box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
    }
    .cart-badge[hidden] { display: none; }

    /* Pop-and-glow when an item lands in the cart. JS adds .pop on the
       button for the duration of the animation. */
    @keyframes cart-pop {
      0%   { transform: scale(1);    box-shadow: 0 0 0 0    rgba(236, 72, 153, 0); }
      40%  { transform: scale(1.18); box-shadow: 0 0 22px 6px rgba(236, 72, 153, 0.85); }
      100% { transform: scale(1);    box-shadow: 0 0 0 0    rgba(236, 72, 153, 0); }
    }
    .icon-button.pop { animation: cart-pop 0.5s ease-out; }

    /* Dimmed backdrop shared by both lightboxes */
    .lightbox-backdrop {
      position: fixed; inset: 0;
      background: rgba(8, 11, 24, 0.55);
      backdrop-filter: blur(2px);
      -webkit-backdrop-filter: blur(2px);
      z-index: 60;
      opacity: 0; visibility: hidden;
      transition: opacity 0.18s ease, visibility 0s linear 0.18s;
    }
    .lightbox-backdrop.open {
      opacity: 1; visibility: visible;
      transition: opacity 0.18s ease, visibility 0s;
    }

    /* Lightbox panels — anchored to the top-right, drop down from the buttons */
    .lightbox {
      position: fixed;
      top: 92px; right: 24px;
      z-index: 61;
      max-height: calc(100vh - 116px);
      display: flex; flex-direction: column;
      background: linear-gradient(180deg, #161a33, #11142a);
      border: 1px solid var(--panel-border);
      border-radius: 16px;
      box-shadow: var(--shadow);
      overflow: hidden;
      opacity: 0; visibility: hidden;
      transform: translateY(-10px) scale(0.98);
      transform-origin: top right;
      transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
    }
    .lightbox.open {
      opacity: 1; visibility: visible;
      transform: translateY(0) scale(1);
      transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
    }
    .lightbox.cart          { width: 340px; }
    .lightbox.impersonation { width: 480px; }
    @media (max-width: 560px) {
      .lightbox { left: 12px; right: 12px; width: auto !important; top: 84px; }
    }

    .lightbox-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 15px 18px;
      border-bottom: 1px solid var(--panel-border);
    }
    .lightbox-header h3 { margin: 0; font-size: 0.95rem; font-weight: 600; }
    .lightbox-close {
      background: none; border: 0; color: var(--muted);
      font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 4px;
    }
    .lightbox-close:hover { color: var(--text); }
    .lightbox-body { padding: 14px 18px 18px; overflow-y: auto; }

    /* Cart rows */
    .cart-empty {
      color: var(--muted); font-size: 0.85rem;
      text-align: center; line-height: 1.6; padding: 22px 0;
    }
    .cart-row {
      display: flex; align-items: baseline; gap: 10px;
      padding: 9px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
      font-size: 0.88rem;
    }
    .cart-row .cart-qty   { color: var(--accent-hover); font-weight: 700; flex: 0 0 auto; }
    .cart-row .cart-name  { flex: 1; color: var(--text); }
    .cart-row .cart-price { flex: 0 0 auto; color: var(--muted); }
    .cart-total {
      display: flex; justify-content: space-between;
      margin-top: 12px; padding-top: 12px;
      border-top: 1px solid var(--panel-border);
      font-size: 0.95rem; font-weight: 700;
    }
    .cart-total .cart-total-value { color: var(--accent-hover); }

    /* Impersonation rows */
    .imp-intro {
      color: var(--muted); font-size: 0.8rem;
      line-height: 1.55; margin: 0 0 14px;
    }
    .imp-group { margin-bottom: 16px; }
    .imp-group:last-child { margin-bottom: 0; }
    .imp-group-title {
      font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em;
      color: var(--accent); font-weight: 700; margin-bottom: 6px;
    }
    .imp-row {
      display: flex; align-items: center; gap: 10px;
      padding: 8px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
      font-size: 0.86rem;
    }
    .imp-row .imp-label { flex: 0 0 124px; color: var(--muted); }
    .imp-row .imp-value { flex: 1; min-width: 0; color: var(--text); font-weight: 500; }
    /* Editable visitor fields (first/last name, product, price). */
    .imp-input {
      width: 100%;
      padding: 6px 9px;
      background: var(--field-bg);
      border: 1px solid var(--field-border);
      border-radius: 7px;
      color: var(--text);
      font-family: inherit;
      font-size: 0.84rem;
      font-weight: 500;
    }
    .imp-input:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.25);
    }

    /* Unit-system toggle, rendered in place of the value for the
       unit_system row. Click either pill to switch all unit-dependent
       fields between metric and imperial display. */
    .imp-unit-toggle {
      display: inline-flex; gap: 3px;
      background: rgba(0, 0, 0, 0.30);
      border-radius: 8px;
      padding: 3px;
    }
    .imp-unit-opt {
      background: transparent;
      border: 0;
      color: var(--muted);
      font-family: inherit;
      font-size: 0.72rem; font-weight: 600;
      padding: 4px 9px;
      border-radius: 6px;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
    }
    .imp-unit-opt:hover:not(.active) { color: var(--text); }
    .imp-unit-opt.active {
      background: var(--accent);
      color: white;
    }
