/* Rasta Connect UI system. Public, local, shared by product/admin/brandbook.
 * Legacy owns layout; the system owns explicitly mapped control appearances.
 * Do not add per-screen colour overrides. Add a semantic role or documented size.
 */
@layer rc-legacy, rc-system;

@layer rc-system {
  /* Voice messages use a quiet icon; their waveform/player is the surface. */
  .voice-note > .voice-note-volume > .media-volume-trigger {
    color: var(--rc-muted); border-color: transparent; background: transparent;
    box-shadow: none; backdrop-filter: none;
  }
  .voice-note > .voice-note-volume:is(:hover, :focus-within, .is-volume-open) > .media-volume-trigger { color: var(--rc-ink); }
  /* The full contact dialog owns this layout. The chat's inline profile and
     the account/settings dialog keep their existing layout. */
  .profile-card.profile-v3.is-public.profile-contact {
    width: min(440px, calc(100vw - 32px));
    max-height: min(800px, calc(100dvh - 32px));
    background: var(--rc-surface);
  }
  .profile-contact::before { display: none; }
  .profile-v3.profile-contact .profile-hero {
    /* The hero owns its menus above the scrolling sibling body (layer 1).
       A dropdown's child z-index cannot escape an equal sibling context. */
    z-index: 2;
    min-height: 0; padding: 24px 20px 20px;
    display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "avatar" "identity" "actions";
    justify-items: center; align-items: start; gap: 12px; overflow: visible; background: none;
  }
  .profile-v3.profile-contact .profile-avatar-wrap {
    grid-area: avatar; align-self: center; width: 82px; height: 82px; min-height: 82px;
  }
  .profile-v3.profile-contact .profile-avatar-wrap :is(.avatar, img) {
    width: 82px; height: 82px; min-height: 82px; border-radius: 27px;
  }
  .profile-contact .profile-avatar-picture { padding: 0; border: 0; background: none; border-radius: 27px; cursor: pointer; }
  .profile-v3.profile-contact .profile-main {
    grid-area: identity; width: 100%; margin: 0; padding: 0; justify-items: center; text-align: center; gap: 5px;
  }
  .profile-v3.profile-contact :is(.profile-inline-identity, .profile-name-row) { width: 100%; justify-content: center; }
  .profile-v3.profile-contact .profile-name { max-width: 100%; font-size: 24px; text-align: center; }
  .profile-v3.profile-contact .profile-name-trigger { text-align: center; }
  .profile-contact .profile-inline-name-tools { flex: 0 0 auto; }
  .profile-v3.profile-contact .profile-v3-quick-region {
    grid-area: actions; position: relative; inset: auto; width: 100%; max-width: none; min-width: 0;
    align-self: auto; justify-self: stretch; gap: 8px; margin-top: 4px;
  }
  .profile-contact .profile-v3-quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .profile-contact .profile-v3-quick-action {
    width: 100%; min-width: 0; height: 64px; min-height: 64px; padding: 8px 3px;
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
    border: 1px solid var(--rc-border-control); border-radius: 13px;
    color: var(--rc-ink); background: var(--rc-surface-raised); box-shadow: none; font-size: 11px; line-height: 1.2;
  }
  .profile-contact .profile-v3-quick-action > svg { width: 21px; height: 21px; flex: 0 0 21px; }
  .profile-contact .profile-v3-quick-action > span { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
  .profile-contact [data-action="open-profile-dm"]:not(:disabled) { background: var(--rc-primary); color: var(--rc-primary-ink); border-color: var(--rc-primary); }
  .profile-contact .profile-v3-quick-action:disabled { color: var(--rc-muted); opacity: .6; }
  .profile-contact-more { position: relative; min-width: 0; }
  .profile-contact-more > summary { list-style: none; cursor: pointer; }
  .profile-contact-more > summary::-webkit-details-marker { display: none; }
  .profile-contact-more-menu {
    position: absolute; z-index: 12; top: calc(100% + 6px); right: 0; width: max-content; max-width: min(260px, calc(100vw - 40px));
    display: grid; padding: 5px; border: 1px solid var(--rc-border-control); border-radius: 12px;
    background: var(--rc-surface-raised); box-shadow: var(--rc-shadow-dialog);
  }
  .profile-contact-more-menu button {
    min-height: 44px; padding: 9px 10px; display: flex; align-items: center; gap: 9px;
    border: 0; border-radius: 8px; color: var(--rc-ink); background: transparent; font: inherit; text-align: left; cursor: pointer;
  }
  .profile-contact-more-menu button:hover { background: var(--rc-surface-hover); }
  .profile-contact-more-menu svg { width: 18px; height: 18px; flex: 0 0 18px; }
  .contact-profile-notifications {
    position: fixed; inset: auto; margin: 0; padding: 0;
    width: min(336px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
    border: 1px solid var(--rc-border-control); border-radius: var(--rc-radius-panel);
    background: var(--rc-surface-raised); color: var(--rc-ink); box-shadow: var(--rc-shadow-dialog);
    overflow: hidden;
  }
  .contact-profile-notifications:popover-open { display: grid; grid-template-rows: auto minmax(0, 1fr); }
  /* Fallback is the profile's child surface: above its modal backdrop (70),
     below the media viewer (120); native popovers use the browser top layer. */
  .contact-profile-notifications.is-fallback { display: grid; grid-template-rows: auto minmax(0, 1fr); z-index: 71; }
  .contact-profile-notifications > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--rc-border); }
  .contact-profile-notifications > header > div { display: grid; min-width: 0; gap: 3px; }
  .contact-profile-notifications > header small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--rc-muted); }
  .contact-profile-notifications-body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 6px 10px 10px; }
  .contact-profile-notifications .setting-row { min-height: 44px; }
  .contact-profile-notifications .notification-local-controls { padding: 0; }
  .contact-profile-notifications .notification-scope-hint { margin: 8px 2px 2px; }
  .profile-v3.profile-contact .profile-content { padding: 0 18px 18px; background: none; scrollbar-gutter: auto; }
  .profile-contact .profile-public { width: 100%; display: grid; gap: 0; }
  .profile-contact-materials { padding-block: 15px 12px; border-top: 1px solid var(--rc-border); }
  .profile-contact-materials h3 { margin: 0 0 8px; color: var(--rc-muted); font-size: 12px; font-weight: 600; }
  .profile-contact-material-row {
    width: 100%; min-width: 0; min-height: 48px; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 14px;
    align-items: center; gap: 11px; padding: 8px 2px; border: 0; border-radius: 8px;
    background: transparent; color: var(--rc-ink); font: inherit; text-align: left; cursor: pointer;
  }
  .profile-contact-material-row > svg { width: 20px; height: 20px; color: var(--rc-muted); }
  .profile-contact-material-row > svg:last-child { width: 14px; height: 14px; }
  .profile-contact-material-row > small { color: var(--rc-muted); font-variant-numeric: tabular-nums; }
  .profile-contact-material-row:hover:not(:disabled) { background: var(--rc-surface-hover); }
  .profile-contact-material-row:disabled { opacity: .55; cursor: default; }
  .profile-contact-material-note { margin: 6px 0 0; color: var(--rc-muted); font-size: 12px; }
  .profile-contact.has-contact-materials:not(.contact-materials-back-preview) > :is(.profile-hero, .profile-content, .profile-close) { visibility: hidden; pointer-events: none; }
  .contact-profile-materials {
    position: absolute; inset: 0; z-index: 3; min-height: 0;
    display: grid; grid-template-rows: auto minmax(0, 1fr);
    background: var(--rc-surface); border-radius: inherit; overflow: hidden;
  }
  .contact-profile-materials > header { grid-area: 1 / 1; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--rc-border); }
  .contact-profile-materials > header > div { display: grid; min-width: 0; gap: 3px; }
  .contact-profile-materials > header :is(strong, small) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .contact-profile-materials > header small { color: var(--rc-muted); }
  .contact-profile-materials > .chat-materials-body { grid-area: 2 / 1; height: auto; min-width: 0; min-height: 0; padding: 12px; overflow: auto; overflow-anchor: none; touch-action: pan-y; overscroll-behavior: contain; }
  .contact-profile-materials.has-link-search { grid-template-rows: auto auto minmax(0, 1fr); }
  .contact-profile-materials > .contact-profile-link-search { grid-area: 2 / 1; margin: 10px 12px 0; }
  .contact-profile-materials.has-link-search > .chat-materials-body { grid-area: 3 / 1; }
  @media (min-width: 961px) and (min-height: 521px) {
    .profile-card.profile-v3.is-public.profile-contact.has-contact-materials { height: var(--contact-material-height); max-height: calc(100dvh - 32px); }
  }
  .contact-profile-materials [data-profile-material-id] { min-width: 0; }
  .contact-profile-materials .chat-material-gif-card { height: 100%; }
  .contact-profile-materials .chat-material-media-card { width: 100%; }
  .profile-contact .profile-shared-workspaces { border: 0; border-top: 1px solid var(--rc-border); border-radius: 0; background: none; box-shadow: none; }
  .profile-contact .profile-shared-workspaces-head { padding: 14px 0 10px; background: none; }
  .profile-contact .profile-shared-workspaces-title > span { display: none; }
  .profile-contact .profile-shared-workspaces-head strong { color: var(--rc-muted); font-size: 12px; }
  .profile-contact .profile-shared-workspaces-head small { display: none; }
  .profile-contact .profile-shared-workspace-list { padding: 0; gap: 3px; }
  .profile-contact .profile-shared-workspace { min-height: 44px; padding: 5px 0; border: 0; background: none; box-shadow: none; }
  @media (max-width: 820px) {
    .profile-card.profile-v3.is-public.profile-contact { width: 100%; height: var(--app-height, 100dvh); max-height: var(--app-height, 100dvh); }
    .profile-v3.profile-contact .profile-hero { padding-top: max(16px, var(--app-safe-top, 0px)); }
  }
  @media (max-height: 520px) and (min-width: 600px) {
    .profile-card.profile-v3.is-public.profile-contact { width: min(560px, calc(100vw - 24px)); height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); place-self: center; border: 1px solid var(--rc-border-control); border-radius: var(--rc-radius-dialog); }
    .profile-v3.profile-contact .profile-hero { grid-template-columns: 70px minmax(0, 1fr); grid-template-areas: "avatar identity" "actions actions"; padding: 14px 20px 12px; gap: 10px 14px; }
    .profile-v3.profile-contact .profile-avatar-wrap,
    .profile-v3.profile-contact .profile-avatar-wrap :is(.avatar, img) { width: 64px; height: 64px; min-height: 64px; border-radius: 22px; }
    .profile-contact .profile-v3-quick-action { height: 52px; min-height: 52px; gap: 3px; padding: 4px 3px; }
    .profile-v3.profile-contact .profile-main { padding-right: 36px; }
  }
}

