/* =====================================================================================================================
   Blackkey: lifted dark and Liquid Glass controls (Nov 2026). Loaded last on the workspace, admin and /agent.

   1. The dark theme is lifted off pure black: a graphite ground, the panels a step above it, the frame a step below.
      Still dark (the agent works in it all day), just not a black hole. Light theme is untouched.
   2. Liquid Glass sits on the controls only (Apple: glass belongs to the functional layer, never to content).
      Buttons, the chosen thumb of every switch, toggles and the round top-bar buttons get the material: a translucent
      fill, a bright top edge, a soft inner rim and a small shadow under it. Cards, lists and menus stay solid.
      The one main action per view keeps its solid light fill (Apple's "prominent" glass), with the same glass edge.
   3. Reduce Transparency and Increase Contrast get solid, clearly bordered controls.
   Contrast on the lifted surfaces: #f5f5f7 on #1f1f22 is 15.9:1, #c7c7cc 11.0:1, #98989d 5.9:1 (all above 4.5:1).
   ===================================================================================================================== */

/* ---------------------------------------------------------------- 1. the lifted dark */
:root:not([data-theme='light']) body:is([data-area='agent'], [data-area='admin']),
.side-agent {
  --ground: #161618;
  --panel: #1f1f22;
  --panel-2: #28282c;
  --raised: #303035;
  --rail: #1b1b1e; --rail-2: #26262a; --rail-hover: #2c2c31;
  --shell-bg: #0f0f11;
  --frame-line: rgba(255, 255, 255, .1);
  --line: rgba(120, 120, 128, .4);
  --line-2: rgba(140, 140, 148, .42);
}
:root:not([data-theme='light']) body:is([data-area='agent'], [data-area='admin']) { background: var(--shell-bg); }
:root:not([data-theme='light']) body[data-area='admin'] .shell { background: var(--ground); }
/* /agent: the black bands become the same graphite */
html .fp.side-agent { --ground: #161618; --panel: #1f1f22; --panel-2: #28282c; --raised: #303035; background: var(--ground); }
.side-agent, .side-agent .ag { --black: #161618; }
.side-agent :is(.ag-video, .ag-band) { background: #161618; }
html .side-agent .fp-foot.ft { background: #121214; }
/* the bar stays a solid surface (the owner's rule: bars and menus are never see-through); the glass is on its controls */
html .side-agent .fp-nav { background: #161618; }
/* menus and popovers sit a step above the panels they open from (still solid) */
:root:not([data-theme='light']) body:is([data-area='agent'], [data-area='admin']) :is(.menu, .notes-pop, .tb-menu) { background: #2d2d32 !important; }

/* ---------------------------------------------------------------- 2. the glass */
:root {
  --g-fill: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .055));
  --g-fill-hi: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .085));
  --g-edge: inset 0 1px 0 rgba(255, 255, 255, .2), inset 0 0 0 1px rgba(255, 255, 255, .08), inset 0 -1px 0 rgba(0, 0, 0, .22);
  --g-drop: 0 4px 14px -6px rgba(0, 0, 0, .6);
  /* the chosen thumb of a switch: the brightest glass on the track */
  --g-thumb: linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, .15));
  --g-thumb-edge: inset 0 1px 0 rgba(255, 255, 255, .38), inset 0 0 0 1px rgba(255, 255, 255, .12), 0 3px 10px -3px rgba(0, 0, 0, .55);
  /* the main action: solid light, with the glass's lit top edge */
  --g-prime-sheen: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%);
  --g-prime-edge: inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 -1px 0 rgba(0, 0, 0, .12), 0 6px 18px -8px rgba(0, 0, 0, .7);
  --g-track: rgba(0, 0, 0, .28);
  --g-track-edge: inset 0 1px 2px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .06);
}
:root[data-theme='light'] {
  --g-fill: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .62));
  --g-fill-hi: linear-gradient(180deg, #fff, rgba(255, 255, 255, .8));
  --g-edge: inset 0 1px 0 #fff, inset 0 0 0 1px rgba(0, 0, 0, .07);
  --g-drop: 0 2px 8px -3px rgba(20, 24, 40, .2);
  --g-thumb: linear-gradient(180deg, #fff, rgba(255, 255, 255, .86));
  --g-thumb-edge: inset 0 1px 0 #fff, inset 0 0 0 1px rgba(0, 0, 0, .06), 0 3px 8px -2px rgba(20, 24, 40, .22);
  --g-prime-sheen: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, 0) 60%);
  --g-prime-edge: inset 0 1px 0 rgba(255, 255, 255, .28), 0 6px 16px -8px rgba(20, 24, 40, .45);
  --g-track: rgba(118, 118, 128, .14);
  --g-track-edge: inset 0 1px 2px rgba(20, 24, 40, .1);
}

