/* layan.ai — home: the app shell. Glass panels over drifting light, an ember wisp for Layan, a side rail on desktop and a
   bottom tab bar on phones. Every number on this page comes from GET /api/home/summary or a live event; nothing here is
   sample data, and a value the API has not reported yet is shown as "not connected yet" rather than invented. */

.home-body { background: var(--abyss); overflow-x: hidden; }

/* a very faint grain over the whole shell, mood-referenced (glass + drifting light), never an external image */
.home-body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- welcome (no account session) ---------- */
/* a class selector's `display` beats the UA rule for [hidden], so both must be re-stated explicitly here */
.welcome[hidden], .shell[hidden] { display: none !important; }
.welcome { position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: var(--s-5); }
/* the welcome-bg holds whichever hero the visitor gets (streams or the idle wisp) behind a gradient wash, so the
   sign-in card is readable either way; z-index: -1 sits it under the card within .welcome's own stacking context */
.welcome-bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(60% 55% at 50% 30%, rgba(37, 78, 193, 0.35), transparent 70%), var(--abyss); }
.welcome-streams, .welcome-wisp { position: absolute; inset: 0; width: 100%; height: 100%; }
.welcome-card { position: relative; width: min(420px, 100%); padding: var(--s-6) var(--s-5); border-radius: var(--r-xl); background: var(--glass-2); border: 1px solid var(--line-strong); backdrop-filter: blur(20px); box-shadow: var(--shadow-panel); text-align: center; }
.welcome-mark { margin: 0 auto var(--s-4); width: 56px; height: 56px; }
.welcome-card h1 { font-size: var(--fs-2xl); margin-bottom: var(--s-2); }
.welcome-card p.lede { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s-5); }
.welcome-actions { display: flex; flex-direction: column; gap: var(--s-3); }
.welcome-or { color: var(--muted); font-size: var(--fs-xs); margin: var(--s-2) 0; }
.welcome-login { display: flex; gap: var(--s-2); }
.welcome-login input { flex: 1; min-width: 0; }
.welcome-note { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s-3); text-align: left; }
.welcome-note a { color: var(--signal); text-decoration: underline; }
.welcome-explore { margin-top: var(--s-5); font-size: var(--fs-xs); }
.welcome-explore a { color: var(--muted); text-decoration: underline; }
.welcome-explore a:hover { color: var(--frost); }

/* ---------- shell ---------- */
.shell { position: relative; z-index: 1; display: flex; min-height: 100vh; min-height: 100dvh; }

.rail {
  width: 232px; flex: none; display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-4) var(--s-3); border-right: 1px solid var(--line);
  background: rgba(7, 20, 51, 0.45); backdrop-filter: blur(14px);
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
.rail-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; padding: 4px 6px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: var(--r-md); color: var(--frost); font-size: var(--fs-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.rail-nav button svg { flex: none; opacity: 0.85; }
.rail-nav button:hover { background: rgba(170, 206, 253, 0.06); color: var(--paper); }
.rail-nav button.is-on { background: rgba(96, 157, 252, 0.14); color: var(--paper); box-shadow: inset 0 0 0 1px var(--line-strong); }
.rail-nav button .count { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }
.rail-nav button.is-locked { color: var(--muted); }
.rail-nav button .lock-tag { margin-left: auto; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.rail-foot { display: flex; flex-direction: column; gap: var(--s-2); border-top: 1px solid var(--line); padding-top: var(--s-3); }
.rail-who { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-signout { align-self: flex-start; font-size: var(--fs-xs); color: var(--muted); text-decoration: underline; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); flex: none; }
.stage-bar h1 { font-size: var(--fs-lg); font-weight: 600; }
.stage-bar .stage-badge { display: flex; gap: var(--s-2); }
.sections { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.sec { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; display: none; }
.sec.is-on { display: block; }
.sec-embed { display: none; padding: 0; }
.sec-embed.is-on { display: flex; flex-direction: column; }
.sec-embed iframe { width: 100%; height: 100%; border: 0; flex: 1; background: var(--abyss); }
.sec-locked { display: flex; align-items: center; justify-content: center; height: 100%; padding: var(--s-6); text-align: center; }
.sec-locked-card { max-width: 420px; }
.sec-locked-card .pill { margin-bottom: var(--s-3); }
.sec-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; padding: var(--s-6); text-align: center; color: var(--muted); }

/* bottom tab bar: phones only */
.tabbar { display: none; }

@media (max-width: 900px) {
  .rail { display: none; }
  .stage { height: calc(100vh - 58px); height: calc(100dvh - 58px); }
  .tabbar {
    display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 2px; flex: none; height: 58px;
    border-top: 1px solid var(--line); background: rgba(7, 20, 51, 0.85); backdrop-filter: blur(14px);
    padding: 0 4px; order: 2;
  }
  .shell { flex-direction: column; }
  .tabbar button {
    flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-width: 68px; padding: 6px 8px; color: var(--muted); font-size: 0.66rem;
  }
  .tabbar button.is-on { color: var(--signal); }
  .tabbar button svg { width: 18px; height: 18px; }
}

/* ---------- Home section ---------- */
/* Hero 1 (streams): fills the visible section behind everything, flowing toward the composer; a few floating agent
   chips sit over it, styled after index.html's cursor tags. Sized to #sec-home's own box (fixed to the stage's
   visible area, see .sec above) rather than its scrolled content, so it lines up with the fixed composer. */
.home-hero-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.home-streams-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.home-hero-chips { position: absolute; inset: 0; }
.home-chip {
  position: absolute; left: var(--x); top: var(--y); z-index: 1;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-xs); font-weight: 500; color: var(--paper);
  padding: 6px 12px 6px 10px; border-radius: 4px 12px 12px 12px;
  background: var(--cobalt); box-shadow: 0 10px 30px -10px rgba(37, 78, 193, 0.8);
  animation: home-chip-drift 9s ease-in-out infinite; animation-delay: var(--d);
  white-space: nowrap; max-width: 46vw;
}
.home-chip-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--paper); }
@keyframes home-chip-drift {
  0%, 100% { transform: translate(0, 0); }
  30% { transform: translate(12px, -8px); }
  60% { transform: translate(-6px, 10px); }
}
@media (prefers-reduced-motion: reduce) { .home-chip { animation: none; } }
@media (max-width: 720px) { .home-chip { display: none; } }

