/* ==========================================================================
   Nova Link component library
   --------------------------------------------------------------------------
   Keyed on the classes the existing JS already generates (app.js, studio.js,
   account-shell.js, account-services.js, admin-v2.js, badges.js,
   alliances.js, discover.js, media-premium.js, payment-icons.js, i18n.js) so
   generated markup is styled without JS changes. New markup may use the
   canonical names (.btn, .field, .chip, .card ...). Most selectors are
   wrapped in :where() so their specificity is 0: surface files (a later
   layer) always win, and inside this file later rules win by source order.

   Sections
     1  Buttons          .btn .primary .secondary .ghost .danger .soft-button .icon-btn
     2  Fields           input select textarea .input-group .field .color-control
     3  Checkbox / radio
     4  Switch           input.switch, rows: .switch-row .switch-grid>label .studio-switch .admin-check
     5  Range            input[type=range], label.range > output
     6  Segmented        .segmented .nova-language-switcher .mobile-editor-tabs ...
     7  Tabs             .tabs [role=tablist] .admin-tabs .editor-section-tabs
     8  Cards            .card .panel .card-head (+ existing card classes)
     9  Lists            .list .list-row
     10 Chips & badges   .chip .pill .premium-pill .chip-premium .status-dot .count
     11 Notices          .notice (+ existing *-error boxes)
     12 Tables           .table-wrap .table-scroll .table .table-stack
     13 Toast            #toast .toast (.show, data-tone)
     14 Tooltip          .tooltip-host > .tooltip
     15 Loading          .spinner .skeleton .loading-state
     16 Empty state      .empty-state .true-empty .error-state .empty-page
     17 Progress         .progress .account-progress progress
     18 Avatar           .avatar
     19 Kbd              kbd .kbd
     20 Menu / popover   .menu-popover .dropdown .menu-item
     21 Disclosure       details.disclosure
     22 Divider          .divider
     23 Page layout      .page-container .page-header .eyebrow (+ .page-title)
     24 Medal            .nb-medal (badge medallion, shared with the profile frame)
   ========================================================================== */

