:root {
  --bg: #050c0e;
  --ink: #f3e9d8;
  --dim: #9a8f7c;
  --gold: #6cd5c6;
  --warn: #ffc566;
  --orange: #2aa89a;
  --line: rgba(100, 200, 190, 0.24);
  --glass: rgba(10, 20, 24, 0.64);
  --danger: #ff5a3c;
  --teal: #7be0a8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #0b1a1c 0%, var(--bg) 65%);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#orb { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button { font: inherit; color: inherit; cursor: pointer; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--dim);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; letter-spacing: .08em;
}
.ghost:hover { color: var(--gold); border-color: var(--gold); }

/* top bar */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
}
.title { display: flex; flex-direction: column; margin-right: auto; }
.brand { letter-spacing: .5em; font-weight: 600; color: var(--gold); text-shadow: 0 0 14px rgba(80,200,185,.5); }
.tag { font-size: 9px; letter-spacing: .22em; text-transform: uppercase; color: var(--dim); margin-top: 3px; }
.clock { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); font-family: ui-monospace, Consolas, monospace; }
.online { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--teal); font-family: ui-monospace, Consolas, monospace; }
.online i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.online b { font-weight: 500; }
.online.busy { color: var(--warn); }
.online.busy i { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

/* system status panel (left) */
.status {
  position: fixed; z-index: 3; left: 16px; top: 64px; width: 250px;
  display: flex; flex-direction: column; gap: 6px;
}
.panel-head { font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--dim); padding: 6px 4px; font-family: ui-monospace, Consolas, monospace; }
.tele-head { margin-top: 10px; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.srow, .tele {
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.srow { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-family: ui-monospace, Consolas, monospace; }
.srow b { font-weight: 600; color: var(--teal); }
.srow.warn b { color: var(--warn); }
.srow.err b { color: var(--danger); }
.tele { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.trow { font-size: 11px; color: var(--dim); font-family: ui-monospace, Consolas, monospace; }
.trow div { display: flex; justify-content: space-between; margin-bottom: 4px; letter-spacing: .08em; text-transform: uppercase; }
.trow span { color: var(--ink); }
.bar { height: 4px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .6s; }

/* quick action chips */
.chips {
  position: fixed; z-index: 4; left: 50%; transform: translateX(-50%);
  bottom: calc(112px + env(safe-area-inset-bottom)); display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 60vw;
}
.chips button {
  background: rgba(10,14,22,.55); border: 1px solid var(--line); color: var(--ink); border-radius: 999px;
  padding: 8px 16px; font-size: 12px; letter-spacing: .08em; font-family: ui-monospace, Consolas, monospace;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.chips button:hover { border-color: var(--gold); color: var(--gold); }

/* chat */
.chat {
  position: fixed; z-index: 3;
  right: 16px; top: 64px; bottom: 124px; width: min(340px, 86vw);
  display: flex; flex-direction: column;
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 30px rgba(80,190,175,.08);
}
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid var(--line);
}
.log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; }
.msg { max-width: 92%; padding: 8px 11px; border-radius: 12px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: rgba(80,190,175,.15); border: 1px solid rgba(100,200,190,.32); }
.msg.ai { align-self: flex-start; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); }
.msg.sys { align-self: center; font-size: 12px; color: var(--dim); background: none; border: none; }
.row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.row input {
  flex: 1; min-width: 0; background: rgba(0,0,0,.35); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 16px; outline: none;
}
.row input:focus { border-color: var(--gold); }
.row button {
  width: 42px; border: 1px solid var(--line); border-radius: 10px; background: rgba(80,190,175,.13); color: var(--gold);
}
.chat.collapsed { bottom: auto; }
.chat.collapsed .log, .chat.collapsed .row, .chat.collapsed .outbox { display: none; }

/* outbox: drafts waiting for approval */
.outbox:empty { display: none; }
.outbox { max-height: 46%; overflow-y: auto; padding: 8px 10px 0; display: flex; flex-direction: column; gap: 8px; }
.draft { border: 1px solid var(--gold); border-radius: 12px; padding: 10px; background: rgba(80,190,175,.08); box-shadow: 0 0 18px rgba(80,190,175,.16); }
.draft h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.draft .meta { font-size: 12px; color: var(--dim); word-break: break-all; }
.draft .body { margin: 6px 0 8px; font-size: 13px; line-height: 1.4; white-space: pre-wrap; max-height: 9.5em; overflow-y: auto; }
.draft .btns { display: flex; gap: 8px; }
.draft button { flex: 1; padding: 8px; border-radius: 9px; border: 1px solid var(--line); background: transparent; font-size: 13px; }
.draft button.go { background: linear-gradient(135deg, #7fdccd, #3aa99a); color: #04120f; font-weight: 600; border: 0; }
.draft button:disabled { opacity: .5; cursor: default; }

/* bottom control */
.bottom {
  position: fixed; z-index: 4; left: 50%; transform: translateX(-50%);
  bottom: calc(26px + env(safe-area-inset-bottom)); text-align: center; width: max-content; max-width: 92vw;
}
.talk {
  padding: 16px 38px; border-radius: 999px; font-size: 15px; letter-spacing: .14em; text-transform: uppercase;
  color: #04120f; font-weight: 600; border: 0;
  background: linear-gradient(135deg, #7fdccd, #3aa99a);
  box-shadow: 0 0 26px rgba(70,185,170,.4), inset 0 0 0 1px rgba(255,255,255,.4);
  transition: transform .15s, box-shadow .2s;
}
.talk:hover { transform: translateY(-1px); box-shadow: 0 0 38px rgba(80,200,185,.55), inset 0 0 0 1px rgba(255,255,255,.5); }
.talk.on {
  color: var(--ink); background: rgba(255,90,60,.16);
  box-shadow: 0 0 0 1px var(--danger), 0 0 26px rgba(255,90,60,.4);
}
.hint { margin: 10px 0 0; min-height: 1.2em; font-size: 12px; color: var(--dim); }
.dbg { margin: 4px 0 0; font-size: 11px; color: #6f6759; max-width: 90vw; word-break: break-word; }
.dbg:empty { display: none; }

/* login */
body.login { display: grid; place-items: center; }
.login-card {
  position: relative; z-index: 3; width: min(360px, 88vw); margin-top: 38vh; text-align: center;
  padding: 22px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.login-card h1 { margin: 0; letter-spacing: .5em; font-weight: 600; color: var(--gold); text-shadow: 0 0 16px rgba(80,200,185,.5); }
.login-card .sub { margin: 4px 0 18px; color: var(--dim); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; }
.login-card input[type=password] {
  width: 100%; background: rgba(0,0,0,.4); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 16px; outline: none; margin-bottom: 10px;
}
.login-card button[type=submit] {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; font-weight: 600; color: #04120f;
  background: linear-gradient(135deg, #7fdccd, #3aa99a);
}
.err { color: var(--danger); min-height: 1.2em; font-size: 13px; margin: 10px 0 0; }

/* mobile: orb stays big in the background, chat is a small panel at the right */
@media (max-width: 1100px) {
  .status { display: none; }
  .chips { max-width: 94vw; }
}
@media (max-width: 720px) {
  .tag, .clock { display: none; }
  .top { gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
  .brand { letter-spacing: .28em; font-size: 14px; }
  .online { letter-spacing: .1em; font-size: 11px; }
  .chips { display: none; }
  .chat { right: 10px; top: auto; bottom: calc(104px + env(safe-area-inset-bottom)); height: 32dvh; width: min(74vw, 320px); }
  .chat.collapsed { height: auto; }
  .talk { padding: 15px 30px; }
  .state { font-size: 11px; }
}

/* ===== Glassmorphism upgrade ===== */
:root {
  --glass: linear-gradient(145deg, rgba(255,255,255,.14) 0%, rgba(255,255,255,.04) 55%, rgba(120,220,210,.07) 100%);
  --glass-border: rgba(255,255,255,.22);
  --glass-shadow: 0 8px 32px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.28), inset 0 -1px 0 rgba(255,255,255,.05);
}
.srow, .tele, .chat, .login-card, .draft {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: var(--glass-shadow);
}
.chat { border-radius: 20px; }
.srow, .tele { border-radius: 14px; }
.chat-head, .row { border-color: rgba(255,255,255,.14); }
.chips button {
  background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.04));
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow: 0 4px 18px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.3);
  transition: transform .15s, box-shadow .2s, border-color .2s;
}
.chips button:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(80,200,185,.25), inset 0 1px 0 rgba(255,255,255,.4); }
.msg.user { background: linear-gradient(145deg, rgba(120,220,210,.28), rgba(60,170,155,.12)); border: 1px solid rgba(255,255,255,.22); box-shadow: inset 0 1px 0 rgba(255,255,255,.2); }
.msg.ai { background: linear-gradient(145deg, rgba(255,255,255,.1), rgba(255,255,255,.03)); border: 1px solid rgba(255,255,255,.14); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.row input { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.row button { background: linear-gradient(145deg, rgba(255,255,255,.2), rgba(255,255,255,.05)); border: 1px solid var(--glass-border); }
.ghost { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.2); }
.talk { box-shadow: 0 8px 30px rgba(70,185,170,.45), inset 0 1px 0 rgba(255,255,255,.6), inset 0 0 0 1px rgba(255,255,255,.35); }
.login-card input[type=password] { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.2); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .srow, .tele, .chat, .login-card, .draft { background: rgba(14,28,32,.88); }
}
