*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface2: #1e1e1e;
  --surface3: #252525;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --accent: #e8ff47;
  --accent-dim: rgba(232,255,71,0.12);
  --accent-glow: rgba(232,255,71,0.25);
  --text: #f0f0f0;
  --text2: #888;
  --text3: #555;
  --red: #ff4444;
  --green: #44ff88;
  --mono: 'DM Mono', monospace;
  --sans: 'Outfit', sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* SCREENS */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.screen.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* LOGIN */
#screen-login {
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
}
.orb1 { width: 400px; height: 400px; background: var(--accent); top: -100px; right: -100px; animation: drift1 8s ease-in-out infinite; }
.orb2 { width: 300px; height: 300px; background: #47aaff; bottom: -50px; left: -80px; animation: drift2 10s ease-in-out infinite; }
.orb3 { width: 200px; height: 200px; background: #ff47aa; top: 50%; left: 50%; transform: translate(-50%,-50%); animation: drift3 6s ease-in-out infinite; }

@keyframes drift1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-20px,20px)} }
@keyframes drift2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(20px,-15px)} }
@keyframes drift3 { 0%,100%{transform:translate(-50%,-50%) scale(1)} 50%{transform:translate(-50%,-50%) scale(1.2)} }

.login-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.brand {
  text-align: center;
  animation: fadeUp 0.6s ease both;
}
.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  margin-bottom: 16px;
  position: relative;
}
.brand-icon::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent-dim), transparent);
  pointer-events: none;
}
.brand-name {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.brand-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 4px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 500;
}

.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeUp 0.6s 0.1s ease both;
}

.login-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text2);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 44px 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.input-wrap input:focus {
  border-color: var(--accent);
}
.input-wrap input::placeholder { color: var(--text3); }
.input-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #0d0d0d;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 4px;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }

.login-hint {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  line-height: 1.5;
}

/* BIOMETRIC */
.bio-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px auto;
  cursor: pointer;
  position: relative;
  transition: border-color 0.3s;
}
.bio-ring::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid var(--accent-dim);
  animation: pulse-ring 2s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%,100%{opacity:0.3;transform:scale(1)}
  50%{opacity:1;transform:scale(1.05)}
}
.bio-ring:active { border-color: var(--accent); }
.bio-icon { display: flex; align-items: center; justify-content: center; }
.bio-label { text-align: center; font-size: 14px; color: var(--text2); }
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  color: var(--text2);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-ghost:hover { border-color: var(--border2); color: var(--text); }

/* APP HEADER */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.agent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  transition: background 0.3s;
}
.agent-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.agent-dot.busy { background: var(--accent); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.agent-name { font-size: 16px; font-weight: 600; }
.header-right { display: flex; gap: 4px; }
.icon-btn {
  background: none;
  border: none;
  color: var(--text2);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

/* TAB BAR */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: none;
  border: none;
  color: var(--text3);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
  position: relative;
}
.tab.active { color: var(--accent); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* TAB CONTENT */
.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}
.tab-content.active { display: flex; }
.tab-inner {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
}

/* MESSAGES */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.msg-system {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  padding: 4px 12px;
  background: var(--surface);
  border-radius: 20px;
  align-self: center;
  border: 1px solid var(--border);
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: msgIn 0.25s ease both;
}
@keyframes msgIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.agent { align-self: flex-start; align-items: flex-start; }
.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: #0d0d0d;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.msg.agent .msg-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  padding: 0 4px;
}
.msg-thinking {
  display: flex;
  gap: 4px;
  padding: 16px;
  align-self: flex-start;
}
.msg-thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: think 1.2s ease-in-out infinite;
}
.msg-thinking span:nth-child(2) { animation-delay: 0.2s; }
.msg-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes think { 0%,80%,100%{transform:scale(0.8);opacity:0.4} 40%{transform:scale(1.2);opacity:1} }

/* COMPOSER */
.composer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 12px 16px;
  padding-bottom: max(12px, var(--safe-bottom));
  flex-shrink: 0;
}
.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 8px 8px 8px 12px;
  transition: border-color 0.2s;
}
.composer-inner:focus-within { border-color: var(--border2); }
.composer-inner textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
  max-height: 120px;
  padding: 4px 0;
}
.composer-inner textarea::placeholder { color: var(--text3); }
.composer-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.voice-btn { background: var(--surface2); color: var(--text2); }
.voice-btn:hover { background: var(--surface3); color: var(--text); }
.voice-btn.recording { background: var(--red); color: white; animation: pulse-btn 1s ease-in-out infinite; }
@keyframes pulse-btn { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }
.send-btn { background: var(--accent); color: #0d0d0d; }
.send-btn:hover { opacity: 0.85; }
.send-btn:active { transform: scale(0.95); }

.voice-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px 2px;
}
.voice-waves {
  display: flex;
  gap: 3px;
  align-items: center;
  height: 20px;
}
.voice-waves span {
  width: 3px;
  border-radius: 2px;
  background: var(--red);
  animation: wave 1s ease-in-out infinite;
  height: 8px;
}
.voice-waves span:nth-child(1) { animation-delay: 0s; }
.voice-waves span:nth-child(2) { animation-delay: 0.1s; }
.voice-waves span:nth-child(3) { animation-delay: 0.2s; }
.voice-waves span:nth-child(4) { animation-delay: 0.1s; }
.voice-waves span:nth-child(5) { animation-delay: 0s; }
@keyframes wave { 0%,100%{height:4px} 50%{height:18px} }
.voice-label { font-size: 13px; color: var(--text2); flex: 1; }
.voice-cancel { background: none; border: none; color: var(--red); font-family: var(--sans); font-size: 13px; cursor: pointer; padding: 4px 8px; }

/* SKILLS */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 16px; font-weight: 600; }
.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text2);
}
.skills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.skill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.skill-card:hover { border-color: var(--border2); background: var(--surface2); }
.skill-icon { font-size: 24px; margin-bottom: 8px; }
.skill-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.skill-desc { font-size: 11px; color: var(--text2); margin-top: 4px; line-height: 1.4; }

.loading-state {
  grid-column: 1/-1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--text3);
  font-size: 13px;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to{transform:rotate(360deg)} }

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.stat-value { font-size: 18px; font-weight: 600; font-family: var(--mono); color: var(--accent); }

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 13px; color: var(--text2); flex-shrink: 0; }
.info-value { font-size: 13px; color: var(--text); text-align: right; word-break: break-all; }
.info-value.mono { font-family: var(--mono); font-size: 11px; }

.btn-danger {
  width: 100%;
  background: none;
  border: 1px solid rgba(255,68,68,0.3);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--red);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-danger:hover { background: rgba(255,68,68,0.1); }

/* TOAST */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ANIMATIONS */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 0; }

/* SETUP SCREEN */
#screen-setup {
  flex-direction: column;
  overflow-y: auto;
}
.setup-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.setup-title {
  font-size: 18px;
  font-weight: 600;
}
.setup-content {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}
.setup-section { display: flex; flex-direction: column; gap: 6px; }
.setup-section-title { font-size: 16px; font-weight: 600; }
.setup-section-desc { font-size: 13px; color: var(--text2); line-height: 1.5; }
.setup-field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); }
.setup-field input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}
.setup-field input:focus { border-color: var(--accent); }
.setup-field input::placeholder { color: var(--text3); }
.field-hint { font-size: 11px; color: var(--text3); line-height: 1.4; }
.setup-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text2);
  font-size: 13px;
}
.btn-secondary {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:hover { background: var(--surface2); border-color: var(--border2); }
