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

/* Safe gradient interpolation color-space tokens */
@layer tokens {
  :root {
    --in-oklab: ;
    --in-oklch: ;

    /* Tier 1: Cosmic Palette */
    --space-950: #050714;
    --space-900: #090d24;
    --space-850: #0e1436;
    --space-800: #151c48;
    --space-700: #222b66;

    --neon-cyan: #56f0ff;
    --neon-blue: #58a6ff;
    --neon-pink: #ff7ee2;
    --neon-gold: #ffd86b;
    --neon-mint: #5effb0;
    --neon-amber: #ffbe55;
    --sleepy-lavender: #9aa3c7;
    --neon-coral: #ff7a8a;

    /* Tier 2: Semantic Tokens */
    --bg-canvas: var(--space-950);
    --surface-glass: rgba(11, 16, 42, 0.86);
    --surface-card: rgba(18, 25, 62, 0.88);
    --surface-elevated: rgba(25, 34, 82, 0.94);

    --text-main: #f3f7ff;
    --text-muted: #b6c2e6;
    --text-soft: #8d9bc4;

    --border-subtle: rgba(130, 178, 255, 0.28);
    --border-bright: rgba(86, 240, 255, 0.56);
    --border-mutual: rgba(255, 126, 226, 0.65);

    --color-focus: #ffd86b;
    --color-accent: var(--neon-cyan);

    /* Scrollbar tokens */
    --scrollbar-thumb: rgba(116, 212, 255, 0.45);
    --scrollbar-track: rgba(10, 14, 38, 0.5);

    /* Typography & radii */
    --font-sans: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Quicksand', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, 'SFMono-Regular', 'JetBrains Mono', Menlo, Consolas, monospace;

    --radius-sm: 0.65rem;
    --radius-md: 1rem;
    --radius-lg: 1.35rem;
    --radius-pill: 999px;

    --shadow-cosmic:
      0 12px 32px rgba(2, 4, 16, 0.65),
      0 0 0 1px var(--border-subtle),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);

    color-scheme: dark;
    accent-color: var(--color-accent);
  }

  @supports (linear-gradient(in oklab, white, black)) {
    :root {
      --in-oklab: in oklab;
      --in-oklch: in oklch;
    }
  }
}

@property --animation-reduced {
  syntax: "*";
  inherits: false;
  initial-value: none;
}

@layer reset {
  html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
  }

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

  ul, ol {
    padding: 0;
    list-style: none;
  }

  button, input, textarea, select {
    font: inherit;
    color: inherit;
    box-sizing: border-box;
  }

  a {
    color: inherit;
  }

  img, svg {
    display: block;
    max-inline-size: 100%;
  }
}

@layer base {
  body {
    background:
      radial-gradient(circle at 18% 15% var(--in-oklab), rgba(86, 240, 255, 0.12), transparent 42%),
      radial-gradient(circle at 82% 85% var(--in-oklab), rgba(255, 126, 226, 0.11), transparent 45%),
      var(--bg-canvas);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    text-align: start;
  }

  ::selection {
    background-color: rgba(86, 240, 255, 0.3);
    color: #ffffff;
  }

  h1, h2, h3 {
    text-wrap: balance;
    line-height: 1.2;
  }

  p {
    text-wrap: pretty;
  }

  :where(a:any-link, button, input, summary, canvas, [tabindex]):focus-visible {
    outline: 2.5px solid var(--color-focus);
    outline-offset: 3px;
  }

  .scroller {
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    scrollbar-width: thin;
    scrollbar-gutter: stable;
  }

  @media (prefers-contrast: more) {
    :root {
      --border-subtle: rgba(182, 226, 255, 0.72);
      --text-muted: #dbe5ff;
      --text-soft: #c5d4ff;
      --scrollbar-thumb: #ffffff;
      --scrollbar-track: #050714;
    }
  }

  @supports not (scrollbar-color: auto) {
    .scroller::-webkit-scrollbar {
      width: 10px;
      height: 10px;
    }

    .scroller::-webkit-scrollbar-thumb {
      background: var(--scrollbar-thumb);
      border-radius: 999px;
    }

    .scroller::-webkit-scrollbar-track {
      background: var(--scrollbar-track);
    }
  }
}

