/* ─── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #050810;
  --surface: #090d18;
  --border:  #0e1c35;
  --glow:    #00d4ff;
  --glow2:   #7b2fff;
  --text:    #b8cce0;
  --muted:   #2e4a68;
  --accent:  #00d4ff;
  --green:   #00ff88;
  --yellow:  #ffcc00;
  --red:     #ff3355;
  --orange:  #ff6633;
  --r:       5px;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar           { width: 3px; height: 3px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Header ────────────────────────────────────────────────────────────────── */
header {
  flex: 0 0 auto;
  height: 46px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: var(--surface);
  position: relative; z-index: 20;
}
header::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--glow2) 30%, var(--glow) 60%, transparent 100%);
  opacity: 0.35;
}

.logo { display: flex; align-items: center; gap: 8px; font-family: 'Orbitron', sans-serif; user-select: none; }
.logo-icon {
  font-size: 18px; color: var(--glow);
  text-shadow: 0 0 14px var(--glow), 0 0 28px rgba(0,212,255,.4);
  animation: icon-pulse 3s ease-in-out infinite;
}
@keyframes icon-pulse {
  0%,100% { text-shadow: 0 0 14px var(--glow), 0 0 28px rgba(0,212,255,.4); }
  50%      { text-shadow: 0 0 22px var(--glow), 0 0 50px rgba(0,212,255,.6); }
}
.logo-text { font-size: 17px; font-weight: 900; letter-spacing: 5px; color: var(--glow); text-shadow: 0 0 20px rgba(0,212,255,.5); }
.logo-ver  { font-size: 9px; color: var(--muted); letter-spacing: 1px; margin-top: 3px; }

.header-center { font-family: 'Orbitron', sans-serif; font-size: 12px; color: var(--muted); letter-spacing: 3px; }
.header-right  { display: flex; align-items: center; gap: 10px; }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  font-family: 'Orbitron', sans-serif;
  font-size: 8px; font-weight: 700;
  padding: 3px 8px; border-radius: 2px;
  letter-spacing: 1.5px; text-transform: uppercase;
}
.badge-online  { background: rgba(0,255,136,.08); color: var(--green); border: 1px solid rgba(0,255,136,.25); }
.badge-offline { background: rgba(255,51,85,.08);  color: var(--red);   border: 1px solid rgba(255,51,85,.25); }
.badge-pi {
  background: rgba(0,212,255,.08); color: var(--accent);
  border: 1px solid rgba(0,212,255,.2);
  font-family: 'Orbitron', sans-serif; font-size: 7px; font-weight: 700;
  padding: 2px 5px; letter-spacing: 1px;
}

/* ─── Overlay / Login ───────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(5,8,16,.96);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(12px);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 44px 40px; width: 340px;
  text-align: center; display: flex; flex-direction: column; gap: 16px;
  position: relative; overflow: hidden;
  box-shadow: 0 0 40px rgba(0,212,255,.08), 0 0 80px rgba(123,47,255,.06);
}
.login-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--glow2), var(--glow), var(--glow2));
  background-size: 200% 100%;
  animation: border-slide 4s linear infinite;
}
@keyframes border-slide { 0% { background-position: 0% 0; } 100% { background-position: 200% 0; } }
.login-logo { font-family: 'Orbitron', sans-serif; font-size: 26px; font-weight: 900; letter-spacing: 6px; color: var(--glow); text-shadow: 0 0 30px rgba(0,212,255,.6); }
.login-sub  { color: var(--muted); font-size: 10px; letter-spacing: 1.5px; }

input {
  width: 100%; padding: 10px 13px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text);
  font-family: inherit; font-size: 12px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus   { border-color: rgba(0,212,255,.5); box-shadow: 0 0 0 2px rgba(0,212,255,.1); }
input::placeholder { color: var(--muted); }

button { cursor: pointer; border: none; border-radius: var(--r); font-family: inherit; transition: all .15s; }
button:hover { opacity: .85; }

#btn-login {
  background: linear-gradient(135deg, #003a6e, #0066bb, var(--accent));
  color: #fff; width: 100%; padding: 12px;
  font-family: 'Orbitron', sans-serif; font-size: 11px; font-weight: 700; letter-spacing: 3px;
  box-shadow: 0 0 20px rgba(0,212,255,.25);
}
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 6px 10px; font-size: 14px; }
.btn-ghost:hover { border-color: var(--red); color: var(--red); }
.error  { color: var(--red); font-size: 10px; }
.hidden { display: none !important; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
#app         { flex: 1 1 0; overflow: hidden; display: flex; flex-direction: column; }
.main-layout { flex: 1 1 0; display: flex; overflow: hidden; }

/* ─── Brain panel (75%) ─────────────────────────────────────────────────────── */
.brain-panel {
  flex: 0 0 75%;
  position: relative; overflow: hidden;
  border-right: 1px solid var(--border);
}
#brain-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.brain-tl {
  position: absolute; top: 14px; left: 16px;
  display: flex; flex-direction: column; gap: 3px;
  pointer-events: none;
}
.brain-stat { font-family: 'Orbitron', sans-serif; font-size: 9px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; }