/* where the glass applies: the workspace, admin and /agent */
.side-agent :is(
  .btn-ghost, .tb-btn, .topbar .bell, .topbar .profile-btn
) {
  background: var(--g-fill); border-color: transparent; box-shadow: var(--g-edge), var(--g-drop);
}
.side-agent :is(.btn-ghost, .tb-btn, .topbar .bell, .topbar .profile-btn):hover:not(:disabled) {
  background: var(--g-fill-hi); box-shadow: var(--g-edge), var(--g-drop);
}
/* a round icon button inside a panel stays flat until it is pointed at, then the glass appears under it */
.side-agent .pad-ib { background: none; box-shadow: none; }
.side-agent .pad-ib:hover { background: var(--g-fill-hi); box-shadow: var(--g-edge); }

/* the main action */
.side-agent :is(.btn-primary, .btn-add, .fp-btn, .ag-cta) {
  background-image: var(--g-prime-sheen) !important; box-shadow: var(--g-prime-edge) !important;
}

/* switches: the track is sunk into the surface, the chosen thumb is glass */
.side-agent :is(.seg, .cur-sw, .fp-switch, .hb-view) {
  background: var(--g-track) !important; border-color: transparent !important; box-shadow: var(--g-track-edge);
}
.side-agent :is(.seg .seg-pill, .fp-switch-pill) {
  background: var(--g-thumb) !important; box-shadow: var(--g-thumb-edge) !important;
}
.side-agent :is(.cur-sw button.on, .hb-view button.on) {
  background: var(--g-thumb) !important; box-shadow: var(--g-thumb-edge) !important; color: var(--ink) !important;
}
/* the chosen word reads in the normal ink on the glass thumb (it was dark text on a white pill) */
:root:not([data-theme='light']) body[data-area='agent'] .content .seg button.on,
:root:not([data-theme='light']) body[data-area='agent'] .content .seg button.on .icon { color: var(--ink); }
.side-agent .fp-switch a.on, .side-agent .fp-switch a[aria-current] { color: var(--ink); }
/* /agent is always dark, whatever the Homes side is set to: it always uses the dark glass */
.side-agent {
  --g-fill: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .055));
  --g-fill-hi: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .085));
  --g-edge: inset 0 1px 0 rgba(255, 255, 255, .2), inset 0 0 0 1px rgba(255, 255, 255, .08), inset 0 -1px 0 rgba(0, 0, 0, .22);
  --g-drop: 0 4px 14px -6px rgba(0, 0, 0, .6);
  --g-thumb: linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, .15));
  --g-thumb-edge: inset 0 1px 0 rgba(255, 255, 255, .38), inset 0 0 0 1px rgba(255, 255, 255, .12), 0 3px 10px -3px rgba(0, 0, 0, .55);
  --g-prime-sheen: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%);
  --g-prime-edge: inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 -1px 0 rgba(0, 0, 0, .12), 0 6px 18px -8px rgba(0, 0, 0, .7);
  --g-track: rgba(0, 0, 0, .28);
  --g-track-edge: inset 0 1px 2px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .06);
}

/* chip groups (dates, filters, pages, tabs): each chip is glass, the chosen one is the bright glass thumb */
.side-agent :is(.chips, .date-chips, .rd-pages, .hq-tabs, .mc-life, .fb-when, .fb-lang, .ks-deals) button:not(.on) {
  background: var(--g-fill) !important; border-color: transparent !important; box-shadow: var(--g-edge);
}
.side-agent :is(.chips, .date-chips, .rd-pages, .hq-tabs, .mc-life, .fb-when, .fb-lang, .ks-deals, .tm-bar .seg) button.on {
  background: var(--g-thumb) !important; border-color: transparent !important; box-shadow: var(--g-thumb-edge) !important; color: var(--ink) !important;
}

