/* ============================================================================
   ClaudeLight site chrome — the header, app bar and footer on EVERY page
   (marketing pages, PIF, AMM, Expense). Markup: shared/site-chrome/chrome.php.

   Everything is namespaced .cl-* so it cannot collide with page or app CSS, and
   colours are variables that FALL BACK to the site palette: pages that define
   --ink / --paper / --sage … (index, dark, quote, pif, amm, PIF app) restyle the
   chrome with their theme automatically; apps with other token names (AMM,
   Expense) get the exact site look from the fallbacks.
   ============================================================================ */

.cl-header, .cl-appbar, .cl-footer {
  --cl-ink:        var(--ink, #0f1a14);
  --cl-ink-muted:  var(--ink-muted, #4a5a52);
  --cl-ink-faint:  var(--ink-faint, #8a9a90);
  --cl-paper:      var(--paper, #f7f5f0);
  --cl-surface:    var(--white, #ffffff);
  --cl-sage:       var(--sage, #2d5a3d);
  --cl-sage-light: var(--sage-light, #e8f0ea);
  --cl-gold:       var(--gold, #c8a84b);
  --cl-rule:       var(--rule, #d8d4cc);
  --cl-navy:       var(--brand-navy, #051638);
  --cl-brand-gold: var(--brand-gold, #a97526);
  --cl-radius:     4px;
  --cl-radius-lg:  12px;
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  box-sizing: border-box;
}
.cl-header *, .cl-appbar *, .cl-footer * { box-sizing: border-box; }
.cl-palette-fixed {
  --cl-ink: #0f1a14; --cl-ink-muted: #4a5a52; --cl-ink-faint: #8a9a90; --cl-paper: #f7f5f0; --cl-surface: #ffffff;
  --cl-sage: #2d5a3d; --cl-sage-light: #e8f0ea; --cl-gold: #c8a84b; --cl-rule: #d8d4cc;
  --cl-navy: #051638; --cl-brand-gold: #a97526;
}
/* Header height incl. its 1px border — apps size full-height shells with it. */
:root { --cl-header-h: 69px; }

/* ─── HEADER ─── */
.cl-header {
  z-index: 100; left: 0; right: 0; top: 0;
  background: color-mix(in srgb, var(--cl-paper) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--cl-rule);
  transition: box-shadow 0.3s;
  line-height: 1.4;
  font-size: 15px;
}
.cl-header.cl-mode-site { position: fixed; }
.cl-header.cl-mode-app  { position: sticky; }
.cl-header.scrolled, .cl-header.cl-scrolled { box-shadow: 0 2px 20px rgba(15, 26, 20, 0.08); }
.cl-header-inner {
  height: 68px; padding: 0 clamp(1.25rem, 5vw, 3rem);
  display: flex; align-items: center; justify-content: space-between; gap: 1.25rem;
  max-width: none; margin: 0;
}

.cl-logo { display: flex; align-items: center; gap: 10px; text-decoration: none !important; flex-shrink: 0; }
.cl-logo img { width: 36px; height: 36px; object-fit: contain; display: block; }
.cl-wordmark {
  font-family: 'Cinzel', 'DM Serif Display', Georgia, serif;
  font-size: 1.15rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
  line-height: 1;
}
.cl-header .cl-wm-claude { color: var(--cl-navy); }
/* Product lockup: the wordmark with the product name beneath (PIF, AMM). */
.cl-logo-stack { display: flex; flex-direction: column; justify-content: center; line-height: 1.02; }
.cl-logo-sub { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--cl-ink-faint); margin-top: 3px; }

/* Product app header (PIF): the app's own menu instead of the site menu. */
.cl-app-header .cl-nav { justify-content: flex-start; gap: 0.1rem; margin-left: 1.25rem; }
.cl-app-header .cl-nav > a { padding: 0.35rem 0.7rem; border-radius: var(--cl-radius); font-size: 0.86rem; }
.cl-app-header .cl-nav > a:hover { background: var(--cl-sage-light); }
.cl-app-header .cl-nav > a.active, .cl-mobile a.active { color: var(--cl-sage); font-weight: 500; }
@media (min-width: 861px) and (max-width: 1080px) {
  .cl-app-header .cl-nav { display: flex; }
  .cl-app-header .cl-actions .cl-account { display: flex; }
  .cl-app-header .cl-hamburger { display: none; }
  .cl-app-header .cl-nav { margin-left: 0.75rem; }
  .cl-app-header .cl-nav > a { padding: 0.35rem 0.5rem; font-size: 0.84rem; }
}
/* An admin's app menu (7+ links) does not fit beside the account button below ~1000px:
   use the hamburger there instead of pushing the account menu off-screen. */
@media (min-width: 861px) and (max-width: 999px) {
  .cl-app-header:has(.cl-nav > a:nth-of-type(7)) .cl-nav { display: none; }
  .cl-app-header:has(.cl-nav > a:nth-of-type(7)) .cl-hamburger { display: flex; }
}
.cl-header .cl-wm-light  { color: var(--cl-brand-gold); }

.cl-nav { display: flex; align-items: center; gap: 1.25rem; flex: 1; justify-content: flex-end; }
.cl-nav > a, .cl-dd-toggle {
  font-size: 0.9rem; font-weight: 400; color: var(--cl-ink-muted); text-decoration: none;
  white-space: nowrap; background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit;
  transition: color 0.2s; line-height: 1.4;
}
.cl-nav > a:hover, .cl-dd-toggle:hover, .cl-dd.open > .cl-dd-toggle { color: var(--cl-sage); }
.cl-dd-toggle { display: inline-flex; align-items: center; gap: 5px; }
.cl-ico { width: 12px; height: 12px; flex-shrink: 0; }
.cl-dd-toggle .cl-ico { transition: transform 0.25s; }
.cl-dd.open > .cl-dd-toggle .cl-ico { transform: rotate(180deg); }

.cl-dd { position: relative; }
.cl-dd-menu {
  position: absolute; top: 100%; left: 0; margin-top: 0.75rem; min-width: 250px;
  background: var(--cl-surface); border: 1px solid var(--cl-rule); border-radius: var(--cl-radius-lg);
  box-shadow: 0 12px 32px rgba(15, 26, 20, 0.14); padding: 0.4rem;
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s; z-index: 120; text-align: left;
}
.cl-dd-menu.cl-dd-right { left: auto; right: 0; }
.cl-dd.open > .cl-dd-menu { opacity: 1; visibility: visible; transform: translateY(0); }
@media (hover: hover) and (min-width: 1081px) {
  .cl-dd:hover > .cl-dd-menu, .cl-dd:focus-within > .cl-dd-menu { opacity: 1; visibility: visible; transform: translateY(0); }
  .cl-dd:hover > .cl-dd-toggle { color: var(--cl-sage); }
}
/* bridge the gap so the menu doesn't close while the pointer crosses it */
.cl-dd-menu::before { content: ''; position: absolute; left: 0; right: 0; top: -0.8rem; height: 0.8rem; }
.cl-dd-menu a {
  display: block; padding: 0.55rem 0.8rem; border-radius: var(--cl-radius);
  font-size: 0.88rem; color: var(--cl-ink-muted); text-decoration: none; white-space: nowrap;
}
.cl-dd-menu a:hover { background: var(--cl-sage-light); color: var(--cl-sage); }
.cl-dd-menu hr { border: 0; border-top: 1px solid var(--cl-rule); margin: 0.3rem 0; }
.cl-dd-head { padding: 0.55rem 0.8rem 0.4rem; display: flex; flex-direction: column; gap: 2px; }
.cl-dd-head strong { color: var(--cl-ink); font-weight: 500; font-size: 0.9rem; }
.cl-dd-head span { color: var(--cl-ink-faint); font-size: 0.78rem; }
.cl-dd-label { display: block; padding: 0.35rem 0.8rem 0.15rem; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cl-ink-faint); }

/* Product menu: Product › (product row) › About X / Login X, opening to the right. */
.cl-flyout { position: relative; }
.cl-dd-menu a.cl-flyout-toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--cl-ink-muted); }
.cl-flyout-toggle .cl-ico { opacity: 0.6; transition: transform 0.2s, opacity 0.2s; }
.cl-flyout:hover > .cl-flyout-toggle, .cl-flyout:focus-within > .cl-flyout-toggle, .cl-flyout.open > .cl-flyout-toggle {
  background: var(--cl-sage-light); color: var(--cl-sage); box-shadow: inset 0 -2px 0 var(--cl-gold);
}
.cl-flyout:hover > .cl-flyout-toggle .cl-ico, .cl-flyout:focus-within > .cl-flyout-toggle .cl-ico, .cl-flyout.open > .cl-flyout-toggle .cl-ico { transform: translateX(2px); opacity: 1; }
.cl-flyout-menu {
  position: absolute; top: -0.4rem; left: calc(100% + 6px); min-width: 170px;
  background: var(--cl-surface); border: 1px solid var(--cl-rule); border-radius: var(--cl-radius-lg);
  box-shadow: 0 12px 32px rgba(15, 26, 20, 0.14); padding: 0.4rem; z-index: 1;
  opacity: 0; visibility: hidden; transform: translateX(6px); transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
/* Invisible bridge across the gap so the pointer never falls off between the two panels. */
.cl-flyout-menu::before { content: ''; position: absolute; top: 0; bottom: 0; right: 100%; width: 10px; }
.cl-flyout:hover > .cl-flyout-menu, .cl-flyout:focus-within > .cl-flyout-menu, .cl-flyout.open > .cl-flyout-menu {
  opacity: 1; visibility: visible; transform: translateX(0);
}
.cl-free {
  display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px;
  background: var(--cl-gold); color: #0f1a14; font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; vertical-align: middle; white-space: nowrap;
}

.cl-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.cl-btn {
  display: inline-flex; align-items: center; padding: 8px 18px; border-radius: var(--cl-radius);
  font-size: 0.9rem; font-weight: 500; text-decoration: none !important; white-space: nowrap;
  transition: background 0.2s, color 0.2s, transform 0.2s; line-height: 1.4;
}
.cl-btn:hover { transform: translateY(-1px); }
.cl-btn-gold { background: var(--cl-gold); color: #0f1a14 !important; }
.cl-btn-gold:hover { background: var(--cl-ink); color: var(--cl-paper) !important; }
.cl-btn-sage { background: var(--cl-sage); color: #fff !important; }
.cl-btn-sage:hover { background: var(--cl-ink); color: var(--cl-paper) !important; }

/* Account slot: .nav-login / .nav-user are also written by index/dark/quote renderAuthNav(). */
.cl-account { display: flex; align-items: center; gap: 8px; }
.cl-header .nav-login, .cl-user-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--cl-sage); color: var(--cl-sage) !important; background: transparent;
  padding: 6px 16px; border-radius: var(--cl-radius); font-size: 0.9rem; font-weight: 500;
  text-decoration: none !important; white-space: nowrap; cursor: pointer; font-family: inherit; line-height: 1.4;
  transition: background 0.2s, color 0.2s;
}
.cl-header .nav-login:hover, .cl-user-btn:hover, .cl-account.open .cl-user-btn { background: var(--cl-sage); color: #fff !important; }
.cl-header .nav-user { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--cl-ink-muted); white-space: nowrap; }
.cl-header .nav-user strong { color: var(--cl-ink); font-weight: 500; }
.cl-header .nav-user button { background: none; border: none; color: var(--cl-sage); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; text-underline-offset: 3px; }

.cl-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0;
  border-radius: 50%; border: 1.5px solid var(--cl-rule); background: none; color: var(--cl-ink-muted) !important; cursor: pointer;
  transition: color 0.2s, border-color 0.2s; flex-shrink: 0;
}
.cl-theme-toggle:hover { color: var(--cl-gold) !important; border-color: var(--cl-gold); }
.cl-theme-toggle svg { width: 18px; height: 18px; }

.cl-hamburger { display: none; flex-direction: column; gap: 5px; cursor: pointer; padding: 6px; background: none; border: 0; }
.cl-hamburger span { width: 22px; height: 2px; background: var(--cl-ink); display: block; border-radius: 2px; transition: transform 0.25s, opacity 0.25s; }
.cl-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.cl-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.cl-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.cl-mobile {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  background: var(--cl-paper); border-bottom: 1px solid var(--cl-rule); box-shadow: 0 12px 24px rgba(15, 26, 20, 0.08);
  padding: 1rem clamp(1.25rem, 5vw, 3rem) 1.25rem; flex-direction: column; gap: 0.1rem;
  max-height: calc(100vh - 68px); overflow-y: auto;
}
.cl-mobile.open { display: flex; }
.cl-mobile a { font-size: 1rem; color: var(--cl-ink); text-decoration: none; padding: 0.6rem 0; border-bottom: 1px solid var(--cl-rule); }
.cl-mobile a.cl-mobile-sub { padding-left: 1rem; color: var(--cl-ink-muted); font-size: 0.95rem; }
.cl-mobile-label { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cl-ink-faint); padding-top: 0.75rem; }
.cl-mobile-product { font-size: 0.9rem; color: var(--cl-ink); font-weight: 500; padding-top: 0.5rem; }
.cl-mobile a.cl-mobile-sub.cl-mobile-sub2 { padding-left: 2rem; }

/* The full link row needs ~1000px: below that it overflows — CLAUDE.md §14. */
@media (max-width: 1080px) {
  .cl-nav, .cl-actions .cl-btn, .cl-actions .cl-account, .cl-actions .cl-theme-toggle { display: none; }
  .cl-hamburger { display: flex; }
}
@media (max-width: 420px) {
  .cl-wordmark { font-size: 1rem; }
  .cl-logo img { width: 30px; height: 30px; }
}

/* ─── APP BAR (inside PIF / AMM / Expense, under the header) ─── */
.cl-appbar { background: var(--cl-surface); border-bottom: 1px solid var(--cl-rule); font-size: 14px; line-height: 1.4; }
.cl-appbar-inner {
  min-height: 46px; padding: 0 clamp(1.25rem, 5vw, 3rem);
  display: flex; align-items: center; gap: 1.5rem;
}
.cl-appbar-brand { display: inline-flex; align-items: baseline; gap: 0.5rem; text-decoration: none !important; flex-shrink: 0; }
.cl-appbar-name {
  font-family: 'Cinzel', Georgia, serif; font-weight: 600; letter-spacing: 0.08em; color: var(--cl-navy);
  font-size: 0.95rem; border-left: 2px solid var(--cl-gold); padding-left: 0.6rem;
}
.cl-appbar-full { color: var(--cl-ink-faint); font-size: 0.8rem; white-space: nowrap; }
.cl-appbar-links { display: flex; align-items: stretch; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.cl-appbar-links::-webkit-scrollbar { display: none; }
.cl-appbar-links a {
  padding: 0.75rem 0.7rem; color: var(--cl-ink-muted); text-decoration: none !important; white-space: nowrap;
  border-bottom: 2px solid transparent; font-size: 0.88rem;
}
.cl-appbar-links a:hover { color: var(--cl-sage); }
.cl-appbar-links a.active { color: var(--cl-sage); border-bottom-color: var(--cl-sage); font-weight: 500; }
.cl-appbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
@media (max-width: 720px) { .cl-appbar-full { display: none; } .cl-appbar-inner { gap: 0.75rem; } }

/* ─── FOOTER (dark in every theme) ─── */
.cl-footer { background: #080f0b; color: rgba(255, 255, 255, 0.72); font-size: 14px; line-height: 1.6; margin: 0; }
.cl-footer-inner {
  padding: 3rem clamp(1.25rem, 5vw, 3rem) 2rem;
  display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.3fr; gap: 2rem 2.5rem;
}
.cl-footer .cl-wm-claude { color: rgba(255, 255, 255, 0.88); }
.cl-footer .cl-wm-light  { color: #d4b85f; }
.cl-tagline { margin: 0.9rem 0 0.35rem; color: #d4b85f; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
.cl-footer-about { margin: 0; max-width: 34ch; color: rgba(255, 255, 255, 0.6); font-size: 0.88rem; }
.cl-footer h4 {
  margin: 0 0 0.9rem; font-family: inherit; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.45);
}
.cl-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.cl-footer a { color: rgba(255, 255, 255, 0.78); text-decoration: none; transition: color 0.2s; }
.cl-footer a:hover { color: #fff; }
.cl-footer .cl-free { margin-left: 6px; }
.cl-footer-contact li { display: flex; gap: 0.6rem; align-items: flex-start; }
.cl-footer-contact .cl-ico { width: 16px; height: 16px; margin-top: 3px; color: #d4b85f; }
.cl-footer-contact strong { color: rgba(255, 255, 255, 0.88); font-weight: 500; }
.cl-footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.25rem clamp(1.25rem, 5vw, 3rem) 1.5rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.cl-footer-data { margin: 0; font-size: 0.78rem; color: rgba(255, 255, 255, 0.5); max-width: 110ch; }
.cl-footer-data a { text-decoration: underline; text-underline-offset: 3px; }
.cl-footer-legal { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; font-size: 0.78rem; color: rgba(255, 255, 255, 0.55); }
.cl-footer-legal-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
@media (max-width: 900px) { .cl-footer-inner { grid-template-columns: 1fr 1fr; } .cl-footer-brand { grid-column: 1 / -1; } }
@media (max-width: 520px) { .cl-footer-inner { grid-template-columns: 1fr; } }

/* Dark themes need no rules here: dark.html and body.dark-theme (pif/amm) redefine
   --brand-navy / --paper / --ink …, and the variables above inherit them. */

@media (prefers-reduced-motion: reduce) {
  .cl-header, .cl-dd-menu, .cl-flyout-menu, .cl-btn, .cl-hamburger span { transition: none; }
}
@media print { .cl-header, .cl-appbar, .cl-footer { display: none !important; } }

/* ============================================================================
   MOBILE UTILITIES — shared by every surface (this file is loaded everywhere).
   Rule of thumb: numeric/data tables SCROLL (.cl-scroll, first column pinned);
   record lists STACK into cards (table.cl-stack + td[data-label]).
   ============================================================================ */

/* Sideways-scrolling data table. Put the table inside; mark cells of the first
   column .cl-pin to keep the row label visible while scrolling. */
.cl-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
  background:
    linear-gradient(to right, var(--cl-scroll-bg, #fff) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(to left, var(--cl-scroll-bg, #fff) 30%, transparent) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(15, 26, 20, 0.14), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(15, 26, 20, 0.14), transparent) right / 10px 100% no-repeat scroll;
}
.cl-scroll .cl-pin { position: sticky; left: 0; z-index: 1; background: var(--cl-scroll-bg, #fff); box-shadow: 1px 0 0 rgba(15, 26, 20, 0.08); }

/* Record lists → stacked cards on phones. Each <td> carries data-label="Column";
   an empty data-label marks an actions cell (full width, right aligned). */
@media (max-width: 640px) {
  table.cl-stack, table.cl-stack tbody, table.cl-stack tr, table.cl-stack td { display: block; width: 100% !important; }
  table.cl-stack { min-width: 0 !important; border: 0; }
  table.cl-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.cl-stack tr {
    background: var(--cl-stack-bg, #fff); border: 1px solid var(--cl-stack-rule, #d8d4cc) !important; border-radius: 10px;
    margin: 0 0 0.75rem; padding: 0.35rem 0.85rem; box-shadow: 0 1px 3px rgba(15, 26, 20, 0.05);
  }
  /* Label floats left; the cell's own content (text, several badges, a select…) flows
     inline on the right and wraps naturally — flex would squeeze each child separately. */
  table.cl-stack td {
    display: block !important; position: relative;
    padding: 0.45rem 0 0.45rem 38% !important; border: 0 !important; border-bottom: 1px solid rgba(15, 26, 20, 0.07) !important;
    text-align: right !important; white-space: normal !important; background: transparent !important;
    min-height: 2.1rem; overflow-wrap: break-word;
  }
  table.cl-stack td:last-child { border-bottom: 0 !important; }
  table.cl-stack td::before {
    content: attr(data-label); position: absolute; left: 0; top: 0.5rem; width: 36%;
    text-align: left; font-size: 0.72rem; font-weight: 600; line-height: 1.3;
    letter-spacing: 0.04em; text-transform: uppercase; color: #8a9a90;
  }
  table.cl-stack td[data-label=""], table.cl-stack td:not([data-label]) { padding-left: 0 !important; }
  table.cl-stack td[data-label=""]::before, table.cl-stack td:not([data-label])::before { content: none; display: none; }
  table.cl-stack .badge { white-space: normal; overflow-wrap: normal; word-break: normal; text-align: left; }
  /* Form controls inside a stacked cell fill the value column. */
  table.cl-stack td > input:not([type="checkbox"]):not([type="radio"]),
  table.cl-stack td > select, table.cl-stack td > textarea { width: 100% !important; max-width: 100% !important; }
  table.cl-stack td > form { display: inline-block; }
  /* A stacked table no longer needs its sideways-scroll wrapper. */
  .table-responsive:has(> table.cl-stack), .table-wrap:has(> table.cl-stack),
  .table-scroll:has(> table.cl-stack), .cl-scroll:has(> table.cl-stack) { overflow: visible; background: none; }
}

/* Phone form basics: 16px text stops iOS zooming on focus; comfortable tap targets. */
@media (max-width: 640px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px !important; }
  .cl-tap { min-height: 40px; min-width: 40px; }
}

/* Pop-up containment: never taller than the screen; bottom sheet on phones. */
.cl-sheet { max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 640px) {
  .cl-sheet-wrap { align-items: flex-end !important; padding: 0 !important; }
  .cl-sheet-wrap > .cl-sheet {
    width: 100% !important; max-width: 100% !important; margin: 0 !important;
    border-radius: 16px 16px 0 0 !important; max-height: 92vh; max-height: 92dvh;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
  }
}

/* ─── Marketing pages: login pop-up (index, dark, quote) ───
   The OTP sign-up step is ~560px tall; on a phone (or with the keyboard open) the centred
   box had no way to scroll to its top or bottom. Contain it and make it a bottom sheet. */
.auth-overlay .auth-modal { max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 640px) {
  .auth-overlay { align-items: flex-end !important; padding: 0 !important; }
  .auth-overlay .auth-modal {
    max-width: 100% !important; border-radius: 16px 16px 0 0 !important;
    padding: 1.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)) !important;
    max-height: 92vh; max-height: 92dvh;
  }
}
@media (max-width: 420px) { .auth-overlay .auth-row { grid-template-columns: 1fr !important; } }

/* ─── Marketing pages: product quick-access rail (assets/product-access.css) ───
   The cookie banner (z 9000, full width, pinned to the bottom) covers the rail's tabs until a
   choice is made: about 80-110px on a laptop, 200px+ stacked on a phone. Keep the rail out of
   the way while the banner is up, at every width, exactly as the Share tab does below. */
body:has(.cc-banner) .qa-rail { display: none; }
@media (max-width: 720px) {
  .qa-rail { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* ============================================================================
   PRODUCT SHARE — the sticky Share tab and its dialog, on every page.

   Shares a PRODUCT (the ClaudeLight site, PIF or AMM) and nothing else: never a
   calculation, a history row, or anything belonging to the signed-in user. The
   wording is each product page's reviewed og:title / og:description, so what a
   visitor sends matches what the link unfurls to.

   It lives in this file, not its own, because every surface already loads this
   stylesheet — the marketing pages and PIF link it directly; AMM, Expense and
   site/profile.php get it from cl_head_assets() — so "on every page" is true by
   construction rather than by remembering to add a <link> to each new page.

   The tab sits on the LEFT edge, mirroring the product rail on the right
   (assets/product-access.css), so the two never collide on the marketing pages
   that carry both. It replaces that rail's old bare-mailto .qa-share tab, which
   did nothing at all in a browser with no mail handler registered.

   Behaviour: assets/site-chrome.js.
   ============================================================================ */

.cl-share-tab, .cl-share-wrap {
  --cl-ink:        var(--ink, #0f1a14);
  --cl-ink-muted:  var(--ink-muted, #4a5a52);
  --cl-ink-faint:  var(--ink-faint, #8a9a90);
  --cl-paper:      var(--paper, #f7f5f0);
  --cl-surface:    var(--white, #ffffff);
  --cl-sage:       var(--sage, #2d5a3d);
  --cl-sage-light: var(--sage-light, #e8f0ea);
  --cl-gold:       var(--gold, #c8a84b);
  --cl-rule:       var(--rule, #d8d4cc);
  --cl-radius:     4px;
  --cl-radius-lg:  12px;
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  box-sizing: border-box;
}
.cl-share-tab *, .cl-share-wrap * { box-sizing: border-box; }

/* Apps whose own --ink/--paper mean something else (AMM, Expense) get the site
   palette pinned, the same way cl_footer does with 'palette' => 'fixed'. */
.cl-share-tab.cl-palette-fixed, .cl-share-wrap.cl-palette-fixed {
  --cl-ink: #0f1a14; --cl-ink-muted: #4a5a52; --cl-ink-faint: #8a9a90; --cl-paper: #f7f5f0; --cl-surface: #ffffff;
  --cl-sage: #2d5a3d; --cl-sage-light: #e8f0ea; --cl-gold: #c8a84b; --cl-rule: #d8d4cc;
}

/* --- the sticky tab --- */
.cl-share-tab {
  position: fixed; left: 0; bottom: 28px;
  /* 45 sits UNDER AMM's phone nav drawer (50) and modal overlay (80), so those
     cover it natively even in a browser without :has(); the :has() rules below
     then hide it outright. Nothing else on any page lives between 45 and 90
     except the Product menu's flyout (51), which opens inside the header. */
  z-index: 45;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 46px; min-height: 60px; padding: 8px 0;
  background: var(--cl-ink); color: var(--cl-paper);   /* inverts with the theme, like the rail */
  border: 1px solid var(--cl-ink); border-left: 0;
  border-radius: 0 var(--cl-radius-lg) var(--cl-radius-lg) 0;
  /* The faint light ring is invisible against a light page but outlines the tab
     where the page background IS --ink — quote.html's default dark view paints
     body with var(--ink), which would otherwise swallow the tab entirely. */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), 0 8px 24px rgba(15, 26, 20, 0.12);
  cursor: pointer; font: inherit;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.cl-share-tab svg { width: 18px; height: 18px; }
.cl-share-tab .cl-share-label {
  font-size: 0.55rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1;
}
.cl-share-tab:hover, .cl-share-tab:focus-visible {
  background: var(--cl-gold); color: #0f1a14; border-color: var(--cl-gold); transform: translateX(2px);
}
.cl-share-tab:focus-visible { outline: 2px solid var(--cl-ink); outline-offset: 2px; }

/* --- the dialog: a centred card on a laptop, a bottom sheet on a phone ---
   It borrows .cl-sheet-wrap / .cl-sheet above, so the share sheet rises from the
   bottom edge exactly like the marketing login pop-up does. */
.cl-share-wrap {
  position: fixed; inset: 0;
  z-index: 9600;                    /* over the cookie banner (9000) and the header (100) */
  display: none; align-items: center; justify-content: center; padding: 1rem;
  background: rgba(8, 16, 12, 0.55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  overscroll-behavior: contain;     /* AMM scrolls .main, not body, so the body lock alone misses it */
}
.cl-share-wrap.cl-open { display: flex; }

.cl-share-panel {
  width: 100%; max-width: 420px; padding: 1.15rem 1.15rem 1.25rem;
  background: var(--cl-surface); color: var(--cl-ink);
  border-radius: var(--cl-radius-lg);
  box-shadow: 0 24px 64px rgba(8, 16, 12, 0.3);
  text-align: left;
}
.cl-share-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.cl-share-head h2 {
  margin: 0; font-family: 'DM Serif Display', Georgia, serif; font-weight: 400;
  font-size: 1.25rem; line-height: 1.2; color: var(--cl-ink);
}
.cl-share-head p { margin: 0.2rem 0 0; font-size: 0.82rem; line-height: 1.4; color: var(--cl-ink-muted); }
.cl-share-x {
  flex: 0 0 auto; background: none; border: 0; padding: 0.3rem; margin: -0.3rem -0.3rem 0 0;
  color: var(--cl-ink-faint); cursor: pointer; line-height: 0; border-radius: var(--cl-radius);
}
.cl-share-x:hover { color: var(--cl-ink); background: var(--cl-sage-light); }
.cl-share-x svg { width: 20px; height: 20px; }

/* Which product am I sharing? Defaults to the one the visitor is looking at. */
.cl-share-prods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; margin-bottom: 0.9rem; }
.cl-share-prod {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 58px; padding: 0.55rem 0.3rem;
  background: var(--cl-surface); border: 1px solid var(--cl-rule); border-radius: var(--cl-radius-lg);
  color: var(--cl-ink-muted); font: inherit; text-align: center; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cl-share-prod b { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.03em; color: var(--cl-ink); }
.cl-share-prod span { font-size: 0.62rem; line-height: 1.25; }
.cl-share-prod:hover { border-color: var(--cl-sage); }
.cl-share-prod[aria-checked="true"] { background: var(--cl-sage-light); border-color: var(--cl-sage); color: var(--cl-sage); }
.cl-share-prod[aria-checked="true"] b { color: var(--cl-sage); }
.cl-share-prod:focus-visible { outline: 2px solid var(--cl-sage); outline-offset: 2px; }

.cl-share-blurb { margin: 0 0 0.75rem; font-size: 0.84rem; line-height: 1.5; color: var(--cl-ink-muted); }
.cl-share-link { display: flex; gap: 0.4rem; margin-bottom: 0.9rem; }
.cl-share-link input {
  flex: 1 1 auto; min-width: 0; padding: 0.55rem 0.6rem;
  font: inherit; font-size: 0.8rem; color: var(--cl-ink-muted);
  background: var(--cl-paper); border: 1px solid var(--cl-rule); border-radius: var(--cl-radius);
}

/* Channels. The native share sheet spans the row when the browser offers one. */
.cl-share-ch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.45rem; }
.cl-share-ch a, .cl-share-ch button {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0.55rem 0.6rem;                 /* comfortable thumb target */
  background: var(--cl-surface); color: var(--cl-ink);
  border: 1px solid var(--cl-rule); border-radius: var(--cl-radius-lg);
  font: inherit; font-size: 0.85rem; text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cl-share-ch a:hover, .cl-share-ch button:hover,
.cl-share-ch a:focus-visible, .cl-share-ch button:focus-visible {
  background: var(--cl-sage-light); border-color: var(--cl-sage); color: var(--cl-sage);
}
.cl-share-ch svg { width: 17px; height: 17px; flex: 0 0 17px; }
/* Text is --cl-paper, not #fff: in the dark theme --sage becomes a LIGHT green,
   and white-on-light-green failed contrast. --paper inverts with the theme, so
   this stays dark-on-light there and light-on-dark here. */
.cl-share-ch .cl-share-primary {
  grid-column: 1 / -1; background: var(--cl-sage); border-color: var(--cl-sage); color: var(--cl-paper);
}
.cl-share-ch .cl-share-primary:hover, .cl-share-ch .cl-share-primary:focus-visible {
  background: var(--cl-ink); border-color: var(--cl-ink); color: var(--cl-paper);
}

/* Honest feedback: it says what actually happened, never "Copied" on a failure. */
.cl-share-note { margin: 0.7rem 0 0; min-height: 1.15em; font-size: 0.75rem; text-align: center; color: var(--cl-ink-faint); }
.cl-share-note.cl-ok { color: var(--cl-sage); }

/* Get out of the way of what an app is doing. The tab sits at z-index 90, which
   is ABOVE AMM's modal overlay (80) and its phone nav drawer (50) — so without
   these it floats, tappable, over an unsaved edit form or an open menu. Both
   elements are transient (#modalRoot is emptied on close; nav-open is toggled),
   so the tab returns the moment they go. */
body:has(.modal-overlay) .cl-share-tab,
body:has(.app.nav-open) .cl-share-tab { display: none; }

/* The cookie banner (z 9000, full-width, pinned to the bottom) buries the tab
   until a choice is made — about 80-110px tall on a laptop, 200px+ stacked on a
   phone. Hide it at EVERY width rather than leave it half-covered; the banner
   node is removed once a choice is made, so the tab comes straight back. */
body:has(.cc-banner) .cl-share-tab { display: none; }

/* PIF's Calculate button becomes a full-width sticky bar below 992px (pif.css),
   so lift the tab clear of the app's primary action on tablets as well as phones. */
@media (max-width: 991px) {
  body:has(.pif-calc-submit) .cl-share-tab { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

@media (max-width: 720px) {
  .cl-share-tab { bottom: calc(96px + env(safe-area-inset-bottom)); width: 40px; min-height: 44px; padding: 6px 0;
                  transition: background 0.2s, color 0.2s, transform 0.25s ease, opacity 0.25s ease; }
  /* Slid off the edge while the visitor scrolls down (assets/site-chrome.js). */
  .cl-share-tab.cl-share-away { transform: translateX(-110%); opacity: 0; pointer-events: none; }
  .cl-share-tab svg { width: 16px; height: 16px; }
  .cl-share-tab .cl-share-label { display: none; }
}
@media (max-width: 360px) {
  .cl-share-prod span { display: none; }                     /* the acronym alone still identifies it */
  .cl-share-prod { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  .cl-share-tab, .cl-share-prod, .cl-share-ch a, .cl-share-ch button, .cl-share-x { transition: none; }
  /* Still gets out of the way, just without the slide. */
  .cl-share-tab.cl-share-away { transition: none; }
}
@media print { .cl-share-tab, .cl-share-wrap { display: none !important; } }