.home-sec { position: relative; z-index: 1; padding: var(--s-6) var(--s-5) calc(var(--s-9) + 96px); max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: var(--s-5); text-align: center; }
.home-greet { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-lg); color: var(--paper); margin-top: var(--s-3); }
.home-greet-speak { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--frost); }
.home-greet-speak:hover { background: rgba(170, 206, 253, 0.08); }

.home-stage { position: relative; width: min(320px, 78vw); height: min(320px, 78vw); display: flex; align-items: center; justify-content: center; }
/* .home-stage sets its own `display`, which otherwise beats the UA [hidden] rule; hero 1 hides the wisp stage this way */
.home-stage[hidden], .home-hero-bg[hidden] { display: none; }
.home-wisp-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.home-ring { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--signal) 55%, transparent); pointer-events: none; transition: transform 90ms linear, opacity 90ms linear, box-shadow 120ms linear; }
.home-ring-2 { border-color: color-mix(in srgb, var(--frost) 30%, transparent); }
@media (prefers-reduced-motion: reduce) { .home-ring { transition: none; } }

.home-captions { min-height: 2.6em; max-width: 52ch; color: var(--frost); font-size: var(--fs-md); }
.home-captions .cap-progress { display: block; color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }
.home-captions .cap-note { display: block; color: var(--warn); font-size: var(--fs-xs); margin-top: 4px; }

.home-sats { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; max-width: 100%; }
.sat-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: var(--r-pill);
  background: rgba(170, 206, 253, 0.06); border: 1px solid var(--line-strong); font-size: var(--fs-xs);
  animation: sat-in 220ms var(--ease-out);
}
.sat-chip .sat-orb { width: 9px; height: 9px; border-radius: 50%; background: hsl(var(--h, 214) 90% 62%); box-shadow: 0 0 8px hsl(var(--h, 214) 90% 62%); }
.sat-chip.is-working .sat-orb { animation: sat-pulse 1.1s ease-in-out infinite; }
.sat-chip.is-done .sat-orb { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.sat-chip .sat-check { color: var(--ok); }
@keyframes sat-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: 0.6; } }
@keyframes sat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sat-chip, .sat-chip .sat-orb { animation: none; } }

.home-approvals { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; max-width: 100%; }
.appr-chip {
  display: flex; align-items: center; gap: var(--s-3); padding: 8px 8px 8px 14px; border-radius: var(--r-pill);
  background: rgba(242, 184, 75, 0.08); border: 1px solid rgba(242, 184, 75, 0.35); font-size: var(--fs-xs); text-align: left;
}
.appr-chip .appr-text { max-width: 30ch; }
.appr-chip .appr-text b { display: block; color: var(--paper); font-weight: 500; }
.appr-chip .appr-actions { display: flex; gap: 4px; }
.appr-chip button { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.appr-chip .appr-yes { background: rgba(61, 220, 151, 0.15); color: var(--ok); }
.appr-chip .appr-no { background: rgba(255, 107, 122, 0.15); color: var(--bad); }

.home-steps { width: 100%; max-width: 420px; padding: var(--s-4); border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--line-strong); text-align: left; }
.home-steps h3 { font-size: var(--fs-sm); margin-bottom: var(--s-3); }
.home-steps ol { display: flex; flex-direction: column; gap: var(--s-2); counter-reset: step; }
.home-steps li { display: flex; flex-direction: column; gap: 2px; }
.home-steps .step-title { font-size: var(--fs-sm); }
.home-steps .step-detail { color: var(--muted); font-size: var(--fs-xs); }
.home-steps button { align-self: flex-start; margin-top: 2px; }