:root {
  --rc-bg: #101510;
  --rc-bg-deep: #0d120e;
  --rc-surface: #171e18;
  --rc-surface-raised: #202a22;
  /* Navigation is neutral graphite, not a branded green form surface. */
  --rc-navigation-surface: #1c1d1b;
  --rc-surface-hover: #2b372d;
  --rc-surface-pressed: #19231c;
  --rc-ink: #f0f0e8;
  --rc-muted: #a3ad9f;
  --rc-border: #b6cfb31a;
  --rc-border-control: #b6cfb32b;
  --rc-border-hover: #b6cfb34d;
  --rc-accent: #a6d6a8;
  --rc-primary: #a6d6a8;
  --rc-primary-ink: #17281b;
  --rc-primary-hover: #b8e2b8;
  --rc-primary-pressed: #8fbe93;
  --rc-danger: #e1aaa2;
  --rc-danger-surface: #362421;
  --rc-danger-hover: #482d29;
  --rc-danger-pressed: #30211f;
  --rc-danger-ink: #fff;
  --rc-danger-border: #df9c9230;
  --rc-warning: #d8bd7b;
  --rc-success: #a6d6a8;
  --rc-info: #9fbfd5;
  /* Browser-bound private conversations: a quiet, distinct encrypted surface. */
  --rc-private: #cec0ef;
  --rc-private-surface: #292535;
  --rc-private-raised: #393147;
  --rc-private-border: #c8afe15c;
  --rc-field: #0f1510;
  --rc-placeholder: #929d8f;
  --rc-selected: #a6d6a81a;
  --rc-switch-off: #353e34;
  --rc-switch-on: #638e68;
  --rc-switch-thumb: #e6e9df;
  --rc-radius-control: 12px;
  --rc-radius-panel: 20px;
  --rc-radius-dialog: 24px;
  --rc-radius-small: 8px;
  --rc-control-size: 44px;
  --rc-control-compact: 34px;
  --rc-icon-size: 18px;
  --rc-icon-stroke: 1.8;
  --rc-space-1: 4px;
  --rc-space-2: 8px;
  --rc-space-3: 12px;
  --rc-space-4: 16px;
  --rc-space-5: 24px;
  --rc-space-6: 32px;
  --rc-motion-fast: 140ms;
  --rc-focus-width: 2px;
  --rc-focus-offset: 3px;
  --rc-disabled-opacity: .38;
  --rc-shadow-dialog: 0 24px 80px #0006;
  --rc-shadow-widget: 0 8px 24px #0005, 0 2px 6px #0003;
  --rc-backdrop: #050b07bb;
  /* Compatibility aliases: one palette while layouts migrate incrementally. */
  --bg: var(--rc-bg);
  --text: var(--rc-ink);
  --ink: var(--rc-ink);
  --muted: var(--rc-muted);
  --soft: #c4ccc0;
  --panel: var(--rc-surface);
  --panel-solid: var(--rc-surface);
  --panel-2: var(--rc-surface-raised);
  --panel-3: var(--rc-surface-raised);
  --line: var(--rc-border);
  --line-strong: var(--rc-border-hover);
  --border: var(--rc-border);
  --radius: var(--rc-radius-control);
  --admin-bg: var(--rc-bg);
  --admin-bg-deep: var(--rc-bg-deep);
  --admin-panel: var(--rc-surface);
  --admin-panel-soft: var(--rc-surface);
  --admin-panel-raised: var(--rc-surface-raised);
  --admin-text: var(--rc-ink);
  --admin-soft: var(--soft);
  --admin-muted: var(--rc-muted);
  --admin-line: var(--rc-border);
  --admin-line-strong: var(--rc-border-hover);
  --admin-radius: var(--rc-radius-panel);
  --admin-shadow: var(--rc-shadow-dialog);
}