@layer components {

  /* Icons (window.NovaIcons): one line set at one stroke (r181: 1.5), sized by their slot, 16 or 18px,
     coloured by the text role of their label. */
  :where(.nv-icon) {
    stroke-width: 1.5;
  }

  /* ========================================================================
     1. Buttons
     ------------------------------------------------------------------------
     Variants: .primary (solid orange, dark text), .secondary (raised surface),
     .ghost (transparent), .danger (tinted red; add .solid for filled),
     .soft-button (tinted orange toggle; reads aria-pressed).
     Sizes: default 40px, .small/.btn-sm 32px, .large/.btn-lg 48px.
     Modifiers: .block (full width), .icon-btn (square), .is-loading or
     aria-busy="true" (spinner), :disabled / aria-disabled="true".
     r181: control radius (10px), weight 500, no glow, no hover lift; a press
     is a tiny scale down (--nv-press-scale).
     ======================================================================== */
  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn) {
    --btn-h: var(--nv-h-md);
    --btn-px: 16px;
    --btn-fg: var(--nv-text);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--nv-space-2);
    min-height: var(--btn-h);
    padding: 4px var(--btn-px);
    border: 1px solid transparent;
    border-radius: var(--nv-r-control);
    background: transparent;
    color: var(--btn-fg);
    font-family: var(--nv-font-sans);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
    line-height: 1.2;
    letter-spacing: 0;
    text-align: center;
    text-decoration: none;
    text-wrap: balance;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition:
      background-color var(--nv-dur-1) var(--nv-ease),
      border-color var(--nv-dur-1) var(--nv-ease),
      color var(--nv-dur-1) var(--nv-ease),
      transform var(--nv-dur-1) var(--nv-ease),
      opacity var(--nv-dur-1) var(--nv-ease);
  }

  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn) > svg {
    flex: none;
    width: 18px;
    height: 18px;
  }

  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn):hover {
    text-decoration: none;
  }

  /* Sizes */
  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn):where(.small, .btn-sm) {
    --btn-h: var(--nv-h-sm);
    --btn-px: 12px;
    gap: 6px;
    font-size: var(--nv-fs-13);
  }

  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn):where(.small, .btn-sm) > svg {
    width: 16px;
    height: 16px;
  }

  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button):where(.large, .btn-lg) {
    --btn-h: var(--nv-h-lg);
    --btn-px: 20px;
    font-size: var(--nv-fs-16);
  }

  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button):where(.block, .btn-block) {
    display: flex;
    width: 100%;
  }

  /* Neutral .btn without a variant behaves like .secondary: the raised surface with a hairline. */
  :where(.btn, .secondary) {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-2);
  }

  :where(.btn, .secondary):hover {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-3);
    color: var(--nv-text);
  }

  :where(.btn, .secondary):active {
    background: var(--nv-surface-2);
    transform: scale(var(--nv-press-scale));
  }

  /* Primary: the one orange action per view. A solid accent fill with dark text, nothing around it. */
  :where(.primary) {
    --btn-fg: var(--nv-on-accent);
    border-color: transparent;
    background: var(--nv-accent);
  }

  :where(.primary):hover {
    color: var(--nv-on-accent);
    background: var(--nv-accent-hover);
  }

  :where(.primary):active {
    background: var(--nv-accent-press);
    transform: scale(var(--nv-press-scale));
  }

  /* Ghost: tertiary actions, toolbars, nav. */
  :where(.ghost) {
    --btn-fg: var(--nv-text-2);
  }

  :where(.ghost):hover {
    background: rgb(239 233 227 / 6%);
    color: var(--nv-text);
  }

  :where(.ghost):active {
    background: rgb(239 233 227 / 10%);
    transform: scale(var(--nv-press-scale));
  }

  /* Danger: tinted by default, .solid for the final confirm in a dialog. */
  :where(.danger) {
    --btn-fg: var(--nv-danger);
    border-color: var(--nv-danger-line);
    background: var(--nv-danger-soft);
  }

  :where(.danger):hover {
    color: var(--nv-danger);
    border-color: var(--nv-danger-line);
    background: rgb(255 107 97 / 18%);
  }

  :where(.danger):active {
    transform: scale(var(--nv-press-scale));
  }

  :where(.danger.solid) {
    --btn-fg: #fff;
    border-color: transparent;
    background: var(--nv-danger-fill);
  }

  :where(.danger.solid):hover {
    color: #fff;
    background: #e5463b;
  }

  /* Soft: tinted orange; pressed state for toggles (aria-pressed / .active). */
  :where(.soft-button) {
    --btn-fg: var(--nv-accent-text);
    border-color: var(--nv-accent-line);
    background: var(--nv-accent-soft);
  }

  :where(.soft-button):hover {
    color: var(--nv-accent-text);
    border-color: var(--nv-accent-line);
    background: var(--nv-accent-soft-2);
  }

  :where(.soft-button):is([aria-pressed="true"], .active) {
    --btn-fg: var(--nv-on-accent);
    border-color: var(--nv-accent);
    background: var(--nv-accent);
  }

  /* Icon button: square/circular, no label (always give it aria-label). */
  :where(.icon-btn) {
    --btn-fg: var(--nv-text-2);
    width: var(--btn-h);
    min-width: var(--btn-h);
    height: var(--btn-h);
    padding: 0;
    border-color: transparent;
    background: transparent;
    font-size: 18px;
    line-height: 1;
  }

  :where(.icon-btn):hover {
    color: var(--nv-text);
    background: rgb(239 233 227 / 6%);
  }

  :where(.icon-btn.bordered) {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-2);
  }

  /* Focus: two-tone ring; composes with the variant's own shadow. */
  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn):focus-visible {
    outline: 2px solid var(--nv-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--nv-focus-gap);
  }

  /* Disabled */
  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn):is(:disabled, [aria-disabled="true"]) {
    opacity: .48;
    filter: saturate(.55);
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
  }

  /* r166 (G1): a faded orange gradient reads as a muddy brown "broken" button. A disabled primary is
     a quiet neutral pill instead (text-3 on surface-3 = 4.6:1). */
  :where(.primary):is(:disabled, [aria-disabled="true"]) {
    --btn-fg: var(--nv-text-3);
    border-color: var(--nv-line);
    background: var(--nv-surface-3);
    color: var(--nv-text-3);
    opacity: 1;
    filter: none;
  }

  /* Loading: label stays in the DOM (width is kept), a spinner replaces it. */
  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn):is(.is-loading, [aria-busy="true"]) {
    color: transparent;
    pointer-events: none;
  }

  :where(.btn, .primary, .secondary, .ghost, .danger, .soft-button, .icon-btn):is(.is-loading, [aria-busy="true"])::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid var(--btn-fg);
    border-right-color: transparent;
    border-radius: 50%;
    animation: nv-spin .7s linear infinite;
  }

  /* Text-only link button (e.g. #forgotPassword .text-action). */
  :where(.text-action, .link-button) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 8px;
    border-radius: var(--nv-r-xs);
    color: var(--nv-accent-text);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
    text-decoration: underline;
    text-decoration-color: rgb(255 154 77 / 40%);
    text-underline-offset: 3px;
  }

  :where(.text-action, .link-button):hover {
    color: var(--nv-accent-text);
    text-decoration-color: currentColor;
  }

  /* Button row helper */
  :where(.btn-row, .button-row) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nv-space-2);
  }

  /* ========================================================================
     2. Fields: text inputs, select, textarea
     ------------------------------------------------------------------------
     Every text-like control is styled without a class (generated markup
     never adds one). Height 40px (44px + 16px font on touch). Wrap with
     .field for label/hint/error, or .input-group for a prefix chip.
     ======================================================================== */
  :where(
    input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="submit"], [type="button"], [type="reset"], [type="image"], [type="hidden"]),
    select,
    textarea,
    .input
  ) {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: var(--nv-h-md);
    padding: 0 12px;
    border: 1px solid var(--nv-field-line);
    border-radius: var(--nv-r-sm);
    background-color: var(--nv-field);
    color: var(--nv-text);
    font-family: var(--nv-font-sans);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-regular);
    line-height: 1.4;
    transition:
      border-color var(--nv-dur-1) var(--nv-ease),
      background-color var(--nv-dur-1) var(--nv-ease);
  }

  :where(textarea) {
    min-height: 96px;
    padding: 10px 12px;
    line-height: var(--nv-lh-body);
  }

  :where(select) {
    padding-right: 38px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a39b92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    cursor: pointer;
  }

  :where(select[multiple]) {
    padding: 6px;
    background-image: none;
  }

  :where(select) option,
  :where(select) optgroup {
    background: var(--nv-surface-2);
    color: var(--nv-text);
  }

  :where(input[type="search"])::-webkit-search-cancel-button {
    filter: invert(.7) sepia(.3);
  }

  :where(
    input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="submit"], [type="button"], [type="reset"], [type="image"], [type="hidden"]),
    select,
    textarea,
    .input
  ):hover {
    border-color: var(--nv-field-line-hover);
    background-color: var(--nv-field-hover);
  }

  :where(
    input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="submit"], [type="button"], [type="reset"], [type="image"], [type="hidden"]),
    select,
    textarea,
    .input
  ):is(:focus, :focus-visible) {
    border-color: var(--nv-accent);
    background-color: var(--nv-field-hover);
    outline: none;
    box-shadow: var(--nv-field-ring);
  }

  /* Invalid after the user touched it, or flagged by JS. */
  :where(input, select, textarea, .input):is(:user-invalid, [aria-invalid="true"]) {
    border-color: rgba(255, 107, 97, .6);
  }

  :where(input, select, textarea, .input):is(:user-invalid, [aria-invalid="true"]):focus {
    box-shadow: 0 0 0 3px rgba(255, 107, 97, .2);
  }

  :where(input, select, textarea, .input):disabled {
    opacity: .55;
    cursor: not-allowed;
  }

  :where(input, textarea):read-only:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]) {
    border-style: dashed;
    background-color: transparent;
    color: var(--nv-text-2);
    box-shadow: none;
  }

  @media (pointer: coarse) {
    :where(
      input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="submit"], [type="button"], [type="reset"], [type="image"], [type="hidden"]),
      select,
      textarea,
      .input
    ) {
      min-height: var(--nv-hit);
      font-size: var(--nv-fs-16);
    }
  }

  /* Field wrapper: <label class="field"><span>Label</span><input>…<small class="field-hint">…</small></label>.
     Generated forms in dialogs get the same treatment for bare <label>s. */
  :where(.field, dialog form > label:not([class]), .modal-body > label:not([class]), .form-grid > label:not([class])) {
    display: grid;
    gap: 8px;
    min-width: 0;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-semibold);
    line-height: var(--nv-lh-ui);
  }

  :where(.field-label) {
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-semibold);
  }

  :where(.field-hint) {
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-regular);
  }

  :where(.field-error) {
    margin: 0;
    color: var(--nv-danger);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
  }

  :where(.field-counter) {
    justify-self: end;
    color: var(--nv-text-3);
    font-family: var(--nv-font-mono);
    font-size: var(--nv-fs-12);
    font-variant-numeric: tabular-nums;
  }

  :where(.form-grid) {
    display: grid;
    gap: var(--nv-space-4);
  }

  @media (min-width: 640px) {
    :where(.form-grid.two) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  /* Prefix chip input: <div class="input-group"><span class="input-prefix">nova-link.lol/</span><input>[<button>]</div>.
     .slug-field (editor) and .social-value (link dialog) use the same look. */
  :where(.input-group, .slug-field) {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    min-height: var(--nv-h-md);
    padding: 3px;
    border: 1px solid var(--nv-field-line);
    border-radius: var(--nv-r-control);
    background: var(--nv-field);
    transition: border-color var(--nv-dur-1) var(--nv-ease);
  }

  :where(.input-group, .slug-field):hover {
    border-color: var(--nv-field-line-hover);
  }

  :where(.input-group, .slug-field):focus-within {
    border-color: var(--nv-accent);
    box-shadow: var(--nv-field-ring);
  }

  :where(.input-prefix, .slug-field > span:first-child, .social-value > .prefix) {
    flex: none;
    display: inline-flex;
    align-items: center;
    align-self: stretch;
    max-width: 55%;
    padding: 0 8px;
    border-radius: calc(var(--nv-r-control) - 3px);
    background: var(--nv-surface-2);
    color: var(--nv-address-host);
    font-family: var(--nv-address-font);
    font-size: var(--nv-fs-13);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  :where(.input-group, .slug-field) > :where(input) {
    flex: 1;
    min-height: calc(var(--nv-h-md) - 8px);
    padding: 0 10px;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-family: var(--nv-font-mono);
    font-size: var(--nv-fs-14);
  }

  :where(.input-group, .slug-field) > :where(input):is(:hover, :focus, :focus-visible) {
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  :where(.input-group, .slug-field) > :where(button) {
    flex: none;
    --btn-h: calc(var(--nv-h-md) - 8px);
  }

  .input-group.large {
    min-height: var(--nv-h-lg);
    padding: 4px;
    border-radius: var(--nv-r-control);
  }

  .input-group.large > .input-prefix {
    padding: 0 12px;
    border-radius: calc(var(--nv-r-control) - 4px);
  }

  /* Colour picker: <span class="color-control"><input type="color"><output>#ff7a1a</output></span> */
  :where(input[type="color"]) {
    flex: none;
    width: 40px;
    height: 40px;
    padding: 4px;
    border: 1px solid var(--nv-field-line);
    border-radius: var(--nv-r-sm);
    background: var(--nv-field);
    cursor: pointer;
  }

  :where(input[type="color"])::-webkit-color-swatch-wrapper {
    padding: 0;
  }

  :where(input[type="color"])::-webkit-color-swatch {
    border: 0;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  }

  :where(input[type="color"])::-moz-color-swatch {
    border: 0;
    border-radius: 6px;
  }

  :where(.color-control) {
    display: flex;
    align-items: center;
    gap: var(--nv-space-2);
    min-height: var(--nv-h-md);
    padding: 3px 12px 3px 3px;
    border: 1px solid var(--nv-field-line);
    border-radius: var(--nv-r-sm);
    background: var(--nv-field);
  }

  :where(.color-control) > :where(input[type="color"]) {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  :where(.color-control) > :where(output) {
    color: var(--nv-text);
    font-family: var(--nv-font-mono);
    font-size: var(--nv-fs-13);
    text-transform: uppercase;
  }

  /* Visible file inputs get a secondary button. */
  :where(input[type="file"])::file-selector-button {
    margin-right: 12px;
    padding: 8px 12px;
    border: 1px solid var(--nv-line-strong);
    border-radius: var(--nv-r-control);
    background: var(--nv-surface-2);
    color: var(--nv-text);
    font: var(--nv-fw-medium) var(--nv-fs-13)/1 var(--nv-font-sans);
    cursor: pointer;
  }

  /* ========================================================================
     3. Checkbox & radio (custom-drawn, keeps native semantics)
     ======================================================================== */
  :where(input[type="checkbox"]:not(.switch, [role="switch"]), input[type="radio"]) {
    flex: none;
    display: inline-grid;
    place-content: center;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid rgba(255, 236, 220, .3);
    border-radius: 5px;
    background: var(--nv-field) no-repeat center / 14px 14px;
    appearance: none;
    vertical-align: middle;
    cursor: pointer;
    transition: background-color var(--nv-dur-1) var(--nv-ease), border-color var(--nv-dur-1) var(--nv-ease);
  }

  :where(input[type="radio"]) {
    border-radius: 50%;
  }

  :where(input[type="checkbox"]:not(.switch, [role="switch"]), input[type="radio"]):hover {
    border-color: rgba(255, 236, 220, .5);
  }

  :where(input[type="checkbox"]:not(.switch, [role="switch"])):is(:checked, :indeterminate) {
    border-color: var(--nv-accent);
    background-color: var(--nv-accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a0e05' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  }

  :where(input[type="checkbox"]:not(.switch, [role="switch"])):indeterminate {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a0e05' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
  }

  :where(input[type="radio"]):checked {
    border-color: var(--nv-accent);
    background-color: var(--nv-field);
    background-image: radial-gradient(circle, var(--nv-accent) 0 4px, transparent 4.5px);
    background-size: 100% 100%;
  }

  :where(input[type="checkbox"], input[type="radio"]):disabled {
    opacity: .45;
    cursor: not-allowed;
  }

  /* Check row: checkbox + text (title + <small> description). .admin-check and
     .copyright-declaration are existing markup with the same shape. */
  :where(.check-row, .admin-check, .copyright-declaration) {
    display: flex;
    align-items: flex-start;
    gap: var(--nv-space-3);
    color: var(--nv-text);
    font-size: var(--nv-fs-14);
    line-height: var(--nv-lh-ui);
    cursor: pointer;
  }

  :where(.check-row, .admin-check, .copyright-declaration) > :where(input) {
    margin-top: 1px;
  }

  :where(.check-row, .admin-check) small {
    display: block;
    margin-top: 2px;
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-regular);
  }

  /* ========================================================================
     4. Switch: <input type="checkbox" class="switch"> (existing markup) or
        <button role="switch" aria-checked> . The knob is a background layer,
        so it works without pseudo-elements on <input>.
     ======================================================================== */
  :where(input.switch, input[role="switch"]) {
    --sw-w: 40px;
    --sw-h: 24px;
    --sw-knob: #d9d1c9;
    flex: none;
    width: var(--sw-w);
    height: var(--sw-h);
    margin: 0;
    border: 1px solid var(--nv-line-strong);
    border-radius: var(--nv-r-round);
    background-color: var(--nv-surface-4);
    background-image: radial-gradient(circle at center, var(--sw-knob) 0 7.5px, transparent 8.5px);
    background-repeat: no-repeat;
    background-size: 22px 22px;
    background-position: 0 50%;
    appearance: none;
    cursor: pointer;
    transition:
      background-position var(--nv-dur-2) var(--nv-ease),
      background-color var(--nv-dur-2) var(--nv-ease),
      border-color var(--nv-dur-2) var(--nv-ease);
  }

  :where(input.switch, input[role="switch"]):hover {
    --sw-knob: var(--nv-text);
  }

  /* "On" is the light ramp track with a dark knob: clearly apart from the dark "off" track, and the same
     everywhere (editor, badges, share sheet, links list). r181: the accent stays on the one primary action. */
  :where(input.switch, input[role="switch"]):checked {
    --sw-knob: var(--nv-bg);
    border-color: transparent;
    background-color: var(--nv-text-2);
    background-position: 100% 50%;
  }

  :where(input.switch, input[role="switch"]):checked:hover {
    background-color: var(--nv-text);
  }

  :where(input.switch, input[role="switch"]):disabled {
    opacity: .45;
    cursor: not-allowed;
  }

  /* Switch row: label text left (title + <small> description), switch right. */
  :where(.switch-row, .switch-grid > label, .studio-switch) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--nv-space-4);
    min-height: 56px;
    padding: 12px 16px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-2);
    color: var(--nv-text);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
    line-height: var(--nv-lh-ui);
    cursor: pointer;
    transition: border-color var(--nv-dur-1) var(--nv-ease), background-color var(--nv-dur-1) var(--nv-ease);
  }

  :where(.switch-row, .switch-grid > label, .studio-switch):hover {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-3);
  }

  :where(.switch-row, .switch-grid > label, .studio-switch) small {
    display: block;
    margin-top: 2px;
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-regular);
  }

  :where(.switch-grid) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: var(--nv-space-2);
  }

  /* ========================================================================
     5. Range slider: a neutral fill to the left of a light knob (r181: six
        orange sliders on one tab spread the accent; the focus ring is the
        only orange on a slider).
        WebKit/Blink draw the fill with the thumb's border-image (clipped by
        overflow:hidden); Firefox uses ::-moz-range-progress.
        Layout helper: <label class="range">Label<output>28%</output><input type="range"></label>
     ======================================================================== */
  :where(input[type="range"]) {
    --range-thumb: 18px;
    --range-track: 4px;
    --range-fill: var(--nv-text-2);
    --range-rest: var(--nv-surface-4);
    --range-knob: var(--nv-text);
    display: block;
    width: 100%;
    height: calc(var(--range-thumb) + 12px);
    margin: 0;
    padding: 0;
    background: none;
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
  }

  :where(input[type="range"]):focus-visible {
    outline: none;
    box-shadow: none;
  }

  :where(input[type="range"])::-webkit-slider-runnable-track {
    height: var(--range-track);
    border-radius: var(--nv-r-round);
    background: var(--range-rest);
  }

  :where(input[type="range"])::-webkit-slider-thumb {
    width: var(--range-thumb);
    height: var(--range-thumb);
    margin-top: calc((var(--range-track) - var(--range-thumb)) / 2);
    border: 0;
    border-radius: 50%;
    background: var(--range-knob);
    border-image: linear-gradient(90deg, var(--range-fill) 50%, transparent 0) 0 1 / calc(50% - var(--range-track) / 2) 100vw / 0 100vw;
    box-shadow: 0 1px 3px rgb(0 0 0 / 45%);
    appearance: none;
    -webkit-appearance: none;
  }

  :where(input[type="range"]):hover::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgb(239 233 227 / 10%), 0 1px 3px rgb(0 0 0 / 45%);
  }

  :where(input[type="range"]):focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 2px var(--nv-focus-gap), 0 0 0 4px var(--nv-focus);
  }

  :where(input[type="range"])::-moz-range-track {
    height: var(--range-track);
    border-radius: var(--nv-r-round);
    background: var(--range-rest);
  }

  :where(input[type="range"])::-moz-range-progress {
    height: var(--range-track);
    border-radius: var(--nv-r-round);
    background: var(--range-fill);
  }

  :where(input[type="range"])::-moz-range-thumb {
    width: var(--range-thumb);
    height: var(--range-thumb);
    border: 0;
    border-radius: 50%;
    background: var(--range-knob);
    box-shadow: 0 1px 3px rgb(0 0 0 / 45%);
  }

  :where(input[type="range"]):focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 2px var(--nv-focus-gap), 0 0 0 4px var(--nv-focus);
  }

  :where(input[type="range"]):disabled {
    opacity: .45;
    cursor: not-allowed;
  }

  :where(label.range, .range-field) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px var(--nv-space-3);
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
  }

  :where(label.range, .range-field) > :where(input[type="range"]) {
    grid-column: 1 / -1;
  }

  /* The value is a figure: mono, tabular, quiet; no pill. */
  :where(label.range, .range-field) > :where(output),
  :where(output.value-chip) {
    justify-self: end;
    min-width: 44px;
    padding: 2px 8px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-xs);
    background: var(--nv-surface-2);
    color: var(--nv-text);
    font-family: var(--nv-font-mono);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-regular);
    font-variant-numeric: tabular-nums;
    text-align: center;
  }

  /* ========================================================================
     6. Segmented control: a quiet well with the active segment one surface
        step up and a hairline. Children are <button>s with .active /
        aria-pressed / aria-selected / aria-checked. .segmented.accent paints
        the active segment orange.
     ======================================================================== */
  :where(.segmented, .nova-language-switcher, .mobile-editor-tabs, .alignment-picker, .wallet-tabs, .badge-gift-tabs, .catalog-tabs) {
    display: inline-flex;
    align-items: stretch;
    gap: 2px;
    max-width: 100%;
    padding: 3px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-control);
    background: var(--nv-bg-deep);
    overflow-x: auto;
    scrollbar-width: none;
  }

  :where(.segmented, .nova-language-switcher, .mobile-editor-tabs, .alignment-picker, .wallet-tabs, .badge-gift-tabs, .catalog-tabs) > :where(button, a, label) {
    flex: 1 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    padding: 4px 12px;
    border: 0;
    border-radius: calc(var(--nv-r-control) - 3px);
    background: transparent;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--nv-dur-1) var(--nv-ease), color var(--nv-dur-1) var(--nv-ease);
  }

  :where(.segmented, .nova-language-switcher, .mobile-editor-tabs, .alignment-picker, .wallet-tabs, .badge-gift-tabs, .catalog-tabs) > :where(button, a, label):hover {
    color: var(--nv-text);
    text-decoration: none;
  }

  :where(.segmented, .nova-language-switcher, .mobile-editor-tabs, .alignment-picker, .wallet-tabs, .badge-gift-tabs, .catalog-tabs) > :where(button, a, label):is(.active, [aria-pressed="true"], [aria-selected="true"], [aria-checked="true"], [aria-current="page"]) {
    background: var(--nv-surface-3);
    color: var(--nv-text);
    box-shadow: inset 0 0 0 1px var(--nv-line);
  }

  :where(.segmented.accent) > :where(button, a, label):is(.active, [aria-pressed="true"], [aria-selected="true"], [aria-checked="true"]) {
    background: var(--nv-accent);
    color: var(--nv-on-accent);
    box-shadow: none;
  }

  :where(.segmented, .nova-language-switcher, .mobile-editor-tabs, .alignment-picker, .wallet-tabs, .badge-gift-tabs, .catalog-tabs) > :where(button, a, label):focus-visible {
    outline-offset: 0;
  }

  /* Compact variant: the language switcher in the sidebar (RU / EN). */
  :where(.nova-language-switcher.compact, .segmented.small) > :where(button, a, label) {
    min-height: 26px;
    padding: 2px 10px;
    font-size: var(--nv-fs-12);
  }

  :where(.nova-language-switcher) > :where(button) {
    font-family: var(--nv-font-mono);
    letter-spacing: .04em;
  }

  /* r166: 15 languages — i18n.js turns every switcher into one native select (the phone's own picker),
     drawn as a compact pill with a chevron. */
  .nova-language-switcher.is-select {
    position: relative;
    padding: 0;
    overflow: visible;
  }

  .nova-language-switcher.is-select::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 12px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    color: var(--nv-text-3);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
  }

  .nova-language-select {
    min-width: 0;
    max-width: 100%;
    min-height: 36px;
    padding: 0 32px 0 12px;
    border: 0;
    border-radius: var(--nv-r-control);
    background: transparent;
    color: var(--nv-text);
    font: inherit;
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
    cursor: pointer;
    appearance: none;
  }

  .nova-language-select:focus-visible {
    outline: 2px solid var(--nv-accent);
    outline-offset: 2px;
  }

  .nova-language-select option {
    background: var(--nv-bg-deep);
    color: var(--nv-text);
  }

  @media (max-width: 640px) {
    .nova-language-select {
      min-height: 40px;
    }
  }

  /* ========================================================================
     7. Tabs: underline style for page-level navigation inside a view.
        role=tablist containers are styled unless they are segmented-style.
     ======================================================================== */
  :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) {
    display: flex;
    align-items: stretch;
    gap: var(--nv-space-1);
    max-width: 100%;
    border-bottom: 1px solid var(--nv-line);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs))::-webkit-scrollbar {
    display: none;
  }

  :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"]) {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: var(--nv-space-2);
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--nv-r-xs) var(--nv-r-xs) 0 0;
    background: transparent;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
    text-decoration: none;
    white-space: nowrap;
    scroll-snap-align: start;
    cursor: pointer;
    transition: color var(--nv-dur-1) var(--nv-ease), background-color var(--nv-dur-1) var(--nv-ease);
  }

  :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"]):hover {
    background: rgb(239 233 227 / 4%);
    color: var(--nv-text);
    text-decoration: none;
  }

  /* The current tab: primary text and a 2px accent underline (no glow). */
  :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"])::after {
    content: "";
    position: absolute;
    inset: auto 12px -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--nv-accent);
    opacity: 0;
    transition: opacity var(--nv-dur-2) var(--nv-ease);
  }

  :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"]):is(.active, [aria-selected="true"], [aria-current="page"]) {
    color: var(--nv-text);
  }

  :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"]):is(.active, [aria-selected="true"], [aria-current="page"])::after {
    opacity: 1;
  }

  :where(.tabs, .admin-tabs, .editor-section-tabs) > :where(button, a, [role="tab"]):focus-visible {
    outline-offset: -2px;
  }

  /* Count inside a tab or nav item: <button>Moderation <span class="count">3</span></button>.
     r181: a count is quiet meta, mono and muted, not a pill; .accent puts it in the accent ink. */
  :where(.count) {
    display: inline-block;
    min-width: 2ch;
    color: var(--nv-text-3);
    font-family: var(--nv-font-mono);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-regular);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-align: right;
  }

  :where(.count.accent) {
    color: var(--nv-accent-text);
  }

  /* ========================================================================
     8. Cards & panels
     ------------------------------------------------------------------------
     .card / .panel: surface-1 one step above the canvas, hairline border,
     16px radius, no shadow. .card.raised: surface-2. .card.interactive (or
     a.card, button.card): a surface step on hover, no lift. .card.accent /
     .premium: an accent hairline (Premium), no glow.
     Existing dashboard containers are mapped here so they read as cards
     until their surface file restyles them.
     ======================================================================== */
  :where(.card, .panel, .account-surface, .account-summary-card, .account-settings-card, .admin-card, .chart-card, .top-links) {
    position: relative;
    min-width: 0;
    padding: var(--nv-space-5);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-lg);
    background: var(--nv-surface-1);
    box-shadow: var(--nv-shadow-1);
  }

  @media (min-width: 900px) {
    :where(.card, .panel) {
      padding: var(--nv-space-6);
    }
  }

  :where(.card.flush, .panel.flush) {
    padding: 0;
    overflow: hidden;
  }

  :where(.card.raised) {
    background: var(--nv-surface-2);
  }

  :where(.card.inset) {
    background: var(--nv-bg-deep);
  }

  :where(.card.interactive, a.card, button.card) {
    display: block;
    width: 100%;
    color: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--nv-dur-1) var(--nv-ease), background-color var(--nv-dur-1) var(--nv-ease);
  }

  :where(.card.interactive, a.card, button.card):hover {
    border-color: var(--nv-line-strong);
    background: color-mix(in srgb, var(--nv-surface-1), var(--nv-surface-2));
    color: inherit;
    text-decoration: none;
  }

  :where(.card.selected, .card[aria-pressed="true"], .card[aria-checked="true"]) {
    border-color: var(--nv-accent-line);
    box-shadow: 0 0 0 1px var(--nv-accent-line);
  }

  /* Premium / featured: an accent hairline, nothing around it. */
  :where(.card.accent, .card.premium) {
    border-color: var(--nv-accent-line);
  }

  :where(.card-head, .card-header) {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--nv-space-3);
    margin-bottom: var(--nv-space-4);
  }

  :where(.card-head, .card-header) :where(h2, h3, b) {
    display: block;
    color: var(--nv-text);
    font-size: var(--nv-fs-16);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
  }

  :where(.card-head, .card-header) :where(span, p, small) {
    display: block;
    margin-top: 2px;
    color: var(--nv-text-3);
    font-size: var(--nv-fs-13);
  }

  :where(.card-title) {
    color: var(--nv-text);
    font-size: var(--nv-fs-16);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
  }

  :where(.card-footer) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--nv-space-2);
    margin-top: var(--nv-space-5);
    padding-top: var(--nv-space-4);
    border-top: 1px solid var(--nv-line-soft);
  }

  /* Stat / KPI tile: <article class="stat"><span>Views</span><b>1 204</b><small>+12%</small></article> */
  :where(.stat) {
    display: grid;
    gap: 6px;
  }

  :where(.stat) > :where(span) {
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
  }

  :where(.stat) > :where(b, strong) {
    color: var(--nv-text);
    font-size: var(--nv-fs-28);
    font-weight: var(--nv-fw-medium);
    line-height: 1.1;
    letter-spacing: -.01em;
    font-variant-numeric: tabular-nums;
  }

  :where(.stat) > :where(small) {
    color: var(--nv-text-3);
  }

  :where(.delta-up) { color: var(--nv-success); }
  :where(.delta-down) { color: var(--nv-danger); }

  /* ========================================================================
     9. List rows: <ul class="list"><li class="list-row">…</li></ul>
        Leading media, .list-row-body (title + meta), trailing actions.
     ======================================================================== */
  :where(.list) {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-1);
    overflow: hidden;
  }

  :where(.list-row) {
    display: flex;
    align-items: center;
    gap: var(--nv-space-3);
    min-height: 56px;
    padding: var(--nv-space-3) var(--nv-space-4);
    color: var(--nv-text);
    text-align: left;
    text-decoration: none;
    transition: background-color var(--nv-dur-1) var(--nv-ease);
  }

  :where(.list-row) + :where(.list-row) {
    border-top: 1px solid var(--nv-line-soft);
  }

  :where(a.list-row, button.list-row, .list-row.interactive) {
    width: 100%;
    cursor: pointer;
  }

  :where(a.list-row, button.list-row, .list-row.interactive):hover {
    background: rgb(239 233 227 / 3%);
    color: var(--nv-text);
    text-decoration: none;
  }

  /* Leading icon: a fixed box so labels align, the icon in the muted role, no tile behind it. */
  :where(.list-row-icon) {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--nv-r-sm);
    color: var(--nv-text-3);
  }

  :where(.list-row-icon) > svg {
    width: 18px;
    height: 18px;
  }

  :where(.list-row-body) {
    display: grid;
    flex: 1;
    gap: 2px;
    min-width: 0;
  }

  :where(.list-row-body) > :where(b, strong, span:first-child) {
    overflow: hidden;
    color: var(--nv-text);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  :where(.list-row-body) > :where(small, span + span) {
    overflow: hidden;
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  :where(.list-row-actions) {
    flex: none;
    display: flex;
    align-items: center;
    gap: var(--nv-space-1);
  }

  /* ========================================================================
     10. Chips, tags & badges
     ------------------------------------------------------------------------
     .chip (24px tag, 6px radius) with tones .accent .success .warning .danger
     .info; .chip.outline; .chip.dot (leading status dot); .chip-premium /
     .premium-pill (existing, media-premium.js) = quiet Premium text badge.
     Toggle chips: <button class="chip" aria-pressed="true"> (control radius).
     ======================================================================== */
  :where(.chip, .pill, .tag) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 2px 8px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-xs);
    background: var(--nv-surface-2);
    color: var(--nv-text-2);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
    line-height: 1.2;
    white-space: nowrap;
    vertical-align: middle;
  }

  :where(.chip, .pill, .tag) > svg {
    width: 14px;
    height: 14px;
  }

  :where(.chip.lg, .pill.lg) {
    min-height: 32px;
    padding: 4px 12px;
    font-size: var(--nv-fs-13);
  }

  :where(.chip, .pill, .tag).accent { border-color: var(--nv-accent-line); background: var(--nv-accent-soft); color: var(--nv-accent-text); }
  :where(.chip, .pill, .tag).success { border-color: var(--nv-success-line); background: var(--nv-success-soft); color: var(--nv-success); }
  :where(.chip, .pill, .tag).warning { border-color: var(--nv-warning-line); background: var(--nv-warning-soft); color: var(--nv-warning); }
  :where(.chip, .pill, .tag).danger { border-color: var(--nv-danger-line); background: var(--nv-danger-soft); color: var(--nv-danger); }
  :where(.chip, .pill, .tag).info { border-color: var(--nv-info-line); background: var(--nv-info-soft); color: var(--nv-info); }
  :where(.chip, .pill, .tag).outline { background: transparent; }

  /* Leading dot uses currentColor, so it follows the tone. */
  :where(.chip.dot, .pill.dot)::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
  }

  /* Toggle chip: a small control (control radius). */
  :where(button.chip, a.chip) {
    min-height: var(--nv-h-sm);
    padding: 4px 12px;
    border-radius: var(--nv-r-control);
    font-size: var(--nv-fs-13);
    cursor: pointer;
    transition: background-color var(--nv-dur-1) var(--nv-ease), border-color var(--nv-dur-1) var(--nv-ease), color var(--nv-dur-1) var(--nv-ease);
  }

  :where(button.chip, a.chip):hover {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-3);
    color: var(--nv-text);
    text-decoration: none;
  }

  /* Selected: one surface step up with a brighter hairline, like the segmented control (r181: no accent tint;
     the accent is for the one primary action and the chosen picker tile). */
  :where(button.chip, a.chip):is(.active, [aria-pressed="true"], [aria-selected="true"]) {
    border-color: var(--nv-field-line-hover);
    background: var(--nv-surface-3);
    color: var(--nv-text);
  }

  /* Premium badge: quiet text in the accent ink with a small lock (mask, no text); sentence case,
     no gradient border, no tracking. */
  :where(.chip-premium, .premium-pill) {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 20px;
    padding: 0 6px;
    border: 1px solid var(--nv-accent-line);
    border-radius: var(--nv-r-xs);
    background: transparent;
    color: var(--nv-premium);
    font-size: var(--nv-fs-12);
    font-style: normal;
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: none;
    white-space: nowrap;
    vertical-align: middle;
  }

  :where(.chip-premium, .premium-pill)::before {
    content: "";
    flex: none;
    width: 12px;
    height: 12px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1Zm2.5 0h5V7a2.5 2.5 0 0 0-5 0v3Z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1Zm2.5 0h5V7a2.5 2.5 0 0 0-5 0v3Z'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  /* Unlocked (an active plan): the word alone, no lock and no sparkle. */
  :where(.chip-premium.unlocked) {
    padding-inline: 6px;
  }

  :where(.chip-premium.unlocked)::before {
    content: none;
  }

  /* Status dot (existing: app.js domains). .idle .warning .error variants. A plain dot, no halo. */
  :where(.status-dot) {
    display: inline-block;
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--nv-success);
  }

  :where(.status-dot.idle) {
    background: var(--nv-text-3);
  }

  :where(.status-dot.warning, .status-dot.checking) {
    background: var(--nv-warning);
  }

  :where(.status-dot.error, .status-dot.bad) {
    background: var(--nv-danger);
  }

  :where(.status-dot.live) {
    animation: nv-pulse 2s var(--nv-ease-in-out) infinite;
  }

  /* ========================================================================
     11. Notices / inline alerts
         <p class="notice">…</p>, tones .info .success .warning .danger.
         Existing error boxes in dialogs map to the danger tone.
     ======================================================================== */
  /* The tone lives in the border, the tint and the icon; the words stay in the text roles. */
  :where(.notice, .legal-notice) {
    display: flex;
    align-items: flex-start;
    gap: var(--nv-space-3);
    margin: 0;
    padding: var(--nv-space-3) var(--nv-space-4);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-2);
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    line-height: var(--nv-lh-body);
  }

  :where(.notice) > svg {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 1px;
  }

  :where(.notice.info) { border-color: var(--nv-info-line); background: var(--nv-info-soft); color: var(--nv-text); }
  :where(.notice.success) { border-color: var(--nv-success-line); background: var(--nv-success-soft); color: var(--nv-text); }
  :where(.notice.warning) { border-color: var(--nv-warning-line); background: var(--nv-warning-soft); color: var(--nv-text); }
  :where(.notice.accent) { border-color: var(--nv-accent-line); background: var(--nv-accent-soft); color: var(--nv-text); }
  :where(.notice.info) > svg { color: var(--nv-info); }
  :where(.notice.success) > svg { color: var(--nv-success); }
  :where(.notice.warning) > svg { color: var(--nv-warning); }
  :where(.notice.accent) > svg { color: var(--nv-accent-text); }

  :where(.notice.danger, .auth-error, .activation-error, .badge-commerce-error, .alliance-error, .admin-bulk-error, .account-settings-error, .admin-badge-error) {
    margin: 0;
    padding: var(--nv-space-2) var(--nv-space-3);
    border: 1px solid var(--nv-danger-line);
    border-radius: var(--nv-r-sm);
    background: var(--nv-danger-soft);
    color: var(--nv-text);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
    line-height: var(--nv-lh-ui);
  }

  /* ========================================================================
     12. Tables: always scroll inside their own wrapper, never the page.
         <div class="table-wrap"><table class="table">…</table></div>
         (.table-scroll from app.js is the same wrapper.) Add .table-stack to
         the wrapper to turn rows into cards below 640px; put the column
         name in each cell as <span class="cell-label">Status</span> (real
         text, so i18n translates it; it is hidden on desktop).
     ======================================================================== */
  :where(.table-wrap, .table-scroll) {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-1);
  }

  :where(.table, .table-wrap > table, .table-scroll > table) {
    width: 100%;
    min-width: 560px;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--nv-text);
    font-size: var(--nv-fs-13);
    font-variant-numeric: tabular-nums;
  }

  :where(.table, .table-wrap > table, .table-scroll > table) :where(th) {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--nv-space-3) var(--nv-space-4);
    border-bottom: 1px solid var(--nv-line);
    background: var(--nv-surface-2);
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
    letter-spacing: .01em;
    text-align: left;
    white-space: nowrap;
  }

  :where(.table, .table-wrap > table, .table-scroll > table) :where(td) {
    padding: var(--nv-space-3) var(--nv-space-4);
    border-top: 1px solid var(--nv-line-soft);
    vertical-align: middle;
  }

  :where(.table, .table-wrap > table, .table-scroll > table) :where(tbody tr:first-child td) {
    border-top: 0;
  }

  :where(.table, .table-wrap > table, .table-scroll > table) :where(tbody tr) {
    transition: background-color var(--nv-dur-1) var(--nv-ease);
  }

  :where(.table, .table-wrap > table, .table-scroll > table) :where(tbody tr:hover) {
    background: rgb(239 233 227 / 3%);
  }

  :where(.table) :where(.num, [data-num]) {
    text-align: right;
  }

  :where(.cell-label) {
    display: none;
  }

  @media (max-width: 639px) {
    :where(.table-stack) {
      border: 0;
      background: transparent;
      overflow: visible;
    }

    :where(.table-stack) :where(table) {
      min-width: 0;
    }

    :where(.table-stack) :where(thead) {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }

    :where(.table-stack) :where(tbody) {
      display: grid;
      gap: var(--nv-space-2);
    }

    :where(.table-stack) :where(tr) {
      display: grid;
      gap: 6px;
      padding: var(--nv-space-3) var(--nv-space-4);
      border: 1px solid var(--nv-line);
      border-radius: var(--nv-r-md);
      background: var(--nv-surface-1);
    }

    :where(.table-stack) :where(td) {
      display: grid;
      grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
      gap: var(--nv-space-3);
      padding: 0;
      border: 0;
    }

    :where(.table-stack) :where(.cell-label) {
      display: block;
      color: var(--nv-text-3);
      font-size: var(--nv-fs-12);
    }
  }

  /* ========================================================================
     13. Toast: #toast (app.js notify() toggles .show). Optional tone via
         data-tone="success|error|warning|info" or .is-success/.is-error/...
         Dialogs sit in the top layer above it (see known issue).
     ======================================================================== */
  :where(#toast, .toast) {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    z-index: var(--nv-z-toast);
    display: flex;
    align-items: center;
    gap: var(--nv-space-3);
    width: max-content;
    max-width: min(460px, calc(100vw - 32px));
    padding: var(--nv-space-3) var(--nv-space-4) var(--nv-space-3) var(--nv-space-3);
    border: 1px solid var(--nv-line-strong);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-2);
    color: var(--nv-text);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
    line-height: var(--nv-lh-ui);
    box-shadow: var(--nv-shadow-2);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity var(--nv-dur-3) var(--nv-ease), transform var(--nv-dur-3) var(--nv-ease);
  }

  :where(#toast, .toast)::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--toast-tone, var(--nv-accent));
  }

  :where(#toast, .toast):empty {
    visibility: hidden;
  }

  :where(#toast, .toast).show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
  }

  :where(#toast, .toast):is([data-tone="success"], .is-success) { --toast-tone: var(--nv-success); }
  :where(#toast, .toast):is([data-tone="error"], [data-tone="danger"], .is-error) { --toast-tone: var(--nv-danger); border-color: var(--nv-danger-line); }
  :where(#toast, .toast):is([data-tone="warning"], .is-warning) { --toast-tone: var(--nv-warning); }
  :where(#toast, .toast):is([data-tone="info"], .is-info) { --toast-tone: var(--nv-info); }

  /* Static toast for the style guide / inline previews. */
  :where(.toast.static) {
    position: static;
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  /* ========================================================================
     14. Tooltip: real text in markup (i18n translates it).
         <span class="tooltip-host"><button aria-describedby="t1">…</button>
         <span class="tooltip" role="tooltip" id="t1">Copy link</span></span>
         .tooltip.bottom places it below.
     ======================================================================== */
  :where(.tooltip-host) {
    position: relative;
    display: inline-flex;
  }

  :where(.tooltip) {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: var(--nv-z-tooltip);
    width: max-content;
    max-width: 240px;
    padding: 6px 10px;
    border: 1px solid var(--nv-line-strong);
    border-radius: var(--nv-r-sm);
    background: var(--nv-surface-4);
    color: var(--nv-text);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
    line-height: 1.35;
    text-align: center;
    box-shadow: var(--nv-shadow-2);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity var(--nv-dur-2) var(--nv-ease), transform var(--nv-dur-2) var(--nv-ease), visibility var(--nv-dur-2);
  }

  :where(.tooltip.bottom) {
    top: calc(100% + 8px);
    bottom: auto;
    transform: translate(-50%, -4px);
  }

  :where(.tooltip-host):is(:hover, :focus-within) > :where(.tooltip),
  :where(.tooltip.show) {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
  }

  /* ========================================================================
     15. Loading: .spinner, .skeleton, .loading-state (existing, app.js/admin)
     ======================================================================== */
  :where(.spinner) {
    display: inline-block;
    flex: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 236, 220, .16);
    border-top-color: var(--nv-accent);
    border-radius: 50%;
    animation: nv-spin .75s linear infinite;
  }

  :where(.spinner.lg) {
    width: 28px;
    height: 28px;
    border-width: 3px;
  }

  :where(.skeleton, .discover-skeleton) {
    display: block;
    min-height: 12px;
    border-radius: var(--nv-r-sm);
    background:
      linear-gradient(100deg, transparent 20%, rgba(255, 236, 220, .06) 45%, transparent 70%) 0 0 / 220% 100% no-repeat,
      var(--nv-surface-2);
    animation: nv-shimmer 1.4s var(--nv-ease-in-out) infinite;
  }

  :where(.skeleton.text) { height: 12px; border-radius: var(--nv-r-xs); }
  :where(.skeleton.title) { width: 46%; height: 20px; border-radius: var(--nv-r-xs); }
  :where(.skeleton.circle) { width: 40px; height: 40px; border-radius: 50%; }

  :where(.loading-state, .catalog-loading, .badges-loading, .alliances-loading, .wallet-history-loading) {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--nv-space-3);
    min-height: 120px;
    padding: var(--nv-space-6);
    color: var(--nv-text-2);
    font-size: var(--nv-fs-14);
    text-align: center;
  }

  :where(.loading-state, .catalog-loading, .badges-loading, .alliances-loading, .wallet-history-loading)::before {
    content: "";
    flex: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 236, 220, .16);
    border-top-color: var(--nv-accent);
    border-radius: 50%;
    animation: nv-spin .75s linear infinite;
  }

  :where(.loading-state.compact) {
    min-height: 64px;
    padding: var(--nv-space-4);
  }

  /* ========================================================================
     16. Empty state: .empty-state (canonical), .true-empty (existing),
         .error-state (existing, adds danger tone), .empty-page (static
         studio placeholder pages). Children: an icon (svg or .empty-icon),
         <b>/<h3> title, <span>/<p> text, buttons.
     ======================================================================== */
  :where(.empty-state, .true-empty, .empty-page) {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: var(--nv-space-2);
    min-height: 200px;
    padding: var(--nv-space-10) var(--nv-space-6);
    border: 1px dashed var(--nv-line-strong);
    border-radius: var(--nv-r-lg);
    background: var(--nv-surface-1);
    color: var(--nv-text-2);
    text-align: center;
  }

  /* The icon on its own in the muted role: no tile, no accent. */
  :where(.empty-state, .true-empty, .empty-page) > :where(.empty-icon, svg),
  :where(.empty-page) > :where(span:first-child) {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-bottom: var(--nv-space-1);
    color: var(--nv-text-3);
  }

  :where(.empty-state, .true-empty, .empty-page) > :where(.empty-icon) > svg {
    width: 24px;
    height: 24px;
  }

  :where(.empty-state, .true-empty, .empty-page) > :where(b, h2, h3, h1) {
    color: var(--nv-text);
    font-size: var(--nv-fs-18);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
  }

  :where(.empty-state, .true-empty, .empty-page) > :where(span, p) {
    max-width: 44ch;
    font-size: var(--nv-fs-14);
    line-height: var(--nv-lh-body);
  }

  :where(.empty-state, .true-empty, .empty-page) > :where(button, a, .btn-row) {
    margin-top: var(--nv-space-3);
  }

  :where(.error-state) {
    border-color: var(--nv-danger-line);
    background: var(--nv-surface-1);
  }

  :where(.error-state) > :where(.empty-icon, svg) {
    color: var(--nv-danger);
  }

  /* ========================================================================
     17. Progress: <div class="progress" role="progressbar" aria-valuenow="60"><span style="width:60%"></span></div>
         .account-progress (account-shell.js) has the same markup; native
         <progress> is styled too.
     ======================================================================== */
  :where(.progress, .account-progress) {
    position: relative;
    height: 6px;
    border-radius: var(--nv-r-round);
    background: var(--nv-surface-3);
    overflow: hidden;
  }

  /* A solid accent fill; the width is set inline and is not animated (r181). */
  :where(.progress, .account-progress) > :where(span, i) {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--nv-accent);
  }

  :where(.progress.lg) {
    height: 8px;
  }

  :where(.progress.indeterminate) > :where(span, i) {
    width: 40%;
    animation: nv-indeterminate 1.2s var(--nv-ease) infinite;
  }

  :where(progress) {
    width: 100%;
    height: 6px;
    border: 0;
    border-radius: var(--nv-r-round);
    background: var(--nv-surface-3);
    appearance: none;
    overflow: hidden;
  }

  :where(progress)::-webkit-progress-bar {
    background: var(--nv-surface-3);
  }

  :where(progress)::-webkit-progress-value {
    border-radius: var(--nv-r-round);
    background: var(--nv-accent);
  }

  :where(progress)::-moz-progress-bar {
    border-radius: var(--nv-r-round);
    background: var(--nv-accent);
  }

  /* ========================================================================
     18. Avatar: <span class="avatar"><img alt=""></span> or initials text.
         Sizes .sm (28) default (40) .lg (56) .xl (88); .ring = accent ring.
     ======================================================================== */
  :where(.avatar, .admin-user-avatar) {
    --av: 40px;
    position: relative;
    flex: none;
    display: inline-grid;
    place-items: center;
    width: var(--av);
    height: var(--av);
    border: 1px solid var(--nv-line-strong);
    border-radius: 50%;
    background: var(--nv-surface-3);
    color: var(--nv-text-2);
    font-size: calc(var(--av) * .38);
    font-weight: var(--nv-fw-medium);
    text-transform: uppercase;
    overflow: hidden;
  }

  :where(.avatar, .admin-user-avatar) > :where(img, video) {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  :where(.avatar.sm) { --av: 28px; }
  :where(.avatar.lg) { --av: 56px; }
  :where(.avatar.xl) { --av: 88px; }
  :where(.avatar.square) { border-radius: 28%; }

  :where(.avatar.ring) {
    border: 0;
    box-shadow: 0 0 0 2px var(--nv-bg), 0 0 0 4px var(--nv-accent);
  }

  :where(.avatar-stack) {
    display: inline-flex;
  }

  :where(.avatar-stack) > :where(.avatar) + :where(.avatar) {
    margin-left: -10px;
    box-shadow: 0 0 0 2px var(--nv-surface-1);
  }

  /* ========================================================================
     19. Keyboard key
     ======================================================================== */
  :where(kbd, .kbd) {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 1px solid var(--nv-line-strong);
    border-bottom-width: 2px;
    border-radius: var(--nv-r-xs);
    background: var(--nv-surface-3);
    color: var(--nv-text-2);
    font-family: var(--nv-font-mono);
    font-size: 11px;
    font-weight: var(--nv-fw-medium);
    line-height: 1;
  }

  /* ========================================================================
     20. Menu / popover / dropdown
         <details class="dropdown"><summary class="secondary">…</summary>
           <div class="menu-popover" role="menu">
             <button class="menu-item" role="menuitem">…</button>
             <hr class="menu-sep"> …</div></details>
         Works with [popover] too. (.menu is the landing hamburger; not used.)
     ======================================================================== */
  :where(.dropdown) {
    position: relative;
    display: inline-block;
  }

  :where(.dropdown) > summary {
    list-style: none;
  }

  :where(.dropdown) > summary::-webkit-details-marker {
    display: none;
  }

  /* A solid floating surface with a hairline and a soft neutral shadow (no glass). */
  :where(.menu-popover, .mode-help-popover) {
    z-index: var(--nv-z-dropdown);
    display: grid;
    gap: 2px;
    width: max-content;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 32px));
    margin: 0;
    padding: 4px;
    border: 1px solid var(--nv-line-strong);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-1);
    color: var(--nv-text);
    box-shadow: var(--nv-shadow-2);
  }

  :where(.dropdown) > :where(.menu-popover) {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    animation: nv-pop var(--nv-dur-2) var(--nv-ease-out);
  }

  :where(.dropdown.end) > :where(.menu-popover) {
    right: 0;
    left: auto;
  }

  :where(.mode-help-popover) {
    gap: var(--nv-space-2);
    padding: var(--nv-space-4);
    font-size: var(--nv-fs-13);
    line-height: var(--nv-lh-body);
  }

  :where(.menu-item, .menu-popover > button, .menu-popover > a) {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 6px 8px;
    border: 0;
    border-radius: calc(var(--nv-r-md) - 4px);
    background: transparent;
    box-shadow: none;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--nv-dur-1) var(--nv-ease), color var(--nv-dur-1) var(--nv-ease);
  }

  :where(.menu-item, .menu-popover > button, .menu-popover > a) > svg {
    flex: none;
    width: 18px;
    height: 18px;
    color: var(--nv-text-3);
  }

  :where(.menu-item, .menu-popover > button, .menu-popover > a):is(:hover, :focus-visible, .active) {
    background: var(--nv-surface-2);
    color: var(--nv-text);
    text-decoration: none;
  }

  :where(.menu-item, .menu-popover > button, .menu-popover > a):focus-visible {
    outline-offset: -2px;
  }

  :where(.menu-item.danger) {
    color: var(--nv-danger);
  }

  :where(.menu-item.danger):hover {
    background: var(--nv-danger-soft);
    color: var(--nv-danger);
  }

  :where(.menu-item) > :where(kbd, .kbd, .chip-premium) {
    margin-left: auto;
  }

  :where(.menu-sep) {
    height: 1px;
    margin: 4px 6px;
    border: 0;
    background: var(--nv-line);
  }

  /* Section label inside a menu: sentence case, muted, close to its own items. */
  :where(.menu-label) {
    padding: 8px 8px 4px;
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
    text-transform: none;
  }

  /* ========================================================================
     21. Disclosure / accordion: <details class="disclosure"><summary>Q</summary><div>A</div></details>
         Chevron is drawn with borders (no text in CSS).
     ======================================================================== */
  :where(details.disclosure) {
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-1);
    transition: border-color var(--nv-dur-2) var(--nv-ease);
  }

  :where(details.disclosure)[open] {
    border-color: var(--nv-line-strong);
  }

  :where(details.disclosure) > summary {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--nv-space-3);
    min-height: 52px;
    padding: 12px 48px 12px 20px;
    border-radius: inherit;
    color: var(--nv-text);
    font-size: var(--nv-fs-16);
    font-weight: var(--nv-fw-medium);
    list-style: none;
  }

  :where(details.disclosure) > summary::-webkit-details-marker {
    display: none;
  }

  :where(details.disclosure) > summary::after {
    content: "";
    position: absolute;
    right: 20px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--nv-text-3);
    border-bottom: 1.5px solid var(--nv-text-3);
    transform: translateY(-70%) rotate(45deg);
    transition: transform var(--nv-dur-2) var(--nv-ease), border-color var(--nv-dur-2) var(--nv-ease);
  }

  :where(details.disclosure)[open] > summary::after {
    border-color: var(--nv-text-2);
    transform: translateY(-30%) rotate(-135deg);
  }

  :where(details.disclosure) > summary:focus-visible {
    outline-offset: -2px;
  }

  :where(details.disclosure) > :not(summary) {
    padding: 0 20px 20px;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-14);
    line-height: var(--nv-lh-body);
  }

  /* ========================================================================
     22. Divider: <hr class="divider"> or <div class="divider"><span>or</span></div>
     ======================================================================== */
  :where(.divider) {
    display: flex;
    align-items: center;
    gap: var(--nv-space-3);
    margin: var(--nv-space-5) 0;
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
  }

  :where(hr.divider) {
    height: 1px;
    border: 0;
    background: var(--nv-line);
  }

  :where(div.divider)::before,
  :where(div.divider)::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--nv-line);
  }

  :where(.divider.vertical) {
    align-self: stretch;
    width: 1px;
    height: auto;
    margin: 0 var(--nv-space-2);
    background: var(--nv-line);
  }

  /* ========================================================================
     23. Page layout: container + page header
         <div class="page-container">
           <header class="page-header">
             <div><span class="eyebrow">Content</span><h1>Links</h1><p class="subtitle">…</p></div>
             <div class="page-header-actions"><button class="primary">…</button></div>
           </header> … </div>
         The existing studio markup .page-title (span + h1 + p | button) and
         .account-page-heading (h1 + p) map to the same look.
     ======================================================================== */
  :where(.page-container, .container) {
    width: 100%;
    max-width: calc(var(--nv-w-content) + 2 * var(--nv-gutter));
    margin-inline: auto;
    padding-inline: var(--nv-gutter);
  }

  :where(.container.wide) {
    max-width: calc(var(--nv-w-wide) + 2 * var(--nv-gutter));
  }

  :where(.container.prose-width) {
    max-width: calc(var(--nv-w-prose) + 2 * var(--nv-gutter));
  }

  :where(.page-header, .page-title) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--nv-space-4) var(--nv-space-6);
    margin-bottom: var(--nv-space-6);
  }

  :where(.page-header, .page-title) > :where(div:first-child) {
    display: grid;
    gap: var(--nv-space-2);
    min-width: 0;
    max-width: 68ch;
  }

  /* A section label: sentence case, muted, normal tracking (r181: no orange tracked caps). */
  :where(.eyebrow, .kicker, .page-title > div > span:first-child) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--nv-text-3);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
    letter-spacing: var(--nv-tracking-eyebrow);
    line-height: 1.3;
    text-transform: none;
  }

  :where(.eyebrow.muted) {
    color: var(--nv-text-3);
  }

  :where(.page-header, .page-title, .account-page-heading) :where(h1) {
    font-size: var(--nv-fs-28);
    font-weight: var(--nv-fw-medium);
    line-height: 1.15;
    letter-spacing: var(--nv-tracking-tight);
  }

  @media (min-width: 900px) {
    :where(.page-header, .page-title, .account-page-heading) :where(h1) {
      font-size: 32px;
    }
  }

  :where(.page-header .subtitle, .page-header p, .page-title p, .account-page-heading p) {
    color: var(--nv-text-2);
    font-size: var(--nv-fs-14);
    line-height: var(--nv-lh-body);
  }

  :where(.page-header-actions) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nv-space-2);
  }

  :where(.account-page-heading) {
    display: grid;
    gap: var(--nv-space-2);
    margin-bottom: var(--nv-space-6);
  }

  /* Section heading inside a page */
  :where(.section-title, .account-section-heading) {
    margin: var(--nv-space-8) 0 var(--nv-space-4);
    color: var(--nv-text);
    font-size: var(--nv-fs-18);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
  }

  /* r181: was gradient text; the highlighted words are plain primary text now (name kept for markup). */
  :where(.text-gradient) {
    color: var(--nv-text);
  }

  /* Signature: an address. <span class="nv-address"><span class="nv-address-host">nova-link.lol/</span><span class="nv-address-name">name</span></span>.
     Mono, the host dim, the name bright; used only where an address is shown. */
  :where(.nv-address) {
    font-family: var(--nv-address-font);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  :where(.nv-address-host) {
    color: var(--nv-address-host);
  }

  :where(.nv-address-name) {
    color: var(--nv-address-name);
  }

  /* Inline line icon inside a sentence (shell glyphs that used to be ✓ / ⚠). */
  :where(.nv-icon-inline) {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    margin-right: .3em;
    vertical-align: -.18em;
  }

  /* ========================================================================
     24. Badge medallion (.nb-medal), rendered by NovaBadges.medal in
         badge-icons-runtime.js. CSS var API (set inline by JS, keep names):
           --nb-size (box size, default 28px), --nb-light, --nb-deep
           (gradient stops), --nb-glow (drop glow), --nb-i (index, staggers
           the sweep). data-anim: pulse | float | spin | spark | bounce | orbit.
         The profile frame loads its own copy (badges-v2.css) until the
         profile agent ports it.
     ======================================================================== */
  .nb-medal {
    --nb-size: 28px;
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: var(--nb-size);
    height: var(--nb-size);
    border-radius: 36%;
    color: #fff;
    background: radial-gradient(120% 90% at 30% 18%, color-mix(in srgb, var(--nb-light) 55%, #fff) 0%, var(--nb-light) 38%, var(--nb-deep) 100%);
    box-shadow:
      0 0 0 1.5px rgba(255, 255, 255, .92),
      0 0 0 2.5px color-mix(in srgb, var(--nb-deep) 45%, transparent),
      inset 0 1px 1px rgba(255, 255, 255, .55),
      inset 0 -3px 6px color-mix(in srgb, var(--nb-deep) 70%, #000 10%),
      0 4px 12px -3px color-mix(in srgb, var(--nb-glow) 75%, transparent);
    isolation: isolate;
    overflow: hidden;
    transition: transform var(--nv-dur-2) var(--nv-ease);
  }

  /* Glossy cap */
  .nb-medal::before {
    content: "";
    position: absolute;
    inset: 0 0 52%;
    z-index: -1;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, 0));
  }

  /* Light sweep. r181: medals are a moment, but a row of them never moves all at once at rest: the sweep
     and the icon motion play on hover / focus, or always inside a preview that opts in with .nb-live
     (on the medal or any parent), staggered by --nb-i. */
  .nb-medal::after {
    content: "";
    position: absolute;
    inset: -40%;
    background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, .55) 50%, transparent 58%);
    transform: translateX(-70%);
    pointer-events: none;
  }

  :is(.nb-medal:hover, .nb-medal:focus-visible, :focus-visible > .nb-medal)::after {
    animation: nbSweepOnce 900ms var(--nv-ease) both;
  }

  :is(.nb-live .nb-medal, .nb-medal.nb-live)::after {
    animation: nbSweep 6s ease-in-out infinite;
    animation-delay: calc(var(--nb-i, 0) * .7s);
  }

  .nb-medal svg {
    width: 60%;
    height: 60%;
    overflow: visible;
    filter: drop-shadow(0 1px 1px color-mix(in srgb, var(--nb-deep) 80%, #000));
  }

  .nb-medal:hover {
    transform: scale(1.06);
  }

  :is(.nb-medal:hover, .nb-medal:focus-visible, :focus-visible > .nb-medal, .nb-live .nb-medal, .nb-medal.nb-live)[data-anim="pulse"] svg { animation: nbPulse 2.2s ease-in-out infinite; }
  :is(.nb-medal:hover, .nb-medal:focus-visible, :focus-visible > .nb-medal, .nb-live .nb-medal, .nb-medal.nb-live)[data-anim="float"] svg { animation: nbFloat 2.6s ease-in-out infinite; }
  :is(.nb-medal:hover, .nb-medal:focus-visible, :focus-visible > .nb-medal, .nb-live .nb-medal, .nb-medal.nb-live)[data-anim="spin"] svg { animation: nbSpin 6s linear infinite; }
  :is(.nb-medal:hover, .nb-medal:focus-visible, :focus-visible > .nb-medal, .nb-live .nb-medal, .nb-medal.nb-live)[data-anim="spark"] svg { animation: nbSpark 2.4s ease-in-out infinite; }
  :is(.nb-medal:hover, .nb-medal:focus-visible, :focus-visible > .nb-medal, .nb-live .nb-medal, .nb-medal.nb-live)[data-anim="bounce"] svg { animation: nbBounce 2s ease-in-out infinite; }
  :is(.nb-medal:hover, .nb-medal:focus-visible, :focus-visible > .nb-medal, .nb-live .nb-medal, .nb-medal.nb-live)[data-anim="orbit"] svg { animation: nbOrbit 3.8s ease-in-out infinite; }

  /* Release 162: a user-made badge with an uploaded picture. badge-icons-runtime.js removes the
     picture when it fails to load, so the icon underneath comes back. */
  .nb-medal.has-image svg {
    display: none;
  }

  .nb-medal-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    pointer-events: none;
  }

  /* Locked / not owned: muted, no sweep. */
  .nb-medal.is-locked,
  .is-locked .nb-medal {
    filter: saturate(.7);
    opacity: .78;
  }

  .nb-medal.is-locked::after,
  .is-locked .nb-medal::after {
    animation: none;
  }

  /* Row of medals (profile badges, previews). */
  :where(.nb-row) {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }

  /* r180: the r166 thumb sizes (section 25) follow the pointer too, so a phone in landscape or a tablet
     keeps 36px segments and tabs, a 44px dialog ✕ / small icon button, 44px menu rows and selects. */
  @media (pointer: coarse) {
    :where(.segmented, .alignment-picker, .wallet-tabs, .badge-gift-tabs, .catalog-tabs) > :where(button, a, label),
    :where(.segmented.small) > :where(button, a, label),
    :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"]) {
      min-height: 36px;
    }

    :where(.dialog-close, .icon-btn.small) {
      --btn-h: var(--nv-hit);
    }

    :where(details) > :where(summary) {
      padding-block: 11px;
    }

    :where(.menu-item) {
      min-height: var(--nv-hit);
    }

    .nova-language-select {
      min-height: var(--nv-hit);
    }
  }

  /* ========================================================================
     25. Phones (≤640px): compact (r160). Zero-specificity :where() so every
         surface rule still wins; only paddings and sizes move (r181: the
         effects are quiet everywhere, so phones no longer need calmer copies).
     ======================================================================== */
  @media (max-width: 640px) {
    /* r166 (G3): thumb-sized targets. Small buttons and segments ≥36px, icon buttons and the
       dialog ✕ 44px, disclosure summaries a full 44px row. */
    :where(.segmented, .alignment-picker, .wallet-tabs, .badge-gift-tabs, .catalog-tabs) > :where(button, a, label),
    :where(.segmented.small) > :where(button, a, label) {
      min-height: 36px;
    }

    :where(.dialog-close, .icon-btn.small) {
      --btn-h: var(--nv-hit);
    }

    :where(details) > :where(summary) {
      padding-block: 11px;
    }

    /* r166 (G6): page tabs on phones are small controls like the filter chips (no underline); r181: the
       current one is a surface step with a hairline, not an orange tint. */
    :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"]) {
      min-height: 36px;
      border-radius: var(--nv-r-control);
    }

    :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"])::after {
      content: none;
    }

    :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) > :where(button, a, [role="tab"]):is(.active, [aria-selected="true"], [aria-current="page"]) {
      background: var(--nv-surface-3);
      box-shadow: inset 0 0 0 1px var(--nv-line);
    }

    :where(.tabs, .admin-tabs, .editor-section-tabs, [role="tablist"]:not(.wallet-tabs, .badge-gift-tabs, .icon-filters, .segmented, .catalog-tabs)) {
      border-bottom: 0;
    }

    /* r166 (G5): the top bar already names the page — no orange eyebrow above every dashboard title. */
    .app-shell .page-header .eyebrow {
      display: none;
    }

    :where(.soft-button):is([aria-pressed="true"], .active) {
      --btn-fg: var(--nv-accent-text);
      border-color: var(--nv-accent-line);
      background: var(--nv-accent-soft-2);
    }

    :where(.switch-row, .switch-grid > label, .studio-switch) {
      gap: var(--nv-space-3);
      min-height: 48px;
      padding: 8px 12px;
    }

    :where(.card-head, .card-header) {
      margin-bottom: var(--nv-space-3);
    }

    :where(.card-footer) {
      margin-top: var(--nv-space-4);
      padding-top: var(--nv-space-3);
    }

    :where(.empty-state, .true-empty, .empty-page) {
      min-height: 0;
      padding: var(--nv-space-8) var(--nv-space-4);
    }

    :where(.empty-state, .true-empty, .empty-page) > :where(b, h2, h3, h1) {
      font-size: var(--nv-fs-16);
    }

    :where(.notice, .legal-notice) {
      padding: var(--nv-space-3);
    }

    :where(.list-row) {
      padding-block: var(--nv-space-2);
    }

    :where(.page-header, .page-title) {
      gap: var(--nv-space-3);
      margin-bottom: var(--nv-space-4);
    }

    :where(.page-header, .page-title) > :where(div:first-child) {
      gap: var(--nv-space-1);
    }

    :where(.page-header .subtitle, .page-header p, .page-title p, .account-page-heading p) {
      font-size: var(--nv-fs-13);
      line-height: 1.5;
    }

    :where(.section-title, .account-section-heading) {
      margin: var(--nv-space-6) 0 var(--nv-space-3);
      font-size: var(--nv-fs-16);
    }

    /* r180: counts, Premium chips and menu labels read at the 12px floor on phones. */
    :where(.count, .chip-premium, .premium-pill, .menu-label) {
      font-size: var(--nv-fs-12);
    }

    /* Medals keep their gloss; the halo is calmer on small screens. */
    .nb-medal {
      box-shadow:
        0 0 0 1.5px rgba(255, 255, 255, .8),
        0 0 0 2.5px color-mix(in srgb, var(--nb-deep) 45%, transparent),
        inset 0 1px 1px rgba(255, 255, 255, .5),
        inset 0 -3px 6px color-mix(in srgb, var(--nb-deep) 70%, #000 10%),
        0 2px 6px -3px color-mix(in srgb, var(--nb-glow) 60%, transparent);
    }
  }
}

