  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg:        #0d0d12;
    --surface:   #16161e;
    --surface2:  #1e1e2a;
    --border:    #2a2a3a;
    --accent:    #7c3aed;
    --accent-h:  #9155ff;
    --accent-dim:#3d1f80;
    --text:      #e2e2e8;
    --text-dim:  #888898;
    --green:     #22c55e;
    --red:       #ef4444;
    --amber:     #f59e0b;
    --radius:    10px;
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
  }

  /* Typewriter reveal, Home hero only */
  @keyframes type {
    from { width: 0; }
    to   { width: 100%; }
  }
  .home-hero h1 {
    overflow: hidden;
    white-space: nowrap;
    animation: type 2.5s steps(22) forwards;
  }

  /* Nav */
  #nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    overflow-x: auto;
  }
  .nav-left { display: flex; align-items: center; gap: 28px; min-width: 0; }
  .nav-logo {
    font-size: 15px; font-weight: 700; letter-spacing: -0.3px;
    color: var(--text); display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  }
  .nav-logo svg { width: 22px; height: 22px; }

  /* Horizontal page nav */
  .nav-links { display: flex; align-items: center; gap: 4px; }
  .nav-item {
    display: flex; align-items: center; gap: 6px; padding: 8px 10px; cursor: pointer;
    color: var(--text-dim); font-size: 13px; font-weight: 500;
    border-bottom: 2px solid transparent; white-space: nowrap;
    transition: color .12s ease, border-color .12s ease; user-select: none;
  }
  .nav-item:hover  { color: var(--text); }
  .nav-item.active { color: var(--text); border-bottom-color: var(--accent); }
  .nav-item .nav-icon { display: inline-flex; }
  .nav-item .nav-icon svg { width: 14px; height: 14px; }
  @media (max-width: 720px) { .nav-left { gap: 16px; } .nav-item { padding: 8px 6px; } }

  /* Account button + dropdown */
  .nav-account { position: relative; }
  .nav-account-btn {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 20px;
    padding: 5px 12px 5px 8px; cursor: pointer;
    transition: background .15s, border-color .15s; color: var(--text);
  }
  .nav-account-btn:hover { background: var(--border); border-color: var(--accent); }
  .nav-account-avatar {
    width: 26px; height: 26px; border-radius: 50%; background: var(--accent-dim);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--accent-h); flex-shrink: 0;
  }
  .nav-account-name {
    font-size: 13px; font-weight: 500; max-width: 140px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .nav-account-chevron { width: 12px; height: 12px; opacity: .5; flex-shrink: 0; }
  .nav-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 220px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.5); overflow: hidden; z-index: 200;
  }
  .nav-dropdown.open { display: block; }
  .nav-dropdown-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .nav-dropdown-header .dn-name  { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
  .nav-dropdown-header .dn-email { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-dropdown-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 16px; background: none; border: none; color: var(--text);
    font-size: 13px; cursor: pointer; text-align: left; transition: background .12s;
  }
  .nav-dropdown-item:hover { background: var(--surface2); }
  .nav-dropdown-item svg { width: 15px; height: 15px; opacity: .6; }

  /* Pages */
  .page { display: none; }
  .page.active { display: block; }

  .page-inner { padding: 32px 24px 64px; }

  /* Dashboard grid 3/6/3 (legacy — kept in case reused) */
  .dashboard-grid { display: grid; grid-template-columns: 3fr 6fr 3fr; gap: 24px; align-items: start; }
  @media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

  /* Hubs page: list + register/spin-up */
  .hubs-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
  @media (max-width: 900px) { .hubs-grid { grid-template-columns: 1fr; } }

  /* Home page: hero + quick-link cards */
  .home-hero { padding: 8px 4px 28px; }
  .home-hero h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 10px; }
  .home-hero p { font-size: 14px; color: var(--text-dim); max-width: 560px; line-height: 1.7; }
  .home-hero-actions { display: flex; gap: 10px; margin-top: 20px; }
  .home-quick-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 12px; }
  .home-quick-grid .card { cursor: pointer; margin-top: 0; }
  .home-quick-featured { display: flex; flex-direction: column; justify-content: center; padding: 28px 24px; }
  .home-quick-secondary { display: flex; flex-direction: column; gap: 12px; }
  @media (max-width: 700px) { .home-quick-grid { grid-template-columns: 1fr; } }

  /* Instructions page: constrained width for comfortable reading/scrolling */
  .instructions-wrap { max-width: 900px; margin: 0 auto; }

  /* App layout: horizontal nav (top, sticky) + full-width main content */
  .app-main { min-width: 0; }

  /* Login */
  .login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 40px 36px; width: 100%; max-width: 420px; text-align: center;
  }
  .login-logo {
    width: 52px; height: 52px; background: var(--accent-dim); border-radius: 14px;
    display: flex; align-items: center; justify-content: center; margin: 0 auto 20px;
  }
  .login-logo svg { width: 28px; height: 28px; color: var(--accent-h); }
  .login-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
  .login-card p  { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }

  /* Form elements */
  input, textarea, select {
    width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
    color: var(--text); padding: 9px 12px; font-size: 14px; font-family: inherit;
    transition: border-color .15s; outline: none;
  }
  input:focus, textarea:focus, select:focus { border-color: var(--accent); }
  textarea { resize: vertical; min-height: 80px; }
  input::placeholder, textarea::placeholder { color: var(--text-dim); }
  .field { margin-bottom: 16px; }
  .field label {
    display: block; font-size: 12px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
  }

  /* Buttons */
  .btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
    border-radius: 7px; font-size: 14px; font-weight: 600; cursor: pointer; border: none;
    transition: background .15s, opacity .15s;
  }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-primary:hover { background: var(--accent-h); }
  .btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
  .btn-secondary:hover { background: var(--border); }
  .btn-danger { background: #7f1d1d; color: #fca5a5; }
  .btn-danger:hover { background: #991b1b; }
  .btn:disabled { opacity: .4; cursor: default; }
  .btn-full { width: 100%; justify-content: center; }

  /* Takeover request/accept — styled to match the client app's Branch page buttons */
  .btn-request {
    padding: 8px 20px; background: #251c08; color: #c08040;
    border: 1px solid #5a3a18; border-radius: 6px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all 0.15s; white-space: nowrap;
  }
  .btn-request:hover    { background: #352510; border-color: #8a5a28; color: #e0a050; }
  .btn-request:disabled { opacity: 0.3; cursor: not-allowed; }

  .btn-accept {
    padding: 7px 16px; background: #0d2a14; color: #4cdf80;
    border: 1px solid #1e6030; border-radius: 5px;
    font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s;
  }
  .btn-accept:hover { background: #1a4020; border-color: #3a9050; }

  .btn-reject {
    padding: 7px 14px; background: #2a0d0d; color: #c04040;
    border: 1px solid #5a1818; border-radius: 5px;
    font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s;
  }
  .btn-reject:hover { background: #3a1414; border-color: #883030; }

  /* Incoming takeover request — orange warning card, matches the client app's Branch page */
  @keyframes reqPulse { 0%,100%{opacity:1} 50%{opacity:0.35} }
  .incoming-req-card {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 18px; border-radius: 8px;
    background: #1e1408; border: 1px solid #6a3a10;
    width: 100%;
  }
  .incoming-req-icon {
    flex-shrink: 0; font-size: 20px; font-weight: 900;
    color: #f0a040; width: 36px; text-align: center;
    animation: reqPulse 1.2s infinite;
  }
  .incoming-req-body { flex: 1; }
  .incoming-req-title {
    font-size: 13px; font-weight: 600; color: #e0b070;
    margin-bottom: 4px;
  }
  .incoming-req-sub { font-size: 12px; color: #7a5a30; }
  .incoming-req-btns { display: flex; gap: 8px; flex-shrink: 0; }

  /* Cards */
  .card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
  }
  .card + .card { margin-top: 12px; }

  /* Section labels */
  .section-label {
    font-size: 11px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px;
  }

  /* Hub cards */
  .hub-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; display: flex; flex-direction: column; gap: 0;
  }
  .hub-card-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: 16px; }
  .hub-card + .hub-card { margin-top: 10px; }

  /* Collapsible sections (Stream Monitor / Chat / Collaboration) below the header row —
     styled after the client app's Listen page cards (dark inset panel, uppercase labels). */
  .hub-section { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
  .hub-section-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none;
    color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; text-align: left;
  }
  .hub-section-chevron { margin-left: auto; color: var(--text-dim); font-size: 11px; display: inline-block; transition: transform .15s; }
  .hub-section-toggle.open .hub-section-chevron { transform: rotate(90deg); }
  .hub-section-body { padding-top: 12px; }

  .hub-monitor-row { display: flex; gap: 16px; align-items: stretch; }
  .hub-fader-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
  .hub-fader-label { font-family: monospace; font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--accent-h); text-transform: uppercase; }
  .hub-fader-track { -webkit-appearance: slider-vertical; width: 20px; height: 110px; accent-color: var(--accent); cursor: ns-resize; }
  .hub-monitor-panel {
    flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; justify-content: space-between;
  }
  .hub-monitor-connect-row { display: flex; align-items: center; gap: 10px; }
  .hub-monitor-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-dim); margin-bottom: 6px; }

  .hub-chat-panel { display: flex; flex-direction: column; }
  .hub-chat-log { height: 140px; overflow-y: auto; font-size: 12px; line-height: 1.6; margin-bottom: 8px; }
  .hub-chat-input-row { display: flex; gap: 8px; }
  .hub-chat-input {
    flex: 1; padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 7px; color: var(--text); font-size: 13px;
  }

  /* Left column: icon + listen button stacked */
  .hub-left { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; }
  .hub-icon { width: 40px; height: 40px; background: var(--accent-dim); border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
  .mon-btn {
    width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--accent);
    background: var(--accent-dim); color: var(--accent); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    flex-shrink: 0; transition: background .15s, color .15s;
  }
  .mon-btn:hover  { background: var(--accent); color: #fff; }
  .mon-btn.active { background: var(--accent); color: #fff; }

  /* Middle column: hub info + actions */
  .hub-card-inner { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
  .hub-name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
  .hub-broadcasters { font-size: 12px; margin-bottom: 4px; }
  .hub-broadcasters .bc-name { color: var(--green); }
  .hub-broadcasters .bc-empty { color: var(--text-dim); font-style: italic; }
  .hub-desc { color: var(--text-dim); font-size: 12px; }
  .hub-pulse {
    width: 8px; height: 8px; background: var(--green); border-radius: 50%; flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(34,197,94,.4); animation: pulse 2s infinite;
  }
  @keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
    70%  { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
  }
  .hub-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

  /* Level meter bars, now inside .hub-monitor-panel */
  .hub-eq { display: flex; align-items: flex-end; gap: 2px; height: 40px; }
  .hub-eq span { flex: 1; background: #22c55e; border-radius: 2px; height: 4px; transition: height .05s; }

  /* Stream name / status, in the monitor panel's connect row */
  .mon-name   { font-size: 12px; color: var(--text-dim); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mon-status { font-size: 11px; color: var(--text-dim); }

  /* Messages */
  .msg { padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-top: 12px; }
  .msg-ok   { background: #14532d; color: #86efac; border: 1px solid #166534; }
  .msg-err  { background: #7f1d1d; color: #fca5a5; border: 1px solid #991b1b; }
  .msg-info { background: var(--accent-dim); color: #c4b5fd; border: 1px solid var(--accent); }

  /* Dev link */
  .dev-link { margin-top: 12px; padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; font-size: 12px; word-break: break-all; }
  .dev-link a { color: var(--accent-h); text-decoration: none; }
  .dev-link a:hover { text-decoration: underline; }

  /* API key box */
  .api-key-box { background: var(--bg); border: 1px solid var(--accent); border-radius: 7px; padding: 14px; margin-top: 14px; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
  .api-key-box .label { color: var(--text-dim); font-family: inherit; margin-bottom: 4px; }
  .api-key-box .value { color: var(--accent-h); }

  /* Divider */
  .divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

  /* Empty state */
  .empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
  .empty svg { width: 40px; height: 40px; opacity: .3; margin-bottom: 12px; }

  /* Spinner */
  .spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ── How It Works page ───────────────────────────────────────── */
  .hw-hero {
    text-align: center;
    padding: 52px 24px 40px;
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124,58,237,.18) 0%, transparent 70%);
  }
  .hw-hero-badge {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent-dim); border: 1px solid var(--accent);
    border-radius: 20px; padding: 4px 14px; font-size: 11px;
    font-weight: 600; color: var(--accent-h); letter-spacing: .5px;
    text-transform: uppercase; margin-bottom: 18px;
  }
  .hw-hero h1 {
    font-size: clamp(24px, 4vw, 40px);
    font-weight: 800; letter-spacing: -1px; line-height: 1.15; margin-bottom: 12px;
  }
  .hw-hero h1 span { color: var(--accent-h); }
  .hw-hero p { color: var(--text-dim); font-size: 16px; max-width: 500px; margin: 0 auto; }

  .hw-section { padding: 0 24px 72px; }

  .hw-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 56px; }
  @media (max-width: 640px) { .hw-roles { grid-template-columns: 1fr; } }
  .hw-role-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px 20px;
  }
  .hw-role-card.primary { border-color: var(--accent); background: linear-gradient(135deg, #1a1030 0%, var(--surface) 60%); }
  .hw-role-card .ri { font-size: 32px; margin-bottom: 12px; }
  .hw-role-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
  .hw-role-card p  { color: var(--text-dim); font-size: 13px; line-height: 1.65; }

  .hw-steps-label { font-size: 11px; font-weight: 700; color: var(--accent-h); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
  .hw-steps-title { font-size: clamp(20px, 3vw, 28px); font-weight: 800; letter-spacing: -.5px; margin-bottom: 36px; }

  .hw-step {
    display: grid; grid-template-columns: 1fr 1fr; gap: 36px;
    align-items: center; margin-bottom: 56px;
  }
  .hw-step.flip { direction: rtl; }
  .hw-step.flip > * { direction: ltr; }
  @media (max-width: 720px) { .hw-step, .hw-step.flip { grid-template-columns: 1fr; direction: ltr; } }

  .hw-step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 14px;
    font-weight: 800; margin-bottom: 14px;
  }
  .hw-step-content h3 { font-size: 20px; font-weight: 700; margin-bottom: 10px; letter-spacing: -.3px; }
  .hw-step-content p  { color: var(--text-dim); font-size: 13px; line-height: 1.75; margin-bottom: 10px; }
  .hw-step-tip {
    display: flex; align-items: flex-start; gap: 8px;
    background: var(--accent-dim); border: 1px solid var(--accent);
    border-radius: 8px; padding: 10px 14px;
    font-size: 12px; color: #c4b5fd; margin-top: 12px; line-height: 1.5;
  }
  .hw-step-tip svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

  .hw-step-visual {
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border); background: var(--surface);
  }

  /* Full-width "moment" steps — breaks up the zigzag rhythm at key story beats */
  .hw-step-full { text-align: center; margin-bottom: 56px; }
  .hw-step-full .hw-step-num { margin: 0 auto 14px; }
  .hw-step-full h3 { font-size: 20px; font-weight: 700; margin-bottom: 10px; letter-spacing: -.3px; }
  .hw-step-full p { color: var(--text-dim); font-size: 13px; line-height: 1.75; max-width: 480px; margin: 0 auto 10px; }
  .hw-step-full .hw-step-tip { text-align: left; max-width: 480px; margin: 12px auto 0; }
  .hw-step-full .hw-step-visual { max-width: 480px; margin: 24px auto 0; }

  .hw-cta {
    text-align: center; padding: 48px 24px 72px;
    background: radial-gradient(ellipse 60% 60% at 50% 100%, rgba(124,58,237,.14) 0%, transparent 70%);
  }
  .hw-cta h2 { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
  .hw-cta p  { color: var(--text-dim); margin-bottom: 24px; }