.home-composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; justify-content: center;
  padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--abyss) 55%, transparent);
}
@media (max-width: 900px) { .home-composer { bottom: 58px; } }
.composer-inner { display: flex; align-items: center; gap: var(--s-2); width: min(560px, 100%); padding: 6px 6px 6px 16px; border-radius: var(--r-pill); background: var(--glass-2); border: 1px solid var(--line-strong); backdrop-filter: blur(16px); }
.composer-inner input { flex: 1; min-width: 0; background: none; border: 0; color: var(--paper); font: inherit; height: 40px; }
.composer-inner input::placeholder { color: var(--muted); }
.composer-mic, .composer-send { flex: none; width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--frost); }
.composer-mic:hover, .composer-send:hover { background: rgba(170, 206, 253, 0.1); }
.composer-mic.is-on { color: #fff; background: var(--cobalt); box-shadow: var(--glow-signal); }
.composer-mic:disabled { opacity: 0.35; cursor: not-allowed; }
.composer-send { background: var(--cobalt); color: #fff; }
.composer-note { position: absolute; bottom: 100%; left: 0; right: 0; text-align: center; font-size: var(--fs-xs); color: var(--muted); padding-bottom: 4px; }

/* ---------- Agents section ---------- */
.agents-sec.is-on { display: flex; flex-direction: column; height: 100%; }
.agents-frame-wrap { flex: 1; min-height: 0; position: relative; }
.agents-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.agents-ask { flex: none; display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); background: rgba(7, 20, 51, 0.6); }
.agents-ask input { flex: 1; min-width: 0; height: 38px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: rgba(2, 9, 31, 0.5); color: var(--paper); padding: 0 12px; font: inherit; }
.agents-ask-caption { flex: none; padding: 4px var(--s-4) 0; font-size: var(--fs-xs); color: var(--muted); min-height: 1.4em; }

/* ---------- Approvals (native) ---------- */
.approvals-sec, .usage-sec, .settings-sec { padding: var(--s-5); max-width: 860px; margin: 0 auto; }
.appr-list { display: flex; flex-direction: column; gap: var(--s-3); }
.appr-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--line); }
.appr-row-text b { display: block; }
.appr-row-text span { color: var(--muted); font-size: var(--fs-sm); }
.appr-row-actions { display: flex; gap: var(--s-2); flex: none; }
.empty-note { color: var(--muted); text-align: center; padding: var(--s-8) 0; }

/* ---------- Usage (native) ---------- */
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.usage-card { padding: var(--s-4); border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--line); }
.usage-card .u-label { color: var(--muted); font-size: var(--fs-xs); display: block; margin-bottom: 4px; }
.usage-card .u-val { font-size: var(--fs-2xl); font-weight: 600; }
.usage-agents { display: flex; flex-direction: column; gap: var(--s-2); }
.usage-agent-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: var(--r-md); background: var(--glass); border: 1px solid var(--line); font-size: var(--fs-sm); }

/* ---------- Settings (native) ---------- */
.settings-block { margin-bottom: var(--s-6); }
.settings-block h2 { font-size: var(--fs-md); margin-bottom: var(--s-3); }
.settings-note { font-size: var(--fs-xs); color: var(--muted); margin-bottom: var(--s-3); }
.settings-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--s-4); font-size: var(--fs-sm); }
.settings-kv dt { color: var(--muted); }
.hero-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: var(--s-2); }
.hero-opt { padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line); background: rgba(2, 9, 31, 0.45); color: var(--frost); font-size: var(--fs-sm); text-align: center; transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast); }
.hero-opt:hover { background: rgba(170, 206, 253, 0.05); }
.hero-opt.is-on { border-color: rgba(96, 157, 252, 0.7); background: rgba(37, 78, 193, 0.18); color: var(--paper); box-shadow: 0 0 40px -20px rgba(96, 157, 252, 0.8); }
@media (max-width: 560px) { .hero-opts { grid-template-columns: 1fr; } }
.member-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.invite-form { display: flex; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; }
.invite-form input { flex: 1; min-width: 160px; height: 38px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: rgba(2, 9, 31, 0.5); color: var(--paper); padding: 0 12px; font: inherit; }
.invite-form select { height: 38px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: rgba(2, 9, 31, 0.5); color: var(--paper); padding: 0 10px; font: inherit; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 8px); z-index: 10; padding: 10px 18px; border-radius: var(--r-pill); background: rgba(7, 20, 51, 0.92); border: 1px solid var(--line-strong); font-size: var(--fs-sm); opacity: 0; pointer-events: none; transition: opacity var(--t-ui), transform var(--t-ui); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

input, button { font-family: var(--font-ui); }