/* ---- Keyframes (global names, prefixed nv- / nb-) -------------------------- */
@keyframes nv-spin {
  to { transform: rotate(360deg); }
}

@keyframes nv-shimmer {
  from { background-position: 120% 0, 0 0; }
  to { background-position: -120% 0, 0 0; }
}

@keyframes nv-pulse {
  50% { opacity: .55; }
}

@keyframes nv-pop {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
}

@keyframes nv-indeterminate {
  from { transform: translateX(-110%); }
  to { transform: translateX(260%); }
}

@keyframes nbSweep { 0%, 70% { transform: translateX(-70%); } 85%, 100% { transform: translateX(70%); } }
@keyframes nbSweepOnce { from { transform: translateX(-70%); } to { transform: translateX(70%); } }
@keyframes nbPulse { 50% { transform: scale(1.14); } }
@keyframes nbFloat { 50% { transform: translateY(-2px); } }
@keyframes nbSpin { to { transform: rotate(360deg); } }
@keyframes nbSpark { 45% { transform: scale(1.12) rotate(-8deg); } 55% { transform: scale(1.08) rotate(8deg); } }
@keyframes nbBounce { 50% { transform: translateY(-3px); } 65% { transform: translateY(1px); } }
@keyframes nbOrbit { 50% { transform: rotate(14deg) translate(1px, -1px); } }