/* toggles: a sunk track, a glass knob; on, the track fills */
.side-agent .switch i { background: var(--g-track); box-shadow: var(--g-track-edge); }
.side-agent .switch i::after { background: linear-gradient(180deg, #fff, #e6e6ea); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .1), 0 2px 6px rgba(0, 0, 0, .4); }
.side-agent .switch input:checked + i { background: #34c759; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2); }

/* the /agent bar floats over the page: its switch is the one real frosted surface */
.side-agent .fp-switch { -webkit-backdrop-filter: blur(20px) saturate(1.5); backdrop-filter: blur(20px) saturate(1.5); }

/* ---------------------------------------------------------------- 3. accessibility */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .side-agent :is(.btn-ghost, .tb-btn, .topbar .bell, .topbar .profile-btn, .pad-ib:hover, .chips button, .date-chips button, .rd-pages button, .hq-tabs button, .mc-life button, .fb-when button, .fb-lang button, .ks-deals button) {
    background: var(--raised) !important; box-shadow: inset 0 0 0 1px var(--line-2) !important;
  }
  .side-agent :is(.seg, .cur-sw, .fp-switch, .hb-view) { background: var(--panel-2) !important; box-shadow: inset 0 0 0 1px var(--line-2) !important; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .side-agent :is(.seg .seg-pill, .fp-switch-pill, .cur-sw button.on, .hb-view button.on, .chips button.on, .date-chips button.on, .rd-pages button.on, .hq-tabs button.on, .mc-life button.on, .fb-when button.on, .fb-lang button.on, .ks-deals button.on) { background: var(--raised) !important; box-shadow: inset 0 0 0 1.5px var(--ink-3) !important; }
}

/* ---------------------------------------------------------------- the agency at the top of the bar, 40% smaller */
.rail-brand.is-agency { gap: 9px; padding: 14px 16px 10px; }
.rail-brand .ab-logo { width: 28px; height: 28px; border-radius: 8px; }
.rail-brand .ab-logo b { font-size: 13px; }
.rail-brand .ab-t strong { font-size: 10px; line-height: 1.2; }

/* ---------------------------------------------------------------- 4. glass that answers the pointer, the way Apple's
   interactive glass does: a light spot follows the pointer across the surface, the control swells a little under it
   and leans toward it, a press squeezes it in and lights it up, and on release it springs back with a small bounce.
   glass.js keeps --gx/--gy (where the pointer is, in %) and --lx/--ly (the lean, in px) up to date. */
.side-agent :is(.btn, .tb-btn, .topbar .bell, .topbar .profile-btn, .date-chips button, .chips button, .fp-btn, .ag-cta, .fp-switch a, .rd-pages button) {
  position: relative; isolation: isolate;
  transform: translate(var(--lx, 0px), var(--ly, 0px)) scale(var(--gs, 1));
  transition: transform 520ms cubic-bezier(.34, 1.56, .64, 1) !important;
  will-change: transform;
}
.side-agent :is(.btn, .tb-btn, .topbar .bell, .topbar .profile-btn, .date-chips button, .chips button, .fp-btn, .ag-cta, .fp-switch a, .rd-pages button)::before {
  content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 140% at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .32), rgba(255, 255, 255, .06) 38%, transparent 64%);
  opacity: 0; transition: opacity 260ms ease !important;
}
:root[data-theme='light'] .side-agent :is(.btn, .tb-btn, .topbar .bell, .topbar .profile-btn, .date-chips button, .chips button, .rd-pages button)::before {
  background: radial-gradient(120% 140% at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .95), rgba(255, 255, 255, .25) 40%, transparent 66%);
}
/* the dark main action lights up dark-on-light: its spot is a soft shine */
.side-agent :is(.btn-primary, .btn-add, .fp-btn, .ag-cta)::before {
  background: radial-gradient(110% 130% at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .7), rgba(255, 255, 255, 0) 60%);
}
.lg-on { --gs: 1.035; }
.lg-on::before { opacity: 1 !important; }
.lg-down { --gs: 1.07; transition-duration: 160ms !important; }
.lg-down::before { opacity: 1 !important; filter: brightness(1.35); }
.side-agent :is(.btn, .fp-btn, .ag-cta):active:not(:disabled) { transform: translate(var(--lx, 0px), var(--ly, 0px)) scale(var(--gs, 1)) !important; }
/* the chosen thumb of a switch glides to its new place with a liquid overshoot */
.side-agent :is(.seg .seg-pill, .fp-switch-pill) { transition: transform 560ms cubic-bezier(.3, 1.45, .5, 1), width 560ms cubic-bezier(.3, 1.45, .5, 1) !important; }

