/* Alex Console — Alfred / Dreambeam look: obsidian, cyan glow, glass, serif greeting. */
:root {
  --bg: #050505;
  --bg-1: #06101a;
  --bg-2: #07111d;
  --bg-3: #0b1723;
  --line: rgba(110, 183, 255, 0.10);
  --line-2: rgba(110, 183, 255, 0.16);
  --line-3: rgba(110, 183, 255, 0.24);
  --ink: #f1f5f9;
  --ink-2: rgba(241, 245, 249, 0.82);
  --ink-3: rgba(241, 245, 249, 0.62);
  --ink-4: rgba(241, 245, 249, 0.45);
  --accent: #06b6d4;
  --accent-2: #38bdf8;
  --accent-3: #67e8f9;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --card: rgba(11, 23, 35, 0.6);
  --card-hover: rgba(15, 23, 42, 0.78);
  --input: rgba(11, 23, 35, 0.55);
  --shadow: rgba(0, 0, 0, 0.7);
  --serif: "Instrument Serif", "New York", ui-serif, Georgia, serif;
  --sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans);
  -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overflow-x: hidden; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent-3); }
[hidden] { display: none !important; }

/* --- backdrop -------------------------------------------------------- */
.backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(900px 500px at 70% -10%, rgba(6, 182, 212, 0.08), transparent 60%),
              radial-gradient(700px 500px at 10% 100%, rgba(56, 189, 248, 0.05), transparent 60%), var(--bg); }
.glow { position: fixed; z-index: 0; pointer-events: none; width: 680px; height: 680px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-3), transparent 65%); filter: blur(120px); opacity: .55;
  top: -300px; left: -220px; animation: drift 32s ease-in-out infinite; }
.glow--b { width: 520px; height: 520px; top: auto; left: auto; right: -240px; bottom: -240px; opacity: 1;
  background: radial-gradient(circle, rgba(220, 225, 240, 0.06), transparent 65%); animation: drift-b 38s ease-in-out infinite; }
.grain { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .045; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
@keyframes drift { 0%,100% { transform: translate(0,0); } 50% { transform: translate(80px, 60px); } }
@keyframes drift-b { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-60px, -40px); } }