@layer layout {
  .top-bar {
    position: relative;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: linear-gradient(to right var(--in-oklab), rgba(10, 14, 38, 0.94), rgba(17, 16, 48, 0.9));
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
    justify-content: space-between;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
  }

  .brand-logo {
    inline-size: 2.35rem;
    block-size: 2.35rem;
    filter: drop-shadow(0 0 10px rgba(86, 240, 255, 0.45));
  }

  .brand-text {
    display: flex;
    flex-direction: column;
  }

  .brand h1 {
    font-size: clamp(1.15rem, 1rem + 0.6vw, 1.45rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    background: linear-gradient(100deg var(--in-oklch), #8bf7ff, #ffd86b, #ff7ee2);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
  }

  .brand-tagline {
    font-size: 0.72rem;
    color: var(--text-soft);
    letter-spacing: 0.06em;
  }

  .search-region {
    flex: 1 1 20rem;
    max-inline-size: 36rem;
    min-inline-size: 0;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
  }
}

@layer components {
  .skip-link {
    position: fixed;
    inset-block-start: 0.75rem;
    inset-inline-start: 0.75rem;
    z-index: 100;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-pill);
    background: var(--neon-gold);
    color: var(--space-950);
    font-weight: 700;
    text-decoration: none;
  }

  /* Search Form */
  .search-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  .search-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-inline-start: 0.35rem;
  }

  .search-input-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem;
    padding-inline-start: 0.8rem;
    border-radius: var(--radius-pill);
    background: rgba(16, 22, 54, 0.92);
    border: 1.5px solid var(--border-subtle);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }

  .search-input-row:focus-within {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 0 3px rgba(86, 240, 255, 0.2);
  }

  .search-input-row:has(input:user-invalid) {
    border-color: var(--neon-coral);
    box-shadow: 0 0 0 3px rgba(255, 122, 138, 0.22);
  }

  .handle-at {
    color: var(--neon-cyan);
    font-weight: 700;
    font-size: 1rem;
    user-select: none;
  }

  #handle-input {
    flex: 1 1 auto;
    min-inline-size: 0;
    min-block-size: 44px;
    border: 0;
    background: transparent;
    color: var(--text-main);
    font-size: 1rem;
    padding-inline: 0.2rem;
  }

  #handle-input::placeholder {
    color: var(--text-soft);
    opacity: 0.9;
  }

  #handle-input:focus-visible {
    outline: none;
  }

  .field-feedback {
    font-size: 0.8rem;
    color: var(--neon-coral);
    padding-inline-start: 0.85rem;
  }

  /* Buttons */
  .btn-primary,
  .btn-ghost,
  .btn-install,
  .btn-icon,
  .btn-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 1.5px solid transparent;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  }

  .btn-primary {
    min-block-size: 44px;
    padding-inline: 1.05rem;
    background: linear-gradient(120deg var(--in-oklch), #56f0ff, #7c8cff);
    color: #040717;
    box-shadow: 0 4px 16px rgba(86, 240, 255, 0.3);
  }

  .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(86, 240, 255, 0.48);
  }

  .btn-primary:active:not(:disabled) {
    transform: translateY(0);
  }

  .btn-ghost {
    min-block-size: 44px;
    padding-inline: 0.85rem;
    background: rgba(24, 32, 74, 0.72);
    border-color: var(--border-subtle);
    color: var(--text-main);
  }

  .btn-ghost:hover:not(:disabled) {
    background: rgba(36, 48, 108, 0.9);
    border-color: var(--border-bright);
  }

  .btn-install {
    min-block-size: 44px;
    padding-inline: 0.9rem;
    background: linear-gradient(120deg var(--in-oklch), #ff7ee2, #ffd86b);
    color: #090b1d;
    box-shadow: 0 4px 16px rgba(255, 126, 226, 0.32);
  }

  .btn-install:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 126, 226, 0.5);
  }

  .btn-icon {
    min-inline-size: 44px;
    min-block-size: 44px;
    padding: 0;
    background: rgba(18, 25, 62, 0.84);
    border-color: var(--border-subtle);
    color: var(--text-main);
  }

  .btn-icon:hover:not(:disabled) {
    background: rgba(34, 46, 104, 0.95);
    border-color: var(--border-bright);
  }

  .btn-icon[aria-pressed="true"] {
    background: rgba(255, 216, 107, 0.2);
    border-color: var(--neon-gold);
    color: var(--neon-gold);
  }

  .btn-mini {
    min-block-size: 32px;
    padding-inline: 0.7rem;
    font-size: 0.78rem;
    background: rgba(86, 240, 255, 0.14);
    border-color: rgba(86, 240, 255, 0.35);
    color: var(--neon-cyan);
  }

  .btn-mini:hover:not(:disabled) {
    background: rgba(86, 240, 255, 0.26);
  }

  .btn-mini-icon {
    min-inline-size: 36px;
    min-block-size: 36px;
  }

  .btn-full {
    inline-size: 100%;
  }

  button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  @media (pointer: coarse) {
    #handle-input,
    .btn-primary,
    .btn-ghost,
    .btn-install,
    .btn-icon {
      min-block-size: 48px;
    }

    .btn-icon {
      min-inline-size: 48px;
    }
  }

  /* Network Status Pill */
  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid var(--border-subtle);
    background: rgba(15, 21, 52, 0.85);
    color: var(--text-muted);
    user-select: none;
  }

  .pill-dot {
    inline-size: 0.52rem;
    block-size: 0.52rem;
    border-radius: 50%;
    background: var(--neon-mint);
    box-shadow: 0 0 8px var(--neon-mint);
  }

  .status-pill-offline {
    border-color: rgba(255, 190, 85, 0.6);
    background: rgba(255, 190, 85, 0.14);
    color: var(--neon-amber);
  }

  .status-pill-offline .pill-dot {
    background: var(--neon-amber);
    box-shadow: 0 0 8px var(--neon-amber);
  }

  .count-chip {
    display: inline-grid;
    place-items: center;
    min-inline-size: 1.35rem;
    block-size: 1.35rem;
    padding-inline: 0.3rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 126, 226, 0.24);
    color: #ffd5f6;
    font-size: 0.74rem;
  }

  /* Welcome Overlay */
  .welcome-card {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 50%;
    transform: translate(-50%, -50%);
    inline-size: min(92%, 29rem);
    padding: 1.75rem 1.5rem;
    border-radius: var(--radius-lg);
    corner-shape: squircle;
    background: linear-gradient(155deg var(--in-oklab), rgba(14, 20, 56, 0.9), rgba(24, 15, 54, 0.88));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-cosmic);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    contain: layout style paint;
    z-index: 10;
  }

  .welcome-mascot {
    inline-size: 5.5rem;
    block-size: 5.5rem;
    filter: drop-shadow(0 0 22px rgba(86, 240, 255, 0.42));
    animation: float-bob 4.5s ease-in-out infinite;
    --animation-reduced: none;
  }

  @keyframes float-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-7px); }
  }

  .welcome-card h2 {
    font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem);
    color: var(--text-main);
  }

  .welcome-copy {
    color: var(--text-muted);
    font-size: 0.94rem;
    max-inline-size: 40ch;
  }

  .welcome-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-block-start: 0.25rem;
  }

  .welcome-saved {
    inline-size: 100%;
    margin-block-start: 0.5rem;
    padding-block-start: 0.85rem;
    border-block-start: 1px solid var(--border-subtle);
  }

  .welcome-saved h3 {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-block-end: 0.55rem;
    font-weight: 600;
  }

  .saved-chip-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
  }

  .saved-chip-btn {
    min-block-size: 36px;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    background: rgba(86, 240, 255, 0.1);
    color: var(--neon-cyan);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease;
  }

  .saved-chip-btn:hover {
    background: rgba(86, 240, 255, 0.22);
    border-color: var(--neon-cyan);
  }

  /* Progress Toast */
  .progress-toast {
    position: absolute;
    inset-block-start: 0.9rem;
    inset-inline-start: 50%;
    transform: translateX(-50%);
    z-index: 15;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    background: rgba(12, 18, 48, 0.92);
    border: 1px solid var(--border-bright);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--neon-cyan);
    pointer-events: none;
  }

  .zoom-hint {
    position: absolute;
    inset-block-start: 0.9rem;
    inset-inline-start: 50%;
    transform: translateX(-50%);
    z-index: 13;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.95rem;
    border-radius: var(--radius-pill);
    background: rgba(14, 20, 54, 0.88);
    border: 1px solid rgba(196, 166, 255, 0.45);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    font-size: 0.82rem;
    font-weight: 600;
    color: #e4dcff;
    pointer-events: none;
    white-space: nowrap;
  }

  .orbit-spinner {
    inline-size: 1rem;
    block-size: 1rem;
    border-radius: 50%;
    border: 2px solid rgba(86, 240, 255, 0.25);
    border-block-start-color: var(--neon-pink);
    border-inline-end-color: var(--neon-cyan);
    animation: spin-orbit 0.85s linear infinite;
    --animation-reduced: none;
  }

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

  /* Hover Tooltip */
  .node-tooltip {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    z-index: 14;
    pointer-events: none;
    padding: 0.45rem 0.72rem;
    border-radius: var(--radius-sm);
    background: rgba(8, 12, 34, 0.94);
    border: 1px solid var(--border-bright);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
    font-size: 0.8rem;
    line-height: 1.3;
    max-inline-size: 16rem;
    color: var(--text-main);
    will-change: transform;
  }

  .tooltip-name {
    font-weight: 700;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tooltip-meta {
    color: var(--text-muted);
    font-size: 0.74rem;
    display: block;
  }

  /* Bottom-left HUD Dock */
  .hud-dock {
    position: absolute;
    inset-block-end: 1rem;
    inset-inline-start: 1rem;
    z-index: 12;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    align-items: flex-start;
    contain: layout style paint;
  }

  .legend-card {
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-md);
    corner-shape: squircle;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-cosmic);
    font-size: 0.78rem;
    max-inline-size: 20rem;
  }

  .legend-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-main);
    user-select: none;
  }

  .legend-summary::marker {
    color: var(--neon-cyan);
  }

  .legend-title {
    white-space: nowrap;
  }

  .legend-counts {
    color: var(--neon-cyan);
    font-weight: 700;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .legend-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, auto));
    gap: 0.35rem 0.75rem;
    margin-block-start: 0.5rem;
    padding-block-start: 0.45rem;
    border-block-start: 1px solid rgba(130, 178, 255, 0.2);
  }

  .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    color: var(--text-muted);
    white-space: nowrap;
  }

  .badge-swatch {
    display: inline-grid;
    place-items: center;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
  }

  .swatch-active {
    background: rgba(94, 255, 176, 0.2);
    border: 1.5px solid var(--neon-mint);
    color: var(--neon-mint);
  }

  .swatch-recent {
    background: rgba(255, 190, 85, 0.2);
    border: 1.5px solid var(--neon-amber);
    color: var(--neon-amber);
  }

  .swatch-inactive {
    background: rgba(154, 163, 199, 0.2);
    border: 1.5px solid var(--sleepy-lavender);
    color: var(--sleepy-lavender);
  }

  .swatch-mutual {
    background: rgba(255, 126, 226, 0.22);
    border: 1.5px solid var(--neon-pink);
    color: var(--neon-pink);
  }

  .swatch-following {
    background: rgba(255, 216, 107, 0.2);
    border: 1.5px solid var(--neon-gold);
    color: var(--neon-gold);
  }

  .swatch-follower {
    background: rgba(86, 240, 255, 0.18);
    border: 1.5px solid var(--neon-cyan);
    color: var(--neon-cyan);
  }

  .swatch-cluster {
    background: rgba(167, 139, 250, 0.22);
    border: 1.5px dashed #c4a6ff;
    color: #e5d4ff;
  }

  .legend-item-wide {
    grid-column: 1 / -1;
  }

  .camera-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem;
    border-radius: var(--radius-pill);
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-cosmic);
  }

  /* Floating Control Panel (Sidebar) */
  .control-panel {
    position: absolute;
    inset-block-start: 0.9rem;
    inset-block-end: 0.9rem;
    inset-inline-end: 0.9rem;
    inline-size: min(23.5rem, calc(100% - 1.8rem));
    z-index: 16;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    corner-shape: squircle;
    background: linear-gradient(165deg var(--in-oklab), rgba(11, 16, 44, 0.95), rgba(19, 15, 48, 0.94));
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow-cosmic);
    contain: layout style paint;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.24s ease-out, transform 0.24s ease-out, display 0.24s allow-discrete;
  }

  .control-panel:not([hidden]) {
    @starting-style {
      opacity: 0;
      transform: translateX(18px);
    }
  }

  .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem 0.65rem;
    border-block-end: 1px solid var(--border-subtle);
    flex-shrink: 0;
  }

  .panel-kicker {
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--neon-cyan);
  }

  .btn-close-panel {
    min-inline-size: 38px;
    min-block-size: 38px;
  }

  .panel-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .profile-hero {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
  }

  .avatar-frame {
    position: relative;
    flex-shrink: 0;
    inline-size: 4.25rem;
    block-size: 4.25rem;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg var(--in-oklch), var(--neon-cyan), var(--neon-blue));
  }

  .avatar-frame.is-mutual {
    background: linear-gradient(135deg var(--in-oklch), var(--neon-pink), var(--neon-gold), var(--neon-cyan));
    box-shadow: 0 0 18px rgba(255, 126, 226, 0.5);
  }

  .avatar-frame.is-following {
    background: linear-gradient(135deg var(--in-oklch), var(--neon-gold), #ff9f6b);
    box-shadow: 0 0 16px rgba(255, 216, 107, 0.45);
  }

  .profile-avatar {
    inline-size: 100%;
    block-size: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 50%;
    background: var(--space-800);
  }

  .avatar-status-dot {
    position: absolute;
    inset-block-end: -2px;
    inset-inline-end: -2px;
    inline-size: 1.45rem;
    block-size: 1.45rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.78rem;
    font-weight: 800;
    background: var(--space-950);
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
  }

  .avatar-status-dot[data-status="active"] {
    border-color: var(--neon-mint);
    color: var(--neon-mint);
  }

  .avatar-status-dot[data-status="recent"] {
    border-color: var(--neon-amber);
    color: var(--neon-amber);
  }

  .avatar-status-dot[data-status="inactive"] {
    border-color: var(--sleepy-lavender);
    color: var(--sleepy-lavender);
  }

  .profile-identity {
    min-inline-size: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
  }

  .profile-name {
    font-size: 1.12rem;
    font-weight: 800;
    color: var(--text-main);
    overflow-wrap: anywhere;
  }

  .profile-handle {
    font-size: 0.86rem;
    color: var(--neon-cyan);
    text-decoration: none;
    overflow-wrap: anywhere;
  }

  .profile-handle:hover {
    text-decoration: underline;
  }

  .profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-block-start: 0.25rem;
  }

  .info-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-pill);
    font-size: 0.74rem;
    font-weight: 700;
    border: 1px solid var(--border-subtle);
    background: rgba(24, 34, 80, 0.75);
  }

  .info-chip-mutual {
    border-color: var(--border-mutual);
    background: rgba(255, 126, 226, 0.16);
    color: #ffd3f5;
  }

  .info-chip-following {
    border-color: rgba(255, 216, 107, 0.62);
    background: rgba(255, 216, 107, 0.16);
    color: #ffe79e;
  }

  .info-chip-follower {
    border-color: rgba(86, 240, 255, 0.48);
    background: rgba(86, 240, 255, 0.12);
    color: #bdf7ff;
  }

  .info-chip-root {
    border-color: rgba(255, 216, 107, 0.65);
    background: rgba(255, 216, 107, 0.16);
    color: var(--neon-gold);
  }

  .info-chip-active {
    border-color: rgba(94, 255, 176, 0.55);
    background: rgba(94, 255, 176, 0.14);
    color: var(--neon-mint);
  }

  .info-chip-recent {
    border-color: rgba(255, 190, 85, 0.55);
    background: rgba(255, 190, 85, 0.14);
    color: var(--neon-amber);
  }

  .info-chip-inactive {
    border-color: rgba(154, 163, 199, 0.5);
    background: rgba(154, 163, 199, 0.14);
    color: var(--sleepy-lavender);
  }

  .profile-bio {
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: pre-line;
    overflow-wrap: anywhere;
    max-inline-size: 65ch;
  }

  .profile-bio a,
  .post-text a {
    color: var(--neon-cyan);
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .telemetry-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.42rem;
  }

  .stat-box {
    padding: 0.5rem 0.35rem;
    border-radius: var(--radius-sm);
    background: rgba(18, 26, 66, 0.75);
    border: 1px solid rgba(130, 178, 255, 0.2);
    text-align: center;
  }

  .stat-box-shared {
    border-color: rgba(196, 166, 255, 0.42);
    background: rgba(34, 26, 78, 0.78);
  }

  .stat-box dt {
    font-size: 0.68rem;
    color: var(--text-soft);
    font-weight: 600;
  }

  .stat-box dd {
    font-size: 0.94rem;
    font-weight: 800;
    color: var(--text-main);
    margin-block-start: 0.1rem;
  }

  .stat-box-shared dd {
    color: #dfcaff;
  }

  .shared-preview {
    font-size: 0.78rem;
    color: #d6c8ff;
    margin-block-start: -0.45rem;
    overflow-wrap: anywhere;
  }

  .shared-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.16rem 0.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.76rem;
    font-weight: 800;
    background: rgba(167, 139, 250, 0.2);
    border: 1px solid rgba(196, 166, 255, 0.48);
    color: #e5d4ff;
  }

  .shared-badge-zero {
    color: var(--text-soft);
    font-size: 0.8rem;
    font-weight: 600;
  }

  .panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  .section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .section-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-soft);
    letter-spacing: 0.04em;
  }

  .did-code {
    display: block;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    background: rgba(5, 8, 22, 0.85);
    border: 1px solid rgba(130, 178, 255, 0.22);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #cde9ff;
    overflow-wrap: anywhere;
  }

  .post-date {
    font-size: 0.76rem;
    color: var(--neon-gold);
    font-weight: 600;
  }

  .post-card {
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-md);
    background: rgba(19, 27, 68, 0.78);
    border: 1px solid rgba(130, 178, 255, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .post-meta {
    font-size: 0.75rem;
    color: var(--neon-pink);
    font-weight: 700;
  }

  .post-text {
    font-size: 0.88rem;
    color: var(--text-main);
    white-space: pre-line;
    overflow-wrap: anywhere;
    max-inline-size: 65ch;
  }

  .post-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--neon-cyan);
    text-decoration: none;
    align-self: flex-start;
  }

  .post-link:hover {
    text-decoration: underline;
  }

  .panel-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-block-start: 0.2rem;
  }

  .expand-note {
    font-size: 0.78rem;
    color: var(--text-soft);
    text-align: center;
  }

  /* Native Top-Layer Popover & Dialog Animations (with @starting-style + allow-discrete + overlay) */
  .cosmic-popover {
    margin: 0;
    inset: auto;
    inset-block-start: 4.9rem;
    inset-inline-end: 1rem;
    inline-size: min(23rem, calc(100vw - 2rem));
    max-block-size: min(72dvh, 32rem);
    padding: 1rem;
    border: 1.5px solid var(--border-bright);
    border-radius: var(--radius-lg);
    corner-shape: squircle;
    background: #0b1030;
    color: var(--text-main);
    box-shadow:
      0 20px 50px rgba(2, 4, 16, 0.88),
      0 0 0 1px rgba(86, 240, 255, 0.35);
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
    transition-property: opacity, transform, display, overlay;
    transition-duration: 0.22s;
    transition-timing-function: ease-out;
    transition-behavior: allow-discrete;
  }

  .cosmic-popover::backdrop {
    background-color: rgba(3, 5, 18, 0);
    transition:
      display 0.22s allow-discrete,
      overlay 0.22s allow-discrete,
      background-color 0.22s ease-out;
  }

  .cosmic-popover:where(:popover-open, .\:popover-open) {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);

    @starting-style {
      opacity: 0;
      transform: translateY(-8px) scale(0.97);
    }
  }

  .cosmic-popover:where(:popover-open, .\:popover-open)::backdrop {
    background-color: rgba(3, 5, 18, 0.5);

    @starting-style {
      background-color: rgba(3, 5, 18, 0);
    }
  }

  .popover-inner {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    inline-size: 100%;
  }

  .popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .popover-title {
    font-size: 1rem;
    color: var(--neon-cyan);
  }

  .popover-subtitle {
    font-size: 0.8rem;
    color: var(--text-soft);
  }

  .history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    max-block-size: 19rem;
    padding-inline-end: 0.25rem;
  }

  .history-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    background: rgba(21, 29, 72, 0.78);
    border: 1px solid rgba(130, 178, 255, 0.22);
  }

  .history-load-btn {
    flex: 1 1 auto;
    min-inline-size: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: transparent;
    border: 0;
    padding: 0.2rem;
    text-align: start;
    cursor: pointer;
    color: inherit;
    border-radius: var(--radius-sm);
  }

  .history-load-btn:hover .history-handle {
    color: var(--neon-cyan);
  }

  .history-avatar {
    inline-size: 2.25rem;
    block-size: 2.25rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--space-800);
  }

  .history-info {
    min-inline-size: 0;
    display: flex;
    flex-direction: column;
  }

  .history-handle {
    font-size: 0.86rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .history-meta {
    font-size: 0.74rem;
    color: var(--text-soft);
  }

  .history-delete-btn {
    min-inline-size: 32px;
    min-block-size: 32px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    display: grid;
    place-items: center;
  }

  .history-delete-btn:hover {
    color: var(--neon-coral);
    border-color: rgba(255, 122, 138, 0.45);
    background: rgba(255, 122, 138, 0.14);
  }

  .history-empty {
    font-size: 0.84rem;
    color: var(--text-soft);
    padding: 0.85rem 0.5rem;
    text-align: center;
  }

  .install-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 216, 107, 0.1);
    border: 1px solid rgba(255, 216, 107, 0.35);
  }

  /* Accessible Star Directory Modal Dialog */
  .cosmic-dialog {
    inline-size: min(52rem, calc(100vw - 2rem));
    max-block-size: 82dvh;
    padding: 0;
    border: 1.5px solid var(--border-bright);
    border-radius: var(--radius-lg);
    corner-shape: squircle;
    background: rgba(10, 14, 40, 0.97);
    color: var(--text-main);
    box-shadow: var(--shadow-cosmic);
    overflow: hidden;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.95);
    transition-property: opacity, transform, display, overlay;
    transition-duration: 0.25s;
    transition-timing-function: ease-out;
    transition-behavior: allow-discrete;
  }

  .cosmic-dialog[open] {
    display: flex;
    opacity: 1;
    transform: scale(1);

    @starting-style {
      opacity: 0;
      transform: scale(0.95);
    }
  }

  .cosmic-dialog::backdrop {
    background-color: rgba(3, 5, 18, 0);
    backdrop-filter: blur(0px);
    transition:
      display 0.25s allow-discrete,
      overlay 0.25s allow-discrete,
      background-color 0.25s ease-out;
  }

  .cosmic-dialog[open]::backdrop {
    background-color: rgba(3, 5, 18, 0.72);
    backdrop-filter: blur(4px);

    @starting-style {
      background-color: rgba(3, 5, 18, 0);
    }
  }

  .dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-block-end: 1px solid var(--border-subtle);
  }

  .dialog-subtitle {
    font-size: 0.82rem;
    color: var(--text-soft);
    margin-block-start: 0.2rem;
  }

  .dialog-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    padding: 0.7rem 1.25rem;
    border-block-end: 1px solid rgba(130, 178, 255, 0.16);
    background: rgba(12, 17, 48, 0.85);
  }

  .directory-search {
    flex: 1 1 15rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
  }

  .directory-filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
  }

  .directory-filter-input {
    flex: 1 1 12rem;
    min-block-size: 40px;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--border-subtle);
    background: rgba(16, 22, 56, 0.92);
    color: var(--text-main);
    font-size: 0.95rem;
  }

  .directory-filter-input::placeholder {
    color: var(--text-soft);
  }

  .relation-filter-group {
    border: 0;
    margin: 0;
    padding: 0;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .relation-pill {
    --pill-bg: rgba(22, 30, 74, 0.75);
    --pill-border: var(--border-subtle);
    --pill-color: var(--text-muted);

    position: relative;
    display: inline-flex;
    align-items: center;
    min-block-size: 36px;
    padding-inline: 0.72rem;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--pill-border);
    background-color: var(--pill-bg);
    color: var(--pill-color);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  }

  .relation-pill input[type="radio"] {
    position: absolute;
    clip-path: inset(50%);
    overflow: hidden;
    inline-size: 1px;
    block-size: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    white-space: nowrap;
  }

  .relation-pill:hover {
    border-color: var(--border-bright);
    color: var(--text-main);
  }

  .relation-pill:has(input:checked) {
    --pill-bg: rgba(86, 240, 255, 0.2);
    --pill-border: var(--neon-cyan);
    --pill-color: #ffffff;
  }

  .relation-pill:has(input:focus-visible) {
    outline: 2.5px solid var(--color-focus);
    outline-offset: 2px;
  }

  @supports not selector(:has(*)) {
    .relation-pill.is-checked {
      --pill-bg: rgba(86, 240, 255, 0.2);
      --pill-border: var(--neon-cyan);
      --pill-color: #ffffff;
    }
  }

  .dialog-body {
    overflow: auto;
    padding: 0.75rem 1.25rem 1.25rem;
    container-type: inline-size;
    container-name: directory-table;
  }

  .star-table {
    inline-size: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
  }

  .table-mobile-meta {
    display: none;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-block-start: 0.2rem;
    white-space: normal;
  }

  /* Container-query compact mobile table: keeps native <table> semantics & zero horizontal scroll */
  @container directory-table (max-width: 600px) {
    .star-table {
      table-layout: fixed;
    }

    .star-table th:nth-child(3),
    .star-table td:nth-child(3),
    .star-table th:nth-child(4),
    .star-table td:nth-child(4),
    .star-table th:nth-child(5),
    .star-table td:nth-child(5) {
      display: none;
    }

    .star-table th:nth-child(2),
    .star-table td:nth-child(2) {
      inline-size: 3.7rem;
      text-align: center;
    }

    .star-table th:nth-child(6),
    .star-table td:nth-child(6) {
      inline-size: 4.8rem;
      text-align: end;
    }

    .star-table th,
    .star-table td {
      padding: 0.55rem 0.25rem;
    }

    .star-table .table-account-cell {
      max-inline-size: 100%;
      min-inline-size: 0;
    }

    .table-mobile-meta {
      display: block;
    }
  }

  .star-table th,
  .star-table td {
    padding: 0.6rem 0.55rem;
    text-align: start;
    vertical-align: middle;
  }

  .star-table th {
    font-size: 0.76rem;
    color: var(--neon-cyan);
    font-weight: 700;
    position: sticky;
    inset-block-start: 0;
    background: rgba(10, 14, 40, 0.98);
    border-block-end: 1px solid rgba(130, 178, 255, 0.28);
  }

  .star-table tbody tr:not(:last-child) td {
    border-block-end: 1px solid rgba(130, 178, 255, 0.16);
  }

  .star-table td:nth-child(2),
  .star-table td:nth-child(3),
  .star-table td:nth-child(4),
  .star-table td:nth-child(5),
  .star-table td:nth-child(6) {
    white-space: nowrap;
  }

  .table-account-cell {
    display: flex;
    flex-direction: column;
    max-inline-size: 16rem;
  }

  .table-account-cell strong,
  .table-handle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .table-handle {
    font-size: 0.76rem;
    color: var(--text-soft);
  }

  .dialog-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-block-start: 0.85rem;
    margin-block-start: 0.35rem;
  }

  .directory-page-status {
    font-size: 0.8rem;
    color: var(--text-soft);
  }

  .btn-table-more {
    min-block-size: 38px;
    padding-inline: 0.9rem;
    font-size: 0.82rem;
  }

  /* Responsive adjustments for smaller viewports */
  @media (max-width: 780px) {
    .top-bar {
      padding-block: 0.55rem;
      padding-inline: 0.75rem;
      gap: 0.5rem 0.75rem;
    }

    .brand-tagline {
      display: none;
    }

    .search-region {
      order: 3;
      flex-basis: 100%;
      max-inline-size: none;
    }

    .control-panel {
      inset-block-start: auto;
      inset-block-end: 0.65rem;
      inset-inline: 0.65rem;
      inline-size: auto;
      max-block-size: 56dvh;
    }

    .control-panel:not([hidden]) {
      @starting-style {
        opacity: 0;
        transform: translateY(20px);
      }
    }

    .hud-dock {
      inset-block-end: 0.65rem;
      inset-inline-start: 0.65rem;
      max-inline-size: calc(100vw - 1.3rem);
    }

    .legend-card {
      max-inline-size: min(22rem, calc(100vw - 1.3rem));
      padding: 0.5rem 0.75rem;
    }

    .legend-summary {
      gap: 0.6rem;
    }

    .legend-list {
      gap: 0.35rem 0.65rem;
      font-size: 0.74rem;
    }

    .dialog-header,
    .dialog-toolbar,
    .dialog-body {
      padding-inline: 0.85rem;
    }
  }
}

@layer utilities {
  [hidden] {
    display: none !important;
  }

  .visually-hidden:where(:not(:focus-within, :active)) {
    position: absolute !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    inline-size: 1px !important;
    block-size: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
  }

  /* Respect prefers-reduced-motion cleanly without 0.01ms global hack */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation: var(--animation-reduced) !important;
    }

    .control-panel,
    .cosmic-popover,
    .cosmic-dialog {
      transform: none;
      transition-duration: 0.1s;
    }

    .control-panel:not([hidden]),
    .cosmic-popover:where(:popover-open, .\:popover-open),
    .cosmic-dialog[open] {
      @starting-style {
        transform: none;
      }
    }
  }

  /* Forced Colors / High Contrast Mode support */
  @media (forced-colors: active) {
    .top-bar,
    .welcome-card,
    .control-panel,
    .legend-card,
    .camera-controls,
    .cosmic-popover,
    .cosmic-dialog,
    .post-card,
    .stat-box,
    .search-input-row,
    .btn-primary,
    .btn-ghost,
    .btn-install,
    .btn-icon {
      border: 1px solid ButtonBorder;
      box-shadow: none;
    }

    .brand h1 {
      background: none;
      color: CanvasText;
    }
  }
}