@media (prefers-reduced-motion: reduce) {
  .lg-on, .lg-down { --gs: 1; --lx: 0px; --ly: 0px; }
  .side-agent :is(.seg .seg-pill, .fp-switch-pill) { transition-duration: 0ms !important; }
}
@media (prefers-reduced-transparency: reduce) { .lg-on::before, .lg-down::before { opacity: 0 !important; } }

/* ---------------------------------------------------------------- Keyper: the round button and its window */
.kp-fab { position: fixed; right: 22px; bottom: 22px; z-index: 60; width: 58px; height: 58px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--g-fill), #2a2a2e; box-shadow: var(--g-edge), 0 10px 28px -10px rgba(0, 0, 0, .75);
  transition: transform 520ms cubic-bezier(.34, 1.56, .64, 1) !important; }
.kp-fab img { width: 100%; height: 100%; border-radius: 50%; display: block; }
.kp-fab:hover { transform: scale(1.06); }
.kp-fab:active { transform: scale(.94); transition-duration: 120ms !important; }
.kp-fab.on { transform: scale(.92); }
.kp-fab:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.kp-fab[hidden] { display: none; }
:root[data-theme='light'] .kp-fab { background: var(--g-fill), #fff; box-shadow: var(--g-edge), 0 10px 26px -10px rgba(20, 24, 40, .35); }

.kp-pop { position: fixed; right: 22px; bottom: 92px; z-index: 61; width: min(420px, calc(100vw - 44px)); height: min(640px, calc(100dvh - 120px));
  display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--line-2); box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .7), 0 0 0 .5px rgba(255, 255, 255, .06);
  transform-origin: bottom right; animation: kp-in 340ms cubic-bezier(.34, 1.4, .64, 1) both; }
:root:not([data-theme='light']) body[data-area='agent'] .kp-pop { background: #1f1f22; }
.kp-pop[hidden] { display: none; }
@keyframes kp-in { from { opacity: 0; transform: translateY(12px) scale(.94); } }
.kp-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.kp-head img { border-radius: 50%; flex: none; }
.kp-head b { font-size: 15px; font-weight: 700; }
.kp-head .beta { margin-right: auto; font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: var(--fill); color: var(--ink-2); }
.kp-ic { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; }
.kp-ic:hover { background: var(--fill); color: var(--ink); }
.kp-ic .icon { width: 18px; height: 18px; }
.kp-body { min-height: 0; }
.kp-body iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--panel); }
@media (max-width: 640px) {
  /* phones: above the bottom bar, and the window takes the whole screen */
  .kp-fab { right: 14px; bottom: calc(62px + env(safe-area-inset-bottom) + 14px); width: 52px; height: 52px; }
  .kp-pop { inset: 0; width: auto; height: auto; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
}
@media (prefers-reduced-motion: reduce) { .kp-pop { animation: none; } .kp-fab { transition: none !important; } }

/* inside the window: the chat alone, no side bar, no top bar, no frame */
html.kp-embed .rail, html.kp-embed .topbar, html.kp-embed .nav-sheet, html.kp-embed .kp-fab { display: none !important; }
html.kp-embed body .shell { display: block !important; padding: 0 !important; height: 100dvh; }
html.kp-embed body .main { border: 0 !important; border-radius: 0 !important; height: 100dvh; }
html.kp-embed body .content { padding: 0 !important; }
html.kp-embed .kei { border-top: 0; }
/* Keyper sits clear of the window edges */
@media (min-width: 641px) { .kp-fab { right: 40px; bottom: 40px; } .kp-pop { right: 40px; bottom: 110px; } }
@media (max-width: 640px) { .kp-fab { right: 22px; bottom: calc(62px + env(safe-area-inset-bottom) + 24px); } }
/* inside the Keyper window the chat fills the whole height, so the message box sits at the bottom */
html.kp-embed body .content { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
html.kp-embed body .view { flex: 1; min-height: 0; display: flex; }
html.kp-embed .kei { flex: 1; min-height: 0; }
html.kp-embed body .main { padding-bottom: 0 !important; }
html.kp-embed body .content { height: 100% !important; }
