/* Atriqa Office — "Glass Office at Dusk".
   Dark graphite + night blue, warm amber for data, and ONE signature glow (dusk peach → rose)
   that belongs only to Riya. Built 2026-10-21 IST. */
:root {
  --bg: #0b0e16;
  --ink: #eef0f6;
  --ink-2: #b9bfcf;
  --ink-3: #7f879b;
  --glass: rgba(16, 20, 32, 0.58);
  --glass-2: rgba(26, 31, 48, 0.62);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --amber: #f2b66d;
  --ok: #6fd6a0;
  --warn: #f2b66d;
  --bad: #ff7a7a;
  --info: #8fb2ff;
  --riya-a: #ffb38a;
  --riya-b: #ff7eb6;
  --riya: linear-gradient(135deg, var(--riya-a), var(--riya-b));
  --radius: 18px;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Manrope", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--riya-a); }

.scene { position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(1200px 700px at 78% -10%, rgba(255, 140, 120, 0.18), transparent 60%),
              linear-gradient(180deg, rgba(11, 14, 22, 0.35), rgba(11, 14, 22, 0.88) 70%),
              url(/riya/scene.webp) center/cover no-repeat; }
.scene::after { content: ""; position: absolute; inset: 0; opacity: .06; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"); }

.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  -webkit-backdrop-filter: blur(22px) saturate(140%); backdrop-filter: blur(22px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 50px rgba(0, 0, 0, 0.35); }

/* ---------- top bar */
.topbar { position: fixed; top: 10px; left: 10px; right: 10px; height: 48px; display: flex; align-items: center; gap: 16px; padding: 0 14px; z-index: 50; }
.brand { font: 22px/1 var(--serif); letter-spacing: .2px; }
.brand em { color: var(--riya-a); }
.clock { flex: 1; text-align: center; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.top-right { display: flex; gap: 8px; align-items: center; }
.pill { border: 1px solid var(--line-2); background: rgba(255,255,255,.04); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.pill.subtle { color: var(--ink-2); }
.pill.danger { border-color: rgba(255, 122, 122, .45); color: #ffb3b3; }
.pill.danger.on { background: rgba(255, 122, 122, .22); color: #fff; }
.pill:hover { border-color: var(--line-2); background: rgba(255,255,255,.09); }

/* ---------- home (voice-first default screen) */
.home { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.corner-btn { position: fixed; top: 16px; right: 16px; z-index: 55; width: 38px; height: 38px; font-size: 18px; opacity: .55; }
.corner-btn:hover { opacity: 1; }
.home-center { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px; max-width: 480px; width: 100%; }
.avatar-wrap { position: relative; width: 96px; height: 96px; flex: none; }
.avatar-wrap img { position: absolute; inset: 0; width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.12); }
.avatar-wrap canvas { position: absolute; left: -12px; top: -12px; width: 120px; height: 120px; pointer-events: none; }
.avatar-wrap.big { width: 240px; height: 240px; }
.avatar-wrap.big img { width: 240px; height: 240px; border-width: 3px; box-shadow: 0 0 70px rgba(255, 126, 182, .25); }
.avatar-wrap.big canvas { left: -40px; top: -40px; width: 320px; height: 320px; }
.riya-name { font: 30px/1 var(--serif); background: var(--riya); -webkit-background-clip: text; background-clip: text; color: transparent; }
.icon-btn { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.icon-btn[aria-pressed="true"] { border-color: var(--riya-a); box-shadow: 0 0 0 1px var(--riya-a) inset; }

.home-status { display: flex; align-items: center; gap: 9px; color: var(--ink-2); font-size: 14px; min-height: 20px; }
.mic-dot { width: 10px; height: 10px; border-radius: 50%; background: #555c6e; flex: none; transition: background .2s, box-shadow .2s; }
.mic-dot.live { background: #ff5577; box-shadow: 0 0 0 4px rgba(255, 85, 119, .22); animation: micpulse 1.1s infinite; }
.mic-dot.wake { background: var(--riya-b); box-shadow: 0 0 0 4px rgba(255, 126, 182, .18); }
@keyframes micpulse { 0% { box-shadow: 0 0 0 0 rgba(255,85,119,.45); } 70% { box-shadow: 0 0 0 8px rgba(255,85,119,0); } 100% { box-shadow: 0 0 0 0 rgba(255,85,119,0); } }

.home-composer { width: 100%; }
.wake-toggle { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 12px; max-width: 360px; text-align: center; justify-content: center; }
.wake-toggle input { accent-color: var(--riya-b); }

.composer { display: flex; gap: 8px; align-items: center; }
.composer input[type="text"] { flex: 1 1 0; min-width: 0; width: 0; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(0,0,0,.25); color: var(--ink); font: inherit; padding: 11px 14px; outline: none; }
.composer input[type="text"]:focus { border-color: var(--riya-a); }
.mic, .send { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(255,255,255,.05); flex: none; font-size: 16px; touch-action: none; user-select: none; -webkit-user-select: none; }
.send { background: var(--riya); color: #2a1020; border: none; font-weight: 700; }
.mic.live { background: var(--riya); color: #2a1020; border: none; box-shadow: 0 0 22px rgba(255, 126, 182, .55); }

/* ---------- desktop overlay topbar + layout */
/* #desktopOverlay.layout's own `display: grid` out-specifies the UA stylesheet's [hidden]
   { display: none }, so the overlay rendered on top of the home screen even while `hidden`
   was true. The [hidden] selector below needs to win — same specificity as the rule above
   (id + 2 classes vs id + attr + class), so it relies on source order (it comes after) to
   take priority per the cascade. Confirmed live 2026-10-21: fresh page load showed both the
   home voice screen and the desktop topbar/dock stacked, with the overlay re-hidden correctly
   once this rule was added. */
#desktopOverlay.layout { position: fixed; top: 68px; left: 10px; right: 10px; bottom: 10px; display: grid; grid-template-columns: 1fr; gap: 10px; }
#desktopOverlay.layout[hidden] { display: none; }
#desktopOverlay .topbar { position: fixed; top: 10px; left: 10px; right: 10px; }

/* ---------- desktop + windows */
.desktop { position: relative; min-width: 0; min-height: 0; }
.windows { position: absolute; inset: 0 0 64px 0; }
.win { position: absolute; display: flex; flex-direction: column; min-width: 280px; min-height: 160px; overflow: hidden; resize: both; background: var(--glass-2); }
.win.focus { border-color: var(--line-2); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 24px 70px rgba(0,0,0,.5); }
.win[hidden] { display: none; }
.win-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px 16px; cursor: grab; user-select: none; border-bottom: 1px solid var(--line); flex: none; }
.win-bar:active { cursor: grabbing; }
.win-title { margin: 0; font: 21px/1.1 var(--serif); font-weight: 400; }
.win-acts button { width: 26px; height: 26px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--ink-3); font-size: 16px; }
.win-acts button:hover { border-color: var(--line); color: var(--ink); }
.win-body { flex: 1; overflow: auto; padding: 12px 16px 16px; scrollbar-width: thin; }

.dock { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px; border-radius: 16px; max-width: 100%; overflow-x: auto; }
.dock button, .dock a { position: relative; margin-right: 4px; border: none; background: none; border-radius: 10px; padding: 8px 12px; color: var(--ink-2); font-size: 13px; white-space: nowrap; text-decoration: none; }
.dock button:hover, .dock a:hover, .dock button.active { background: rgba(255,255,255,.08); color: var(--ink); }
.badge { position: absolute; top: -4px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; font-weight: 700; }
.badge.info { background: rgba(143,178,255,.85); color: #0b0e16; }
.badge:empty { display: none; }

/* ---------- content atoms */
.section { margin: 2px 0 16px; }
.section h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; display: flex; gap: 8px; align-items: center; }
.section h3 .n { color: var(--ink-2); letter-spacing: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(255,255,255,.03); cursor: pointer; text-align: left; }
.stat .v { font: 30px/1 var(--serif); }
.stat .l { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.stat.bad .v { color: var(--bad); } .stat.warn .v { color: var(--amber); } .stat.info .v { color: var(--info); }
.row { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .meta { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.row .sub { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.row.click { cursor: pointer; } .row.click:hover .main { color: #fff; }
.tid { font: 11.5px var(--mono); color: var(--ink-3); }
.p1 { color: var(--bad); } .p2 { color: var(--amber); }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag.ok { border-color: rgba(111,214,160,.45); color: var(--ok); }
.tag.warn { border-color: rgba(242,182,109,.5); color: var(--amber); }
.tag.bad { border-color: rgba(255,122,122,.5); color: var(--bad); }
.tag.info { border-color: rgba(143,178,255,.5); color: var(--info); }
.tag.riya { border-color: var(--riya-a); color: var(--riya-a); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; transform: translateY(-1px); }
.dot.ok { background: var(--ok); } .dot.watch { background: var(--amber); } .dot.attention { background: var(--bad); } .dot.parked { background: #555c6e; }
.dot.working { background: var(--ok); box-shadow: 0 0 0 0 rgba(111,214,160,.6); animation: pulse 1.6s infinite; }
.dot.needs_you { background: var(--bad); } .dot.idle { background: #555c6e; } .dot.ready { background: var(--riya-b); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: rgba(255,255,255,.03); cursor: pointer; text-align: left; }
.card:hover { border-color: var(--line-2); background: rgba(255,255,255,.06); }
.card .t { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.card .s { color: var(--ink-3); font-size: 12px; margin-top: 6px; }
.card .nums { display: flex; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.approval { border: 1px solid rgba(255, 126, 182, .4); background: rgba(255, 126, 182, .07); border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.approval .why { color: var(--ink-3); font-size: 12px; margin: 6px 0 10px; }
.btn { border: 1px solid var(--line-2); background: rgba(255,255,255,.06); border-radius: 10px; padding: 6px 14px; }
.btn.go { background: var(--riya); color: #2a1020; border: none; font-weight: 700; }
.btn + .btn { margin-left: 6px; }
.empty { color: var(--ink-3); padding: 6px 0; }
.result { white-space: pre-wrap; font-size: 13px; background: rgba(0,0,0,.22); border-radius: 10px; padding: 10px; border: 1px solid var(--line); }
.untrusted { font-size: 11.5px; color: var(--amber); margin-bottom: 8px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar input, .toolbar select { background: rgba(0,0,0,.25); border: 1px solid var(--line-2); color: var(--ink); border-radius: 10px; padding: 6px 10px; font: inherit; }
.bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--amber); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th { text-align: left; color: var(--ink-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
table.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(111,214,160,.55); } 70% { box-shadow: 0 0 0 7px rgba(111,214,160,0); } 100% { box-shadow: 0 0 0 0 rgba(111,214,160,0); } }

/* ---------- login */
.login-body { overflow: auto; background: var(--bg) url(/riya/scene.webp) center/cover; }
.login { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; text-align: center; background: linear-gradient(180deg, rgba(11,14,22,.35), rgba(11,14,22,.85)); }
.login-portrait { width: 132px; height: 132px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px rgba(255,255,255,.08), 0 0 60px rgba(255, 126, 182, .45); }
.login h1 { font: 40px/1.1 var(--serif); font-weight: 400; margin: 22px 0 6px; }
.login-sub { color: var(--ink-2); margin: 0 0 22px; }
.login-form { width: 100%; max-width: 360px; padding: 22px; display: grid; gap: 14px; text-align: left; }
.login-form label { display: grid; gap: 6px; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; }
.login-form input { background: rgba(0,0,0,.3); border: 1px solid var(--line-2); border-radius: 12px; padding: 11px 12px; color: var(--ink); font: 15px var(--sans); text-transform: none; letter-spacing: 0; }
.login-form input:focus { outline: none; border-color: var(--riya-a); }
.login-form button { background: var(--riya); color: #2a1020; border: none; border-radius: 12px; padding: 12px; font-weight: 700; font-size: 15px; }
.login-err { color: var(--bad); margin: 0; font-size: 13px; }
.login-note { color: var(--ink-3); font-size: 12px; margin-top: 16px; }

/* ---------- phone */
@media (max-width: 860px) {
  .avatar-wrap.big { width: 168px; height: 168px; }
  .avatar-wrap.big img { width: 168px; height: 168px; }
  .avatar-wrap.big canvas { left: -28px; top: -28px; width: 224px; height: 224px; }
  .home-center { padding: 16px; gap: 14px; }
  .corner-btn { top: calc(10px + env(safe-area-inset-top)); right: 10px; }

  #desktopOverlay .topbar { left: 0; right: 0; top: 0; border-radius: 0; border-width: 0 0 1px; height: calc(48px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  #desktopOverlay .clock, #desktopOverlay #costPill, #desktopOverlay .top-right a.pill { display: none; }
  #desktopOverlay .brand { font-size: 19px; flex: 1; }
  #desktopOverlay.layout { top: calc(48px + env(safe-area-inset-top)); left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); display: block; }
  /* Android on-screen keyboard: some WebView/Chrome builds don't honour interactive-widget
     and leave position:fixed pinned to the pre-keyboard height, so the keyboard overlaps and
     hides the bottom of the last reply + composer instead of the layout shrinking to make room.
     --vvh (set from visualViewport in app.js) is the real visible height; it wins when present. */
  #desktopOverlay.layout { bottom: auto; height: calc(var(--vvh, 100vh) - 48px - env(safe-area-inset-top)); }
  .desktop { position: static; }
  .windows { position: fixed; inset: calc(48px + env(safe-area-inset-top)) 0 calc(60px + env(safe-area-inset-bottom)) 0; pointer-events: none; z-index: 40; }
  .win { pointer-events: auto; position: absolute; inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; resize: none; }
  .win-bar { cursor: default; }
  .win-min { display: none; }
  .dock { position: fixed; left: 0; right: 0; bottom: 0; transform: none; border-radius: 0; border-width: 1px 0 0; justify-content: flex-start; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 60; }
  .mic { width: 52px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* 22 Oct: on <=375px phones (most Android = 360px) the text input's intrinsic width pushed Send off-screen.
   min-width:0 above lets it shrink; here the buttons tighten so all four fit down to 320px. */
.composer > * { flex-shrink: 0; }
.composer > input[type="text"] { flex-shrink: 1; }
@media (max-width: 380px) {
  .composer { gap: 6px; }
  .composer .mic, .composer .send, .composer .attach-btn { width: 42px; min-width: 42px; height: 42px; padding: 0; }
}

/* 22 Oct: Updates bell on the voice-first home (left of 🌐 and ⊞) */
.updates-btn { right: 108px; }
.updates-btn .badge { top: -4px; right: -4px; }
.updates-btn:has(.badge:not(:empty)) { opacity: 1; }
@media (max-width: 860px) { .updates-btn { right: 102px; } }

/* 22 Oct: phone top bar overflowed (Back button cut off at 360px). Drop the servers pill, tighten pills. */
@media (max-width: 860px) {
  #sysPill { display: none; }
  .top-right { gap: 6px; flex-wrap: nowrap; }
  .top-right .pill { padding: 4px 10px; font-size: 12px; }
}

/* 22 Oct: Conversation view (💬). Voice home stays the default; in .convo the avatar shrinks to the top,
   the transcript fills the screen (full, formatted replies — nothing truncated) and the composer sits at the bottom. */
.convo-btn { right: 154px; }
@media (max-width: 860px) { .convo-btn { right: 148px; } }
.convo-btn[aria-pressed="true"] { opacity: 1; border-color: var(--riya-a); }
.convo-chat { display: none; }
body.convo .home { align-items: stretch; }
body.convo .home-center { max-width: 760px; height: 100%; padding: calc(64px + env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom)); gap: 10px; }
body.convo .avatar-wrap.big, body.convo .avatar-wrap.big img { width: 64px; height: 64px; }
body.convo .avatar-wrap.big canvas { left: -12px; top: -12px; width: 88px; height: 88px; }
body.convo .home-status { margin-top: -4px; }
body.convo .convo-chat { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; width: 100%; overflow-y: auto; padding: 4px 2px; }
body.convo .wake-toggle { display: none; }
.convo-chat .msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere; }
.convo-chat .msg.me { align-self: flex-end; background: rgba(143, 178, 255, .16); border: 1px solid rgba(143, 178, 255, .25); border-bottom-right-radius: 4px; }
.convo-chat .msg.riya { align-self: flex-start; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.convo-chat .msg table { display: block; overflow-x: auto; }
.reply-ctx { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; font-size: 12.5px; color: var(--riya-a);
  border: 1px solid var(--riya-a); border-radius: 10px; padding: 4px 6px 4px 12px; }
.reply-ctx[hidden] { display: none; }
.reply-ctx .icon-btn { width: 26px; height: 26px; }
.btn.small { padding: 3px 10px; font-size: 12px; align-self: center; }