.brain-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 22px;
  font-size: 9px; color: var(--muted); opacity: .35; letter-spacing: 1px;
  pointer-events: none;
}

/* ─── Node info popup ───────────────────────────────────────────────────────── */
.node-info {
  position: absolute; bottom: 50px; left: 18px;
  background: rgba(9,13,24,.94); border: 1px solid rgba(0,212,255,.22);
  border-radius: var(--r); padding: 13px 15px;
  min-width: 230px; max-width: 280px;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 20px rgba(0,212,255,.07), 0 4px 24px rgba(0,0,0,.5);
  animation: node-appear .18s ease;
}
@keyframes node-appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.node-info::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--glow), transparent);
}
.ni-header { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.ni-dot    { font-size: 8px; }
.ni-name   { font-family: 'Orbitron', sans-serif; font-size: 13px; font-weight: 700; color: var(--glow); }
.ni-cat    { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 8px; }
.ni-desc   { font-size: 11px; color: var(--text); line-height: 1.6; margin-bottom: 8px; }
.ni-row    { font-size: 9px; color: var(--muted); }
.ni-label  { margin-right: 4px; }

/* ─── Sidebar (25%) ─────────────────────────────────────────────────────────── */
.sidebar { flex: 0 0 25%; display: flex; flex-direction: column; overflow-y: auto; background: var(--surface); }

.s-panel       { padding: 12px 13px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.s-panel-flex  { display: flex; flex-direction: column; min-height: 0; }
.s-panel-chat  { display: flex; flex-direction: column; }

.s-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 8px; font-weight: 700; letter-spacing: 2.5px;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: 10px; display: flex; align-items: center; gap: 7px;
}

.agent-status { font-size: 10px; }

/* ─── Metrics ───────────────────────────────────────────────────────────────── */
.metric-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.metric-row:last-child { margin-bottom: 0; }
.m-lbl   { font-size: 9px; color: var(--muted); width: 28px; letter-spacing: 1px; }
.m-track { flex: 1; height: 3px; background: rgba(255,255,255,.04); border-radius: 2px; overflow: hidden; }
.m-fill  {
  height: 100%; width: 0%; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--glow2));
  transition: width .5s ease, background .3s;
  box-shadow: 0 0 5px rgba(0,212,255,.35);
}
.m-fill.warn   { background: linear-gradient(90deg, var(--yellow), #ff8800); box-shadow: 0 0 5px rgba(255,204,0,.35); }
.m-fill.danger { background: linear-gradient(90deg, var(--red), var(--orange)); box-shadow: 0 0 5px rgba(255,51,85,.35); }
.m-val { font-size: 10px; color: var(--text); width: 40px; text-align: right; }

/* ─── Event feed ────────────────────────────────────────────────────────────── */
.feed { list-style: none; overflow-y: auto; max-height: 145px; display: flex; flex-direction: column; gap: 2px; }
.feed li {
  display: flex; gap: 6px; align-items: flex-start;
  font-size: 9px; color: var(--muted); line-height: 1.5;
  padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.02);
}
.feed li .ts        { flex: 0 0 auto; opacity: .4; }
.feed li.type-actions   { color: #4dc; }
.feed li.type-anomalies { color: var(--yellow); }
.feed li.type-diagnosis { color: #a98fff; }

/* ─── Chat ──────────────────────────────────────────────────────────────────── */
.thinking-dot { font-size: 8px; color: var(--accent); animation: think-blink .7s ease-in-out infinite; }
@keyframes think-blink { 0%,100% { opacity: 1 } 50% { opacity: .1 } }

.chat-messages { height: 185px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; padding-right: 2px; }
.chat-msg { max-width: 92%; font-size: 11px; line-height: 1.55; padding: 7px 10px; border-radius: 4px; animation: msg-appear .15s ease; }
@keyframes msg-appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg.user      { align-self: flex-end; background: rgba(0,212,255,.08); border: 1px solid rgba(0,212,255,.18); color: var(--accent); }
.chat-msg.assistant { align-self: flex-start; background: rgba(123,47,255,.08); border: 1px solid rgba(123,47,255,.18); color: #c0aaff; }

.chat-row { display: flex; gap: 4px; align-items: center; }
.chat-row input   { flex: 1; padding: 7px 10px; }
.chat-row button  { padding: 7px 9px; font-size: 12px; background: rgba(0,212,255,.08); border: 1px solid rgba(0,212,255,.18); color: var(--accent); }
.chat-row button:hover { background: rgba(0,212,255,.16); }
#btn-mic.recording { color: var(--red); border-color: rgba(255,51,85,.4); background: rgba(255,51,85,.08); }

/* ─── Actions ───────────────────────────────────────────────────────────────── */
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.skill-btn {
  background: rgba(255,255,255,.02); border: 1px solid var(--border);
  color: var(--muted); font-family: 'Orbitron', sans-serif;
  font-size: 8px; font-weight: 700; letter-spacing: 1.5px; padding: 9px 8px;
  transition: all .2s;
}
.skill-btn:hover   { background: rgba(0,212,255,.07); border-color: rgba(0,212,255,.35); color: var(--accent); box-shadow: 0 0 10px rgba(0,212,255,.08); }
.skill-btn:active  { transform: scale(.97); }

.skill-result {
  margin-top: 8px; padding: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r);
  font-size: 9px; color: var(--text); max-height: 120px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}

/* ─── System time ───────────────────────────────────────────────────────────── */
.sys-time { font-variant-numeric: tabular-nums; letter-spacing: 2px; }

/* ─── Weather widget ────────────────────────────────────────────────────────── */
.weather-main {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.weather-icon { font-size: 28px; line-height: 1; }
.weather-temp {
  font-family: 'Orbitron', sans-serif; font-size: 26px; font-weight: 700;
  color: var(--glow); text-shadow: 0 0 12px rgba(0,212,255,.4);
}
.weather-desc { font-size: 10px; color: var(--muted); letter-spacing: 1px; text-transform: capitalize; flex: 1; }
.weather-details {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px;
  font-size: 9px; color: var(--muted); margin-bottom: 10px;
}
.weather-forecast {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px;
}
.weather-forecast::-webkit-scrollbar { height: 2px; }
.wf-day {
  flex: 0 0 auto; text-align: center;
  background: rgba(255,255,255,.02); border: 1px solid var(--border);
  border-radius: var(--r); padding: 6px 8px;
  font-size: 9px; color: var(--muted);
  display: flex; flex-direction: column; gap: 3px;
}
.wf-day .wf-name { font-size: 8px; letter-spacing: 0.5px; text-transform: capitalize; }
.wf-day .wf-temp { font-size: 10px; color: var(--text); }
.wf-day .wf-ico  { font-size: 16px; }

/* ─── Mobile nav (hidden on desktop) ───────────────────────────────────────── */
.mobile-nav { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE — max 767px
   Samsung Galaxy Note 20 5G : 412×915px, AMOLED, ratio 3x
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* Body */
  html, body { overflow: hidden; height: 100%; }
  body { font-size: 14px; }

  /* ── Header ── */
  header { height: 52px; padding: 0 14px; }
  .logo-icon { font-size: 20px; }
  .logo-text { font-size: 16px; letter-spacing: 4px; }
  .logo-ver  { display: none; }
  .header-center { display: none; }
  .badge { font-size: 10px; padding: 4px 10px; }
  .btn-ghost { font-size: 18px; padding: 8px 12px; min-height: 44px; }

  /* ── Login ── */
  .login-card { width: calc(100vw - 32px); max-width: 400px; padding: 36px 24px; }
  .login-logo { font-size: 22px; letter-spacing: 4px; }
  .login-sub  { font-size: 12px; }
  input { font-size: 16px; padding: 14px 16px; }
  #btn-login { font-size: 13px; padding: 16px; min-height: 52px; letter-spacing: 2px; }
  .error { font-size: 13px; }

  /* ── App layout ── */
  #app        { flex: 1 1 0; display: flex; flex-direction: column; overflow: hidden; }
  .main-layout { flex: 1 1 0; position: relative; overflow: hidden; }

  /* Brain panel — full area, JS controls visibility */
  .brain-panel {
    position: absolute; inset: 0;
    flex: unset; border-right: none;
    width: 100%; height: 100%;
  }

  /* Sidebar — full area, JS controls visibility */
  .sidebar {
    position: absolute; inset: 0;
    flex: unset; width: 100%;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 68px;
  }

  /* Panels */
  .s-panel { padding: 20px 16px; border-bottom: none; }
  .s-title  { font-size: 11px; letter-spacing: 2px; margin-bottom: 18px; }

  /* ── Metrics ── */
  .metric-row { margin-bottom: 16px; gap: 12px; }
  .m-lbl   { font-size: 13px; width: 40px; }
  .m-track { height: 6px; border-radius: 3px; }
  .m-val   { font-size: 15px; width: 54px; }

  /* ── Event feed ── */
  .feed { max-height: 60vh; gap: 4px; }
  .feed li { font-size: 13px; padding: 7px 0; gap: 8px; }

  /* ── Chat ── */
  .s-panel-chat { height: calc(100vh - 120px); display: flex; flex-direction: column; }
  .chat-messages { flex: 1 1 0; height: auto; gap: 10px; margin-bottom: 12px; }
  .chat-msg { font-size: 14px; padding: 10px 14px; border-radius: 8px; max-width: 88%; }
  .chat-row { gap: 8px; }
  .chat-row input  { font-size: 16px; padding: 13px 14px; }
  .chat-row button { font-size: 20px; padding: 13px 14px; min-width: 50px; min-height: 50px; }

  /* ── Actions ── */
  .actions-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .skill-btn { font-size: 11px; padding: 18px 10px; min-height: 56px; border-radius: 8px; }
  .skill-result { font-size: 12px; max-height: 40vh; }

  /* ── Mobile bottom nav ── */
  .mobile-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 62px; z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,.6);
  }
  .mnav-btn {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; background: transparent;
    color: var(--muted); border: none; border-radius: 0;
    min-height: 62px; padding: 0;
    font-size: 20px;
    transition: color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mnav-btn span { font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.5px; }
  .mnav-btn.active { color: var(--accent); background: rgba(0,212,255,.07); }
  .mnav-btn:active  { background: rgba(0,212,255,.14); }
}