/* --- orb --------------------------------------------------------------- */
.orb { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
.orb img { width: 100%; height: 100%; object-fit: contain; position: relative; z-index: 1;
  filter: drop-shadow(0 0 28px rgba(56, 189, 248, 0.45)); animation: breathe 5s ease-in-out infinite; }
.orb::before { content: ""; position: absolute; inset: -50px; border-radius: 50%;
  background: radial-gradient(circle, rgba(103, 232, 249, 0.18), transparent 60%); filter: blur(20px);
  animation: breathe-glow 5s ease-in-out infinite; }
.orb--sm { width: 30px; height: 30px; }
.orb--sm::before { inset: -10px; filter: blur(8px); }
.orb.thinking img { animation: think 1.4s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes breathe-glow { 0%,100% { opacity: .7; } 50% { opacity: 1; } }
@keyframes think { 0%,100% { transform: scale(.94) rotate(0deg); } 50% { transform: scale(1.06) rotate(8deg); } }

/* --- login ------------------------------------------------------------ */
.login { position: relative; z-index: 2; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 28px; padding: 32px 16px calc(48px + env(safe-area-inset-bottom)); }
.greet { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 9vw, 46px); line-height: 1.05;
  letter-spacing: -0.01em; text-align: center;
  background: linear-gradient(180deg, #f1f5f9 0%, rgba(241, 245, 249, 0.6) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { margin: 6px 0 0; text-align: center; color: var(--ink-3); font-size: 14px; }
.wordmark { font-size: 11px; letter-spacing: .32em; text-transform: uppercase; font-weight: 600; color: var(--ink-4); }

/* --- glass surfaces ------------------------------------------------------ */
.glass { position: relative; border-radius: 22px; border: 1px solid var(--line-2); background: var(--card);
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 24px 70px var(--shadow); }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.input { width: 100%; border-radius: 13px; border: 1px solid var(--line-2); background: var(--input);
  padding: 12px 14px; font-size: 15px; outline: none; transition: border-color .18s, box-shadow .18s; }
.input::placeholder { color: var(--ink-4); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.16); }
textarea.input { resize: none; min-height: 46px; max-height: 160px; line-height: 1.4; }
.btn { border: none; border-radius: 13px; padding: 11px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  color: #fff; background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 22px rgba(103, 232, 249, .45), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .12s, box-shadow .18s, opacity .18s; white-space: nowrap; }
.btn:hover:not(:disabled) { box-shadow: 0 0 32px rgba(103, 232, 249, .6), inset 0 1px 0 rgba(255,255,255,.24); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.btn--ghost { background: rgba(110, 183, 255, 0.07); color: var(--ink-2); box-shadow: none; border: 1px solid var(--line-2); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn--ghost:hover:not(:disabled) { background: rgba(110, 183, 255, 0.13); box-shadow: none; }
.btn--danger { background: linear-gradient(180deg, #fb7185, #e11d48); box-shadow: 0 0 18px rgba(251, 113, 133, .35); }
.btn--block { width: 100%; }
.btn--sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.error { margin: 0; color: var(--bad); font-size: 13px; }
.muted { color: var(--ink-3); }
.tiny { font-size: 12px; color: var(--ink-4); }

/* --- shell ---------------------------------------------------------------- */
.shell { position: relative; z-index: 2; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(6, 16, 26, 0.78);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); }
.topbar__name { font-family: var(--serif); font-size: 22px; flex: 0 0 auto; }
.tabs { margin-left: auto; display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(110, 183, 255, 0.06);
  border: 1px solid var(--line); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; color: var(--ink-3); padding: 6px 12px; border-radius: 9px; cursor: pointer;
  font-size: 13px; font-weight: 600; white-space: nowrap; }
.tab[aria-selected="true"] { background: rgba(110, 183, 255, 0.14); color: var(--ink); }
.view { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); }

/* --- home ---------------------------------------------------------------- */
.hero { padding: 6px 2px 18px; }
.hero .greet { text-align: left; font-size: clamp(30px, 8vw, 40px); }
.hero .sub { text-align: left; }
.cards { display: grid; gap: 14px; }
.card { padding: 18px; display: flex; flex-direction: column; gap: 12px; border-radius: 20px; }
.card__head { display: flex; align-items: center; gap: 10px; }
.card__title { font-weight: 650; font-size: 15px; }
.card__step { margin-left: auto; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-4); }
.card p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.light { width: 10px; height: 10px; border-radius: 50%; background: #475569; flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(71,85,105,.18); }
.light--good { background: var(--good); box-shadow: 0 0 12px rgba(52, 211, 153, .6); }
.light--warn { background: var(--warn); box-shadow: 0 0 12px rgba(251, 191, 36, .55); animation: pulse 1.6s ease-in-out infinite; }
.light--bad { background: var(--bad); box-shadow: 0 0 12px rgba(251, 113, 133, .55); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .input { flex: 1 1 200px; min-width: 0; }
.code-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px;
  background: rgba(6, 182, 212, 0.06); border: 1px dashed var(--line-3); }
.code { font-family: var(--mono); font-size: clamp(26px, 8vw, 34px); letter-spacing: .08em; color: var(--ink);
  text-shadow: 0 0 18px rgba(103, 232, 249, .35); word-break: break-all; }
.ok { color: var(--good); font-weight: 600; font-size: 14px; }
details { border-radius: 12px; border: 1px solid var(--line); padding: 8px 12px; background: rgba(110,183,255,.03); }
summary { cursor: pointer; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
details ol { margin: 8px 0 2px; padding-left: 20px; color: var(--ink-2); font-size: 13.5px; line-height: 1.6; }
.pending { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(251, 191, 36, 0.07); border: 1px solid rgba(251, 191, 36, 0.25); }
.pending__who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.statusrow { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .statusrow { grid-template-columns: repeat(3, 1fr); } }
.stat { padding: 16px; display: flex; flex-direction: column; gap: 10px; border-radius: 18px; }
.stat__line { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.stat__meta { font-size: 13px; color: var(--ink-3); min-height: 18px; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; padding: 10px 16px; border-radius: 12px; background: rgba(7,17,29,.95); border: 1px solid var(--line-3);
  font-size: 14px; box-shadow: 0 12px 40px var(--shadow); max-width: calc(100vw - 32px); }

/* --- chat ------------------------------------------------------------------ */
.chat { display: flex; flex-direction: column; min-height: calc(100dvh - 64px); max-width: 760px; margin: 0 auto;
  width: 100%; padding: 0 16px; }
.chat__bar { display: flex; gap: 8px; padding: 12px 0 6px; align-items: center; }
.chat__bar select { flex: 1; min-width: 0; }
.thread { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 10px 0 18px; }
.empty { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 30px 0; }
.bubble { max-width: 88%; padding: 11px 14px; border-radius: 18px; font-size: 15px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); }
.bubble--user { align-self: flex-end; background: rgba(14, 116, 144, 0.32); border-color: rgba(103,232,249,.22); border-bottom-right-radius: 6px; }
.bubble--bot { align-self: flex-start; background: rgba(15, 23, 42, 0.85); border-bottom-left-radius: 6px; }
.bubble--err { align-self: stretch; background: rgba(251, 113, 133, 0.08); border-color: rgba(251, 113, 133, .35); color: #fecdd3;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; white-space: normal; }
.thinking { align-self: flex-start; display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 13px; }
.composer { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 35%); }
.composer .btn { height: 46px; }
.notice { margin: 14px 0; padding: 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--card);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

/* --- admin ------------------------------------------------------------------ */
.logbox { font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 60dvh; overflow: auto; padding: 14px; border-radius: 14px; background: rgba(0,0,0,.45); border: 1px solid var(--line); color: var(--ink-2); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-4); font-weight: 600; }
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.6); }
.modal .glass { width: 100%; max-width: 420px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
