/* GNI Universal Client v2 — GNI Studio design system + dual-node + voice */
/* Tokens from the official GNI Brand Guide (studio skill) */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg-deep:    #0a0e1a;
  --bg-card:    #0d1321;
  --bg-input:   #080c16;
  --border:     #1a2332;
  --border-hi:  #2a3a4f;
  --blue:       #4facfe;
  --blue-dim:   #2f7dcc;
  --cyan:       #7cfff5;
  --text:       #c8d0e0;
  --text-bright:#e0e8f0;
  --text-dim:   #91a0b8;
  --success:    #4ade80;
  --warning:    #f0c040;
  --danger:     #ff5c67;
  --glow:       rgba(79,172,254,0.2);
}
html, body { height: 100%; }
body {
  background:
    radial-gradient(1000px 700px at 15% -5%, #101c38 0%, transparent 55%),
    radial-gradient(800px 600px at 110% 110%, #141a33 0%, transparent 55%),
    var(--bg-deep);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.view { display: none; height: 100dvh; flex-direction: column; padding: 14px; gap: 10px; }
.view.active { display: flex; }

/* ── Login ── */
#view-login { align-items: center; justify-content: center; }
.brand { text-align: center; margin-bottom: 24px; }
.logo-img {
  display: block;
  margin: 0 auto 14px;
  max-width: 100%;
  height: auto;
  max-height: 96px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 18px var(--glow));
}
.brand-name { font-size: 18px; font-weight: 700; color: var(--text-bright); letter-spacing: 0.5px; }
.brand-sub { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.login-card {
  width: 100%; max-width: 340px; padding: 18px; border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.login-card label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px; }
.login-card input {
  padding: 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text-bright); font-size: 14px;
  font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--blue-dim); }
.btn {
  padding: 11px; border-radius: 8px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--blue), var(--blue-dim));
  color: var(--bg-deep); font-weight: 700; font-size: 14px; font-family: inherit;
  letter-spacing: 0.5px;
}
.btn:active { opacity: 0.8; }
.btn.mic {
  width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 18px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--cyan);
}
.btn.mic.active { background: linear-gradient(135deg, var(--danger), #a83246); color: #fff; border-color: var(--danger); box-shadow: 0 0 16px rgba(255,92,103,0.4); }
.foot { margin-top: 20px; color: var(--text-dim); font-size: 11px; }

/* ── Shell ── */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.topbar-left { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-on { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot-off { background: var(--danger); }
.chip {
  font-size: 10px; padding: 3px 9px; border-radius: 14px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
}
.ghost {
  padding: 5px 12px; font-size: 11px; background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-family: inherit;
}

.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}
.panel.grow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel-title {
  font-size: 10px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.8px; margin-bottom: 8px; display: flex; justify-content: space-between;
}

/* ── Dual-node state ── */
.state-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.node-card {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.node-name { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-bright); font-weight: 500; }
.node-sub { font-size: 10px; color: var(--text-dim); margin-top: 6px; display: grid; gap: 3px; }
.node-sub span { display: flex; justify-content: space-between; }
.node-sub b { color: var(--text-bright); font-weight: 500; }

/* ── Chat ── */
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 3px 0; }
.msg { max-width: 84%; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(79,172,254,0.22), rgba(124,255,245,0.12)); border: 1px solid rgba(79,172,254,0.25); color: var(--text-bright); }
.msg.issie { align-self: flex-start; background: var(--bg-input); border: 1px solid var(--border); }
.msg.sys { align-self: center; font-size: 10px; color: var(--text-dim); }
.msg .ts { display: block; font-size: 9px; color: var(--text-dim); margin-top: 4px; }
.chat-input-row { display: flex; gap: 7px; margin-top: 8px; align-items: center; }
.chat-input-row input {
  flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text-bright); font-size: 14px; font-family: inherit;
}
.chat-input-row input:focus { outline: none; border-color: var(--blue-dim); }
.chat-input-row .btn { padding: 10px 16px; }
.error { color: var(--danger); font-size: 12px; text-align: center; min-height: 16px; }
.utc { font-size: 9px; color: var(--text-dim); text-align: center; opacity: 0.7; }

/* ── Responsive: tablet / desktop ── */
@media (min-width: 768px) {
  #view-login { padding: 32px; }
  .login-card { max-width: 400px; padding: 26px; }
  .logo-img { max-height: 130px; }
  .brand-name { font-size: 24px; }
  .brand-sub { font-size: 14px; }
  .login-card input { padding: 14px; font-size: 15px; }
  .btn { padding: 13px; font-size: 15px; }
  .panel { padding: 18px; border-radius: 14px; }
  .panel-title { font-size: 11px; }
  .msg { font-size: 14px; max-width: 70%; }
}

/* Desktop: constrain the shell to a centered column, panels side by side */
@media (min-width: 1024px) {
  #view-shell {
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
  }
  .state-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .node-card { padding: 16px; }
  .node-name { font-size: 13px; }
  .node-sub { font-size: 12px; }
  .chat-log { max-height: 50vh; }
  .msg { font-size: 14px; }
  .chat-input-row input { padding: 13px; font-size: 15px; }
}

/* Wide desktop: state and chat side by side */
@media (min-width: 1440px) {
  #view-shell {
    max-width: 1200px;
    display: grid;
    grid-template-columns: 340px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "topbar topbar"
      "state  chat";
    gap: 14px;
    height: 100dvh;
  }
  .topbar { grid-area: topbar; }
  .panel:first-of-type { grid-area: state; align-self: start; }
  .panel.grow { grid-area: chat; min-height: 0; }
  .state-grid { grid-template-columns: 1fr; }
  .chat-log { flex: 1; }
}

/* Landscape phones: keep the shell usable */
@media (max-height: 500px) and (orientation: landscape) {
  .state-grid { grid-template-columns: 1fr 1fr; }
  .node-card { padding: 8px; }
  #view-shell { padding: 8px; gap: 8px; }
  .panel { padding: 10px; }
}