@layer rc-system {
  /* Same composer surface and transport control in human and RastorG chats. */
  .composer-input, .rastorg-composer textarea {
    color: var(--rc-ink); background: var(--rc-field); border: 1px solid var(--rc-border-control);
    border-radius: var(--mobile-composer-radius, var(--rc-radius-control));
    font-size: var(--rc-text-body); font-weight: var(--rc-weight-regular); line-height: 1.35;
  }
  .composer-input:focus, .rastorg-composer textarea:focus {
    background: var(--rc-field); border-color: var(--rc-border-hover); outline: none; box-shadow: none;
  }
  .rastorg-composer textarea::placeholder { color: var(--rc-placeholder); opacity: 1; }
  .button.voice-local-mic.microphone-state-off:not(:disabled) {
    --rc-button-bg: var(--rc-danger-surface); --rc-button-hover: var(--rc-danger-hover);
    --rc-button-pressed: var(--rc-danger-pressed); --rc-button-ink: var(--rc-danger-ink);
    --rc-button-border: var(--rc-danger-border);
  }
  .rastorg-composer .rastorg-composer-submit { border-radius: 50%; }
  .rastorg-composer :is(.rastorg-composer-expand, .rastorg-composer-tools-toggle) {
    --rc-button-bg: transparent; --rc-button-border: transparent; --rc-button-ink: var(--rc-muted);
    box-shadow: none;
  }
  .profile-v3 .profile-name { min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .profile-v3 .profile-name-trigger {
    display: block; width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 4px;
    color: inherit; background: none; box-shadow: none; font: inherit; letter-spacing: inherit; text-align: left; cursor: pointer;
  }
  .profile-name-trigger > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .profile-name-trigger[aria-disabled="true"] { cursor: default; }
  .profile-v3 .profile-avatar-wrap { align-self: start; }
  .profile-v3 .profile-hero:has(.profile-full-name) { z-index: 8; }
  .profile-full-name {
    position: absolute; z-index: 10; top: calc(100% - 8px); left: 16px; right: auto;
    width: max-content; max-width: min(420px, calc(100% - 24px)); box-sizing: border-box;
    padding: 12px 16px; border: 1px solid var(--rc-border-control); border-radius: var(--rc-radius-control);
    background: var(--rc-surface-raised); color: var(--rc-ink); box-shadow: var(--rc-shadow-dialog);
    font-size: var(--rc-text-body); font-weight: var(--rc-weight-regular); line-height: 1.45;
    white-space: normal; overflow-wrap: anywhere; max-height: 35dvh; overflow: auto; user-select: text;
  }
  :is(.workspace-settings-backdrop, .emoji-picker, .pulse-center-layer, .pulse-popover-layer, .personal-call-preflight-layer):is(.mobile-swipe-dragging, .mobile-swipe-settling) {
    transform: translate3d(var(--mobile-swipe-x, 0px), 0, 0); will-change: transform;
  }
  :is(.workspace-settings-backdrop, .emoji-picker, .pulse-center-layer, .pulse-popover-layer, .personal-call-preflight-layer).mobile-swipe-dragging { animation: none; transition: none; }
  .emoji-picker :is(.emoji-choice, .klipy-choice), .emoji-picker, .pulse-center, .pulse-popover { touch-action: pan-y; }
  .personal-dashboard, .personal-call-preflight, .workspace-settings-card,
  .workspace-mobile-overview, .workspace-settings-content { touch-action: pan-y; }
  .personal-call-shell-compact :is(.personal-call-compact-main, .personal-call-compact-video-stage) { touch-action: none; cursor: grab; }
  .personal-call-shell-compact :is(.personal-call-compact-main, .personal-call-compact-video-stage):active { cursor: grabbing; }
  :is(.workspace-settings-backdrop, .emoji-picker, .pulse-center-layer, .pulse-popover-layer, .personal-call-preflight-layer).mobile-swipe-settling { transition: transform 180ms ease; }
  @media (prefers-reduced-motion: reduce) {
    :is(.workspace-settings-backdrop, .emoji-picker, .pulse-center-layer, .pulse-popover-layer, .personal-call-preflight-layer).mobile-swipe-settling { transition-duration: 1ms; }
  }
  .rasta-video-mobile-download { display: none; }
  /* A back preview is a noninteractive sibling, never the active dialog. */
  .mobile-back-preview { z-index: 0; pointer-events: none; animation: none; }
  .mobile-back-foreground { z-index: 1; }
  .mobile-back-preview :is(.profile-card, .workspace-settings-card) { animation: none; }
  @media (max-width: 380px) {
    .attachment-viewer-backdrop.is-video .attachment-viewer-top .attachment-viewer-title {
      margin-top: 52px; max-width: 100%;
    }
  }
  @media (max-width: 820px), (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
    .attachment-viewer-close { display: none; }
    .attachment-viewer-top { pointer-events: none; }
    .attachment-viewer-title { min-width: 0; max-width: calc(100% - 52px); align-items: center; justify-content: center; }
    .attachment-viewer-backdrop.is-video .attachment-viewer-title {
      width: max-content; max-width: calc(100% - 200px);
      flex-direction: row; white-space: nowrap;
    }
    .attachment-viewer-backdrop.is-video .attachment-viewer-actions { display: none; }
    .attachment-viewer-actions .button.icon { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
    .attachment-viewer-backdrop.is-video .attachment-viewer-frame { width: 100%; height: 100%; max-width: none; max-height: none; }
    .attachment-viewer-backdrop .rasta-video-player { border: 0; border-radius: 0; box-shadow: none; }
    .attachment-viewer-backdrop .rasta-video-controls {
      inset: 0; width: auto; height: auto; padding: 0;
      background: none; border: 0; box-shadow: none; transform: none; pointer-events: none;
    }
    .attachment-viewer-backdrop .rasta-video-toolbar {
      position: absolute;
      inset: max(9px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left));
      height: auto; display: grid; gap: 6px;
      grid-template-columns: minmax(0, 1fr) repeat(4, 44px);
      grid-template-rows: 44px 1fr 24px; pointer-events: none;
    }
    .attachment-viewer-backdrop .rasta-video-toolbar > :is(.rasta-video-volume, .rasta-video-more, .fullscreen, .rasta-video-mobile-download) {
      position: relative; inset: auto; grid-row: 1; pointer-events: auto;
      width: 44px; min-width: 44px; height: 44px; min-height: 44px; margin: 0;
    }
    .attachment-viewer-backdrop .rasta-video-volume { grid-column: 2; }
    .attachment-viewer-backdrop .rasta-video-more { grid-column: 3; display: block; }
    .attachment-viewer-backdrop .rasta-video-toolbar > .fullscreen { grid-column: 4; }
    .attachment-viewer-backdrop .rasta-video-mobile-download { grid-column: 5; display: inline-flex; }
    .attachment-viewer-backdrop .rasta-video-toolbar :is(.rasta-video-button, .media-volume-trigger, .rasta-video-mobile-download) {
      width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0;
      border-radius: 999px; border: 1px solid var(--media-overlay-border);
      color: var(--media-overlay-ink); background: var(--media-overlay-surface); box-shadow: none;
    }
    .attachment-viewer-backdrop .rasta-video-toolbar :is(.rasta-video-button, .media-volume-trigger, .rasta-video-mobile-download):hover {
      background: var(--media-overlay-hover);
    }
    .attachment-viewer-backdrop .rasta-video-toolbar > :is([data-video-control="toggle"], .rasta-video-speed, .pip, .rasta-video-toolbar-spacer) { display: none; }
    .attachment-viewer-backdrop .rasta-video-time { position: static; grid-column: 1 / -1; grid-row: 3; align-self: end; }
    .attachment-viewer-backdrop .rasta-video-timeline { position: absolute; left: 12px; right: 12px; bottom: max(8px, env(safe-area-inset-bottom)); height: 22px; pointer-events: auto; }
    .attachment-viewer-backdrop .rasta-video-more-menu { right: -100px; max-width: calc(100vw - 24px); }
    #messages :is(.klipy-message-media, .message-media, .circle-shell) { touch-action: pan-y pinch-zoom; }
  }
  .space-panel, .people-panel, .space-header { background: var(--rc-navigation-surface); }
  .music-float-header > strong {
    font-size: var(--rc-text-player-meta);
    font-weight: var(--rc-weight-medium);
    letter-spacing: .08em;
    color: var(--rc-muted);
  }
  .music-float-header > strong em { color: var(--rc-accent); }
  .music-float-status {
    font-size: var(--rc-text-player-meta);
    font-weight: var(--rc-weight-regular);
    letter-spacing: normal;
    text-transform: none;
    color: var(--rc-muted);
    text-overflow: ellipsis;
  }
  .music-float-footer { grid-template-columns: minmax(0, 1fr) auto; }
  .music-float-footer > small { grid-column: 2; }
  .rc-button { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-size: var(--rc-text-control); cursor: pointer; text-decoration: none; }
  .rc-button.icon { width: var(--rc-control-size); height: var(--rc-control-size); min-width: var(--rc-control-size); min-height: var(--rc-control-size); padding: 0; }
  .rc-button.compact { min-height: var(--rc-control-compact); padding: var(--rc-space-1) var(--rc-space-2); }
  /* Buttons: legacy names are adapters, not independent implementations.
   * Composer send/recording and media transport keep their specialised geometry.
   */
  :is(.rc-button, .button, .admin-button, .admin-icon-button, .ds-button):not(.send, .chat-send-control) {
    --rc-button-bg: var(--rc-surface-raised);
    --rc-button-hover: var(--rc-surface-hover);
    --rc-button-pressed: var(--rc-surface-pressed);
    --rc-button-ink: var(--rc-ink);
    --rc-button-border: var(--rc-border-control);
    color: var(--rc-button-ink);
    background: var(--rc-button-bg);
    border: 1px solid var(--rc-button-border);
    border-radius: var(--rc-radius-control);
    box-shadow: none;
    text-shadow: none;
    font-weight: var(--rc-weight-semibold);
    line-height: var(--rc-leading-ui);
    gap: var(--rc-space-2);
    transition: background var(--rc-motion-fast), border-color var(--rc-motion-fast), color var(--rc-motion-fast);
  }
  :is(.rc-button, .button, .admin-button, .ds-button):not(.icon, .ds-icon, .tiny, .compact, .send, .chat-send-control) {
    min-height: var(--rc-control-size);
    padding-inline: var(--rc-space-4);
  }
  :is(.rc-button, .button, .admin-button, .admin-icon-button, .ds-button):not(.send, .chat-send-control):hover:not(:disabled, [aria-disabled="true"]) {
    color: var(--rc-button-ink);
    background: var(--rc-button-hover);
    border-color: var(--rc-border-hover);
    box-shadow: none;
    transform: none;
    filter: none;
  }
  :is(.rc-button, .button, .admin-button, .admin-icon-button, .ds-button):not(.send, .chat-send-control):active:not(:disabled, [aria-disabled="true"]) {
    background: var(--rc-button-pressed);
    color: var(--rc-button-ink);
    transform: none;
  }
  .ds-button[data-state="hover"] { background: var(--rc-button-hover); }
  .ds-button[data-state="pressed"] { background: var(--rc-button-pressed); }
  .ds-button[data-state="focus"] { outline: var(--rc-focus-width) solid var(--rc-accent); outline-offset: var(--rc-focus-offset); }
  :is(.rc-button, .button, .admin-button, .ds-button):is(.primary, .ds-primary, [data-variant="primary"]):not(.send, .chat-send-control) {
    --rc-button-bg: var(--rc-primary);
    --rc-button-hover: var(--rc-primary-hover);
    --rc-button-pressed: var(--rc-primary-pressed);
    --rc-button-ink: var(--rc-primary-ink);
    --rc-button-border: transparent;
  }
  :is(.rc-button, .button, .admin-button):is(.active, [aria-pressed="true"]):not(.primary, .danger, .danger-soft, .send, .chat-send-control) {
    --rc-button-bg: var(--rc-selected);
    --rc-button-ink: var(--rc-accent);
    --rc-button-border: var(--rc-accent);
  }
  :is(.rc-button, .button, .admin-button, .ds-button):is(.danger, .danger-soft, .self-delete, .profile-avatar-delete, .ds-danger, [data-variant="danger"]) {
    --rc-button-bg: var(--rc-danger-surface);
    --rc-button-hover: var(--rc-danger-hover);
    --rc-button-pressed: var(--rc-danger-pressed);
    --rc-button-ink: var(--rc-danger-ink);
    --rc-button-border: var(--rc-danger-border);
  }
  :is(.rc-button, .button, .admin-button, .admin-icon-button, .ds-button):not(.send, .chat-send-control) > svg:not(.rasta-send-mark) {
    color: inherit;
    stroke-width: var(--rc-icon-stroke);
    flex-shrink: 0;
  }
  :is(.rc-button, .button, .admin-button, .admin-icon-button, .ds-button):disabled {
    opacity: var(--rc-disabled-opacity);
    cursor: not-allowed;
  }
  :is(.rc-button, .button, .admin-button, .ds-button)[aria-busy="true"] {
    opacity: .72;
    cursor: wait;
  }
  /* Composer emoji is quiet until its picker is open (ordinary and secret chat). */
  .attachment-viewer-actions .button.icon {
    --rc-button-bg: var(--media-overlay-surface);
    --rc-button-hover: var(--media-overlay-hover);
    --rc-button-pressed: var(--media-overlay-hover);
    --rc-button-ink: var(--media-overlay-ink);
    --rc-button-border: var(--media-overlay-border);
    border-radius: 999px;
  }
  .attachment-viewer-actions .button.icon:hover {
    border-color: var(--media-overlay-border);
  }
  .button.icon.composer-emoji {
    --rc-button-bg: transparent;
    --rc-button-hover: transparent;
    --rc-button-pressed: transparent;
    --rc-button-border: transparent;
    --rc-button-ink: var(--rc-muted);
  }
  .button.icon.composer-emoji:hover { border-color: transparent; }
  .button.icon.composer-emoji:is(.active, [aria-expanded="true"]) {
    --rc-button-bg: var(--rc-selected);
    --rc-button-hover: var(--rc-selected);
    --rc-button-pressed: var(--rc-selected);
    --rc-button-ink: var(--rc-accent);
    --rc-button-border: transparent;
  }
  :is(button, a, input, textarea, select, [tabindex]):focus-visible {
    outline: var(--rc-focus-width) solid var(--rc-accent);
    outline-offset: var(--rc-focus-offset);
  }
  /* Pointer-opened menu owns focus; visible focus belongs to its commands. */
  .message-menu[data-message-menu-id][tabindex="-1"]:focus-visible { outline: none; }
  /* Form fields only: never restyle contenteditable composers, range sliders,
   * file inputs, native checkbox geometry or media controls through this adapter. */
  :is(.input, .textarea):not(.composer-input),
  .admin-field :is(input:not([type="checkbox"], [type="range"], [type="file"], [type="color"]), textarea),
  .ds-field input {
    background: var(--rc-field);
    color: var(--rc-ink);
    border: 1px solid var(--rc-border-control);
    border-radius: var(--rc-radius-control);
    box-shadow: none;
  }
  :is(.input, .textarea):not(.composer-input)::placeholder,
  .admin-field :is(input, textarea)::placeholder,
  .ds-field input::placeholder { color: var(--rc-placeholder); opacity: 1; }
  :is(.input, .textarea):not(.composer-input):focus,
  .admin-field :is(input, textarea):focus,
  .ds-field input:focus { border-color: var(--rc-accent); box-shadow: none; }
  :is(.input, .textarea):is(.has-error, [aria-invalid="true"]),
  .admin-field [aria-invalid="true"], .ds-field input[aria-invalid="true"] { border-color: var(--rc-danger); }
  :is(.input, .textarea):disabled, .ds-field input:disabled { opacity: .45; cursor: not-allowed; }
  :is(.field-error, .ds-field-error) { color: var(--rc-danger); font-weight: var(--rc-weight-regular); }
  .field-error { white-space: normal; overflow-wrap: anywhere; text-transform: none; }
  .field { text-transform: none; font-weight: var(--rc-weight-medium); }
  /* A trailing action owns its actual width, never a legacy 34px grid track. */
  .profile-setting-head { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .notification-profile-toggle, .profile-quick-reaction-current {
    width: var(--rc-control-size);
    height: var(--rc-control-size);
    min-width: var(--rc-control-size);
    min-height: var(--rc-control-size);
    justify-self: end;
  }
  .profile-setting-head > button:focus-visible { outline-offset: -3px; }
  .notification-platform-hint { overflow-wrap: anywhere; }
  /* Every select already uses the shared custom-select behaviour. */
  .rasta-custom-select-trigger {
    color: var(--rc-ink);
    background: var(--rc-field);
    border: 1px solid var(--rc-border-control);
    border-radius: var(--rc-radius-control);
    box-shadow: none;
  }
  .rasta-custom-select-trigger:hover,
  .rasta-custom-select.open .rasta-custom-select-trigger {
    background: var(--rc-surface-raised);
    border-color: var(--rc-accent);
  }
  .rasta-custom-select-panel { background: var(--rc-surface); border-color: var(--rc-border-hover); border-radius: var(--rc-radius-control); }
  .rasta-custom-select-option { color: var(--rc-ink); }
  .rasta-custom-select-option:is(:hover, .active, [aria-selected="true"]) { background: var(--rc-selected); color: var(--rc-ink); }
  /* Context menus share appearance, but remain compact action lists, not forms. */
  :is(.message-menu, .chat-material-menu, .header-menu, .personal-music-track-menu,
      .personal-video-menu, .personal-files-menu) {
    background: var(--rc-surface);
    border-color: var(--rc-border-hover);
    border-radius: var(--rc-radius-panel);
    box-shadow: var(--rc-shadow-widget);
    color: var(--rc-ink);
  }
  :is(.message-menu-item, .header-menu > button, .personal-music-track-menu button,
      .personal-video-menu button, .personal-files-menu button) {
    color: var(--rc-ink);
    border-radius: var(--rc-radius-control);
    background: transparent;
    box-shadow: none;
    font-weight: var(--rc-weight-medium);
  }
  :is(.message-menu-item, .header-menu > button, .personal-music-track-menu button,
      .personal-video-menu button, .personal-files-menu button):hover:not(:disabled) {
    background: var(--rc-selected);
    color: var(--rc-ink);
  }
  :is(.message-menu-item, .header-menu > button, .personal-music-track-menu button,
      .personal-video-menu button, .personal-files-menu button):active { transform: none; }
  :is(.message-menu-item, .header-menu > button, .personal-music-track-menu button,
      .personal-video-menu button, .personal-files-menu button).danger {
    color: var(--rc-danger-ink);
    background: var(--rc-danger-surface);
  }
  .message-menu-item.danger .message-menu-icon { color: inherit; }
  /* Message actions can pair their command surface with a reaction rail. */
  .message-menu.message-actions-popover {
    width: min(244px, calc(100vw - 20px));
    padding: 0;
    gap: 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    contain: layout style;
    pointer-events: none;
  }
  .message-menu.message-actions-popover:not(:has(> .message-menu-reaction-surface)) {
    width: max-content;
    min-width: min(180px, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
  }
  .message-actions-popover::after { display: none; }
  .message-actions-popover .message-menu-actions,
  .message-actions-popover .message-menu-reaction-surface {
    min-width: 0;
    padding: 4px;
    border: 1px solid var(--rc-border);
    background: var(--rc-surface);
  }
  .message-actions-popover .message-menu-actions {
    display: grid;
    width: max-content;
    max-width: 100%;
    min-width: min(180px, 100%);
    justify-self: center;
    gap: 0;
    border-radius: 14px;
  }
  .message-actions-popover.is-ready > :is(.message-menu-actions, .message-menu-reaction-surface) { pointer-events: auto; }
  .message-actions-popover .message-menu-page { gap: 0; }
  .message-actions-popover .message-menu-item {
    min-width: 0;
    min-height: 36px;
    padding: 6px 10px;
    gap: 12px;
    border-radius: 9px;
    font-size: var(--rc-text-control, 14px);
    line-height: 20px;
    font-weight: var(--rc-weight-medium);
    background: transparent;
  }
  .message-actions-popover.is-compact .message-menu-item { min-height: 40px; }
  .message-actions-popover .message-menu-item > span:last-child { min-width: 0; overflow-wrap: anywhere; }
  .message-actions-popover .message-menu-item:is(:hover, :focus-visible) { background: var(--rc-selected); }
  .message-actions-popover .message-menu-item.danger:is(:hover, :focus-visible) { background: var(--rc-danger-surface); }
  .message-actions-popover .message-menu-icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--rc-muted);
  }
  .message-actions-popover .message-menu-icon svg { width: 20px; height: 20px; }
  .message-actions-popover .message-menu-item.danger .message-menu-icon { color: inherit; background: transparent; }
  .message-actions-popover .message-menu-divider { margin: 4px 8px; background: var(--rc-border); }
  .message-actions-popover .message-menu-reaction-surface { border-radius: 22px; }
  .message-actions-popover .reaction-divider { display: none; }
  .message-actions-popover .message-menu-reaction-picker { padding: 0; }
  .message-actions-popover .message-menu-reactions { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; }
  .message-actions-popover .message-menu-reactions-more { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .message-actions-popover .message-menu-reaction { width: 100%; height: 36px; font-size: 22px; line-height: 1; }
  /* Microphone preview is a media action, not form confirmation (CS-04). */
  .button.primary.voice-preflight-action:not(.send, .chat-send-control) {
    --rc-button-bg: var(--rc-selected);
    --rc-button-hover: var(--rc-surface-raised);
    --rc-button-pressed: var(--rc-surface-pressed);
    --rc-button-ink: var(--rc-accent);
    --rc-button-border: var(--rc-border-hover);
  }
  :is(.personal-music-search, .personal-video-search, .personal-files-search, .personal-music-picker-search) {
    background: var(--rc-field);
    color: var(--rc-muted);
    border: 1px solid var(--rc-border-control);
    border-radius: var(--rc-radius-control);
    box-shadow: none;
  }
  :is(.personal-music-search, .personal-video-search, .personal-files-search, .personal-music-picker-search):focus-within { border-color: var(--rc-border-control); }
  :is(.personal-music-search, .personal-video-search, .personal-files-search, .personal-music-picker-search) input { color: var(--rc-ink); background: transparent; }
  :is(.personal-music-search, .personal-video-search, .personal-files-search, .personal-music-picker-search) input::placeholder { color: var(--rc-placeholder); }
  /* Search has one quiet surface, including while typing. Keep focus rings on
   * buttons and other keyboard controls; do not frame the nested text input. */
  :is(.klipy-search, .contact-search-box, .workspace-search, .secret-search-box,
      .personal-music-search, .personal-video-search, .personal-files-search,
      .personal-music-picker-search, .personal-share-search, .audiobook-library-search,
      .audiobook-chapter-search, .message-search-control, .message-search-inline-control,
      .message-search-mobile-control, .message-forward-search) {
    outline: none; box-shadow: none; border-color: var(--rc-border-control); background: var(--rc-field);
  }
  input[type="search"]:is(:focus, :focus-visible):not([aria-invalid="true"]) {
    outline: none; box-shadow: none; border-color: var(--rc-border-control);
  }
  /* Inline channel creation has one surface, not a second frame around text. */
  .channel-create:not(.has-error) { border-color: var(--rc-border-control); }
  .channel-create:not(.has-error):focus-within { border-color: var(--rc-border-hover); }
  .channel-create input:is(:focus, :focus-visible) { outline: none; box-shadow: none; }
  /* Topic titles need a quiet field focus, not the global ring plus legacy glow. */
  .rastorg-topic-create input[name="topicTitle"]:is(:focus, :focus-visible) {
    outline: none;
    box-shadow: none;
    border-color: var(--rc-border-hover);
  }
  .switch, .ds-switch { width: 42px; height: 24px; background: var(--rc-switch-off); }
  .switch::after { width: 18px; height: 18px; top: 3px; left: 3px; }
  .switch.active::after { transform: translateX(18px); }
  .switch.active, .ds-switch:checked { background: var(--rc-switch-on); }
  .switch::after, .ds-switch::before { background: var(--rc-switch-thumb); }
  /* Fullscreen sheets keep their existing mobile edge-to-edge silhouette. */
  :is(.platform-modal, .avatar-delete-dialog, .personal-music-dialog, .personal-files-dialog,
      .personal-share-dialog, .message-forward-dialog, .rastorg-dialog,
      .rastorg-topic-kb-dialog, .rastorg-image-limit-dialog, .secret-modal, .admin-dialog, .ds-dialog) {
    background: var(--rc-surface);
    color: var(--rc-ink);
    border-color: var(--rc-border-hover);
    box-shadow: var(--rc-shadow-dialog);
  }
  @media (min-width: 821px) {
    :is(.platform-modal, .avatar-delete-dialog, .personal-music-dialog, .personal-files-dialog,
        .personal-share-dialog, .message-forward-dialog, .rastorg-dialog,
        .rastorg-topic-kb-dialog, .rastorg-image-limit-dialog, .secret-modal, .admin-dialog, .ds-dialog) { border-radius: var(--rc-radius-dialog); }
  }
  :is(.avatar-delete-backdrop, .personal-music-dialog-backdrop, .personal-share-backdrop,
      .message-forward-backdrop, .rastorg-dialog-backdrop, .rastorg-topic-kb-backdrop, .admin-dialog-backdrop) {
    background: var(--rc-backdrop);
    backdrop-filter: blur(4px);
  }
  :is(.chat-material-tabs, .stream-settings-panel .quality-tabs, .ds-tabs) {
    background: var(--rc-surface);
    border-bottom: 1px solid var(--rc-border);
    border-radius: 0;
    gap: 0;
  }
  :is(.chat-material-tabs, .stream-settings-panel .quality-tabs, .ds-tabs) > button {
    min-height: 48px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--rc-muted);
    background: transparent;
    box-shadow: none;
    font-size: var(--rc-text-control);
    font-weight: var(--rc-weight-semibold);
    gap: var(--rc-space-2);
  }
  :is(.chat-material-tabs, .stream-settings-panel .quality-tabs, .ds-tabs) > button:is(.active, [aria-selected="true"]) {
    color: var(--rc-accent);
    border-bottom-color: var(--rc-accent);
    background: var(--rc-selected);
  }
  :is(.chat-material-tabs, .stream-settings-panel .quality-tabs, .ds-tabs) > button:focus-visible { outline-offset: -5px; }
  :is(.chat-material-tabs, .stream-settings-panel .quality-tabs, .ds-tabs) > button > svg { width: var(--rc-icon-size); height: var(--rc-icon-size); stroke-width: var(--rc-icon-stroke); }
  /* Music and audiobook docks are one floating widget; no playback DOM changes. */
  @media (max-width: 820px), (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
    .mobile-music-card.music-dock {
      width: calc(100% - 24px);
      margin: 10px 12px 12px;
      padding: 12px;
      min-height: 0;
      border: 1px solid var(--rc-border-hover);
      border-radius: var(--rc-radius-panel);
      background: var(--rc-surface);
      box-shadow: var(--rc-shadow-widget);
      grid-template-columns: repeat(5, minmax(0, 1fr));
      grid-template-rows: auto 44px;
      grid-template-areas: "play main main main close" "prev next volume share car";
      gap: 8px 4px;
      overflow: visible;
    }
    .mobile-music-card .music-dock-main {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto 16px auto;
      gap: 0;
      min-width: 0;
    }
    .mobile-music-card .music-dock-head { grid-area: 1 / 1; gap: 6px; }
    .mobile-music-card .music-dock-head > span { display: none; }
    .mobile-music-card .music-dock-head strong { font-size: var(--rc-text-control); font-weight: var(--rc-weight-semibold); line-height: 1.4; }
    .mobile-music-card .music-dock-main > .music-dock-progress { grid-area: 2 / 1; margin: 0; }
    .mobile-music-card .music-dock-main > small { grid-area: 3 / 1; justify-self: start; font-size: var(--rc-text-caption); font-weight: var(--rc-weight-regular); color: var(--rc-muted); line-height: 1.2; }
    .mobile-music-card .music-dock-progress::before { background: var(--rc-border-hover); }
    .mobile-music-card .music-dock-progress span { background: var(--rc-accent); border-radius: 999px; }
    .mobile-music-card > .music-dock-play {
      width: 48px; height: 48px; min-width: 48px; min-height: 48px;
      justify-self: center; border-radius: 50%; border: 0;
      color: var(--rc-primary-ink); background: var(--rc-primary); box-shadow: none;
    }
    .mobile-music-card > .music-dock-play:hover { background: var(--rc-primary-hover); }
    .mobile-music-card > .music-dock-play > svg { width: 22px; height: 22px; stroke-width: var(--rc-icon-stroke); }
    .mobile-music-card > .music-dock-step,
    .mobile-music-card > .button,
    .mobile-music-card .music-volume,
    .mobile-music-card .music-volume > .media-volume-trigger {
      width: 44px; height: 44px; min-width: 44px; min-height: 44px;
      padding: 0; justify-self: center; border-radius: var(--rc-radius-control);
      border: 0; box-shadow: none; background: transparent; color: var(--rc-muted);
    }
    .mobile-music-card :is(.music-dock-step, .button, .media-volume-trigger):hover:not(:disabled) { background: var(--rc-surface-raised); color: var(--rc-ink); }
    .mobile-music-card :is(.music-dock-step, .button, .media-volume-trigger) > svg { width: 18px; height: 18px; stroke-width: var(--rc-icon-stroke); }
    .mobile-music-card .music-dock-step::before,
    .mobile-music-card .music-dock-play::before { display: none; }
    .mobile-panel-activity { border-top: 0; background: transparent; padding: 12px 10px; }
    .mobile-panel-activity .mobile-music-card.music-dock {
      width: 100%; margin: 0;
      grid-template-columns: 44px minmax(0, 1fr) 44px;
      grid-template-rows: auto 48px 44px;
      grid-template-areas: "main main close" "prev play next" "volume share car";
      padding: 12px;
      box-shadow: var(--rc-shadow-widget);
    }
    .mobile-music-card:not(.has-share):not(.has-car-mode) { grid-template-areas: "play main main main close" "prev . volume . next"; }
    .mobile-music-card:not(.has-nav).has-share { grid-template-areas: "play main main main close" "volume . share . car"; }
    .mobile-panel-activity .mobile-music-card:not(.has-nav).has-share { grid-template-areas: "main main close" ". play ." "volume share car"; }
    .mobile-panel-activity .mobile-music-card:not(.has-share):not(.has-car-mode) { grid-template-areas: "main main close" "prev play next" ". volume ."; }
  }
  @media (max-width: 380px) {
    .mobile-music-card.music-dock {
      grid-template-columns: 44px minmax(0, 1fr) 44px;
      grid-template-rows: auto 48px 44px;
      grid-template-areas: "main main close" "prev play next" "volume share car";
    }
    .mobile-music-card:not(.has-share):not(.has-car-mode) { grid-template-areas: "main main close" "prev play next" ". volume ."; }
    .mobile-music-card:not(.has-nav).has-share { grid-template-areas: "main main close" ". play ." "volume share car"; }
  }
  @media (prefers-reduced-motion: reduce) {
    :is(.rc-button, .button, .admin-button, .admin-icon-button, .ds-button, .input, .textarea, .rasta-custom-select-trigger, .switch, .ds-switch) { transition: none; }
  }
}

/* Segmented choices fill one track; only the track's outside corners curve. */
@layer rc-system {
  :root :is(.profile-settings-v5 .settings-media-tabs, .profile-settings-v5 .settings-media-presets, .profile-settings-v5 .settings-media-priority, .profile-settings-v4 .notification-overview-tabs, .personal-files-view-toggle, .audiobook-sort) {
    padding: 0;
    gap: 0;
  }
  :root :is(.profile-settings-v5 .settings-media-tabs, .profile-settings-v5 .settings-media-presets, .profile-settings-v5 .settings-media-priority, .profile-settings-v4 .notification-overview-tabs, .personal-files-view-toggle, .audiobook-sort) > button {
    border-radius: 0;
    box-shadow: none;
  }
  :root :is(.profile-settings-v5 .settings-media-tabs, .profile-settings-v5 .settings-media-presets, .profile-settings-v5 .settings-media-priority, .profile-settings-v4 .notification-overview-tabs, .personal-files-view-toggle, .audiobook-sort) > button:first-child {
    border-start-start-radius: inherit;
    border-end-start-radius: inherit;
  }
  :root :is(.profile-settings-v5 .settings-media-tabs, .profile-settings-v5 .settings-media-presets, .profile-settings-v5 .settings-media-priority, .profile-settings-v4 .notification-overview-tabs, .personal-files-view-toggle, .audiobook-sort) > button:last-child {
    border-start-end-radius: inherit;
    border-end-end-radius: inherit;
  }
  :root .profile-settings-v5 :is(.settings-media-tabs, .settings-media-presets, .settings-media-priority) > button { min-height: 52px; }
  :root .profile-settings-v4 .notification-overview-tabs > button { min-height: 48px; }
  :root .personal-files-view-toggle { display: inline-flex; }
  :root .personal-files-view-toggle > button { width: 38px; height: 40px; }
  :root .audiobook-sort > button { flex: 1; min-height: 40px; }
  :root :is(.profile-settings-v5 .settings-media-tabs, .profile-settings-v5 .settings-media-presets, .profile-settings-v5 .settings-media-priority, .profile-settings-v4 .notification-overview-tabs, .personal-files-view-toggle, .audiobook-sort) > button:focus-visible { outline-offset: -3px; }
  @media (max-width: 420px) {
    :root .profile-settings-v5 .settings-media-presets > button { min-height: 44px; border-radius: 0; }
    :root .profile-settings-v5 .settings-media-presets > button:first-child { border-radius: 12px 12px 0 0; }
    :root .profile-settings-v5 .settings-media-presets > button:last-child { border-radius: 0 0 12px 12px; }
    :root .profile-settings-v5 .settings-media-presets > button:only-child { border-radius: 12px; }
  }
}

/* Shared quiet scrollbar. Keep deliberately hidden mobile rails hidden. */
@layer rc-legacy {
  :where(*) { scrollbar-width: thin; scrollbar-color: var(--rc-border-hover) transparent; }
  :where(*)::-webkit-scrollbar { width: 6px; height: 6px; }
  :where(*)::-webkit-scrollbar-track,
  :where(*)::-webkit-scrollbar-corner { background: transparent; }
  :where(*)::-webkit-scrollbar-thumb { background: var(--rc-border-hover); border-radius: 8px; }
  :where(*)::-webkit-scrollbar-thumb:hover { background: var(--rc-muted); }
  :where(*)::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
  @media (forced-colors: active) {
    :where(*) { scrollbar-color: auto; scrollbar-width: auto; }
  }
}
