:root {
  --bg: #0b0f14;
  --bg-soft: #0f1620;
  --card: #121a24;
  --card-2: #16202c;
  --line: #1f2b3a;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #22d3ee;
  --accent-dim: #0e7490;
  --danger: #f43f5e;
  --warn: #f59e0b;
  --ok: #22c55e;
  --radius: 16px;
  --tap: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #12202d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
  min-height: 100%;
}

body {
  padding: max(12px, env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  overscroll-behavior-y: contain;
}

.screen { width: 100%; max-width: 540px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- login */
.login-wrap {
  min-height: 78vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center;
}
.logo { filter: drop-shadow(0 0 18px rgba(34, 211, 238, .25)); }
h1 { font-size: 26px; margin: 6px 0 0; letter-spacing: .3px; }
#login-form { width: 100%; max-width: 320px; margin-top: 18px; display: grid; gap: 12px; }
.pin-input {
  width: 100%; height: 60px; text-align: center; font-size: 24px; letter-spacing: 8px;
  color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); outline: none; transition: border-color .15s, box-shadow .15s;
}
.pin-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .15); }
.error-text { color: var(--danger); min-height: 18px; font-size: 13px; margin: 4px 0 0; }
.hint { color: var(--muted); font-size: 12px; max-width: 320px; line-height: 1.6; }
code { background: #0a121a; border: 1px solid var(--line); padding: 1px 5px; border-radius: 6px; font-size: 11px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.host { font-weight: 650; font-size: 16px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--muted);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); transition: background .2s;
}
.dot.online { background: var(--ok); animation: pulse 2.4s infinite; }
.dot.offline { background: var(--danger); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .45); }
  70% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ----------------------------------------------------------------- cards */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { font-size: 14px; margin: 0; color: var(--muted); font-weight: 600; letter-spacing: .4px; text-transform: uppercase; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 4px; }
.foot-note { margin: 10px 2px 0; line-height: 1.6; }

/* ----------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ssid-line { margin-top: 8px; }

/* ---------------------------------------------------------------- inputs */
.say-row { display: flex; gap: 8px; align-items: stretch; }#say-input {
  flex: 1; min-width: 0; height: var(--tap); padding: 0 14px; font-size: 15px;
  color: var(--text); background: var(--card-2); border: 1px solid var(--line);
  border-radius: 14px; outline: none;
}
#say-input:focus { border-color: var(--accent); }
.mic { width: 44px; height: auto; padding: 0; flex: 0 0 44px; }
.mic.rec { color: var(--danger); border-color: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }

/* ----------------------------------------------------------------- chat */
.say-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.badge {
  font-size: 10px; font-weight: 700; letter-spacing: .6px; color: #04141a;
  background: linear-gradient(180deg, #22d3ee, #0e7490); padding: 3px 8px;
  border-radius: 999px;
}
.chat {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 340px; overflow-y: auto; margin-bottom: 10px;
  scroll-behavior: smooth;
}
.chat:empty { display: none; }
.msg {
  max-width: 88%; padding: 9px 12px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.msg.user {
  align-self: flex-end; color: #04141a; border-bottom-right-radius: 4px;
  background: linear-gradient(180deg, #29c9e2, #12889f);
}
.msg.ai {
  align-self: flex-start; background: var(--card-2); border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.err { border-color: var(--danger); color: #ffd9e0; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 11.5px; padding: 2px; }
.msg.typing { color: var(--muted); font-style: italic; }
.public-link { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.public-link a { color: var(--accent); text-decoration: none; font-size: 12px; word-break: break-all; }

/* --------------------------------------------------------------- buttons */
.btn {
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 14px; height: var(--tap); padding: 0 18px; font-size: 15px;
  font-weight: 600; cursor: pointer; transition: transform .06s, filter .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #1fb9d4, var(--accent-dim)); border-color: #0e7490; color: #04141a; }
.btn.danger { background: linear-gradient(180deg, #f43f5e, #be123c); border-color: #9f1239; color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.small { height: 38px; font-size: 13px; padding: 0 14px; }
.btn:disabled { opacity: .55; pointer-events: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line); cursor: pointer;
}
.icon-btn:active { transform: scale(.95); }

/* --------------------------------------------------------------- actions */
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.act {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 14px; padding: 12px; min-height: 62px; cursor: pointer;
  transition: transform .06s, border-color .15s, background .15s;
}
.act:active { transform: scale(.975); }
.act .ico { font-size: 20px; width: 26px; text-align: center; flex: 0 0 26px; }
.act .ico svg { display: block; margin: 0 auto; }
.act .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.act .txt b { font-size: 14px; font-weight: 600; }
.act .txt span { font-size: 11px; color: var(--muted); }
.act.warn { border-color: rgba(245, 158, 11, .35); }
.act.danger { border-color: rgba(244, 63, 94, .38); }
.act.danger .ico { color: var(--danger); }
.act:disabled { opacity: .5; }
.app-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}

/* ------------------------------------------------------------------ logs */
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 210px; overflow: auto; }
.log-list li {
  display: flex; gap: 8px; align-items: baseline; font-size: 12px;
  padding: 6px 8px; background: var(--card-2); border-radius: 8px; border: 1px solid var(--line);
}
.log-list .t { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.log-list .k { color: var(--accent); flex: 0 0 auto; }
.log-list .d { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.log-empty { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(4, 8, 12, .78);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.dialog {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 22px; text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.94); opacity: .5; } to { transform: scale(1); opacity: 1; } }
.dialog-icon { font-size: 34px; }
.dialog h2 { margin: 8px 0 6px; font-size: 19px; }
.dialog-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

.pending {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 30; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #2a1114; border: 1px solid var(--danger); border-radius: 14px;
  padding: 10px 12px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.5);
}

.shot-wrap { width: 100%; max-width: 900px; display: flex; flex-direction: column; gap: 10px; }
.shot-wrap img { width: 100%; border-radius: 14px; border: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  max-width: 90vw; background: #0d1a22; border: 1px solid var(--accent-dim);
  color: var(--text); padding: 11px 16px; border-radius: 12px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: rise .18s ease-out;
}
.toast.bad { border-color: var(--danger); background: #1d0e13; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.footer { text-align: center; padding: 6px 0 0; }

@media (max-width: 360px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .actions { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
