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

:root {
  --bg:         #080810;
  --surface:    #0f0f1a;
  --surface2:   #13131f;
  --border:     #1e1e30;
  --accent:     #8b5cf6;
  --accent2:    #3b82f6;
  --glow:       rgba(139, 92, 246, 0.45);
  --glow-blue:  rgba(59, 130, 246, 0.45);
  --text:       #f1f5f9;
  --text-dim:   #94a3b8;
  --text-muted: #64748b;
  --user-bg:    #1a2a3a;
  --aria-bg:    #1a1030;
  --error:      #ef4444;
  --r:          12px;
  --r-sm:       8px;
  --t:          0.3s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── LOGIN ──────────────────────────────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: auto;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(139,92,246,.12) 0%, transparent 65%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 52px 44px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.aria-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-bottom: 6px;
}

.logo-orb {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c4b5fd, #8b5cf6 40%, #3b82f6 80%, #1e40af);
  box-shadow: 0 0 40px rgba(139,92,246,.5), 0 0 80px rgba(139,92,246,.15);
  animation: breathe 4s ease-in-out infinite;
}

.aria-logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--text);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 36px;
  letter-spacing: .5px;
}

.input-group { margin-bottom: 12px; }

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,92,246,.12);
}
.input-group input::placeholder { color: var(--text-muted); }

.btn-enter {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: all var(--t);
}
.btn-enter:hover  { background: #7c3aed; box-shadow: 0 0 20px rgba(139,92,246,.4); }
.btn-enter:active { transform: scale(.98); }
.btn-enter:disabled { opacity: .6; cursor: not-allowed; }

.error-msg { color: var(--error); font-size: 13px; margin-top: 12px; }

/* ── APP LAYOUT ─────────────────────────────────────────────────────────── */
body.app-page {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
}

/* ── HEADER ─────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text);
}

.brand-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 7px var(--accent);
  animation: blink 2.5s ease-in-out infinite;
}

.header-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  font-size: 15px;
  transition: all var(--t);
}
.icon-btn:hover  { border-color: var(--accent); color: var(--text); }
.icon-btn.muted  { border-color: var(--error); color: var(--error); }

/* ── MAIN / ORB ─────────────────────────────────────────────────────────── */
.app-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
  min-height: 0;
}

.orb-container {
  position: relative;
  width: 200px; height: 200px;
  display: flex; align-items: center; justify-content: center;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid transparent;
  opacity: 0;
}
.ring-1 { width: 130px; height: 130px; }
.ring-2 { width: 170px; height: 170px; }
.ring-3 { width: 210px; height: 210px; }

.orb-core {
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c4b5fd, #8b5cf6 40%, #3b82f6 75%, #1e40af);
  box-shadow: 0 0 24px rgba(139,92,246,.3);
  transition: box-shadow .4s ease, background .4s ease;
}

/* — IDLE — */
.orb.idle .orb-core { animation: breathe 4s ease-in-out infinite; }

/* — LISTENING — */
.orb.listening .orb-core {
  animation: pulse-listen .9s ease-in-out infinite;
  background: radial-gradient(circle at 35% 35%, #bfdbfe, #3b82f6 40%, #1d4ed8 75%, #1e3a8a);
  box-shadow: 0 0 50px var(--glow-blue), 0 0 90px rgba(59,130,246,.15);
}
.orb.listening .orb-ring {
  opacity: 1;
  border-color: rgba(59,130,246,.35);
  animation: ring-out .9s ease-out infinite;
}
.orb.listening .ring-2 { animation-delay: .3s; }
.orb.listening .ring-3 { animation-delay: .6s; }

/* — THINKING — */
.orb.thinking .orb-core {
  animation: hue-spin 1.8s linear infinite;
  box-shadow: 0 0 40px var(--glow), 0 0 70px rgba(59,130,246,.2);
}

/* — SPEAKING — */
.orb.speaking .orb-core {
  animation: pulse-speak .45s ease-in-out infinite;
  box-shadow: 0 0 60px var(--glow), 0 0 120px rgba(139,92,246,.25);
}
.orb.speaking .orb-ring {
  opacity: 1;
  border-color: rgba(139,92,246,.4);
  animation: ring-out .6s ease-out infinite;
}
.orb.speaking .ring-2 { animation-delay: .2s; }
.orb.speaking .ring-3 { animation-delay: .4s; }

/* — MUTED — */
.orb.muted .orb-core {
  background: radial-gradient(circle at 35% 35%, #475569, #334155 40%, #1e293b 75%, #0f172a);
  box-shadow: 0 0 8px rgba(0,0,0,.3);
  animation: none;
}

/* — ERROR / DISCONNECTED — */
.orb.error .orb-core {
  background: radial-gradient(circle at 35% 35%, #fca5a5, #ef4444 40%, #dc2626 75%, #991b1b);
  box-shadow: 0 0 30px rgba(239,68,68,.4);
  animation: breathe 2s ease-in-out infinite;
}

/* ── ANIMATIONS ─────────────────────────────────────────────────────────── */
@keyframes breathe      { 0%,100%{transform:scale(1)}   50%{transform:scale(1.04)} }
@keyframes pulse-listen { 0%,100%{transform:scale(1)}   50%{transform:scale(1.09)} }
@keyframes pulse-speak  { 0%,100%{transform:scale(1)}   50%{transform:scale(1.13)} }
@keyframes hue-spin     { 0%{filter:hue-rotate(0deg)}  100%{filter:hue-rotate(360deg)} }
@keyframes blink        { 0%,100%{opacity:1}            50%{opacity:.35} }
@keyframes ring-out     { 0%{transform:scale(.7);opacity:.6} 100%{transform:scale(1.3);opacity:0} }

/* ── STATUS TEXT ────────────────────────────────────────────────────────── */
.status-text {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: .5px;
  text-align: center;
  min-height: 20px;
}

/* ── TRANSCRIPT ─────────────────────────────────────────────────────────── */
.transcript-section {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface);
  min-height: 130px;
  max-height: 42vh;
  flex-shrink: 0;
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 18px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  transition: color var(--t);
}
.clear-btn:hover { color: var(--error); }

.transcript-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.transcript-body::-webkit-scrollbar { width: 3px; }
.transcript-body::-webkit-scrollbar-track { background: transparent; }
.transcript-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 87%;
  animation: msg-in .18s ease-out;
}
@keyframes msg-in { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:translateY(0)} }

.msg-user   { align-self: flex-end; align-items: flex-end; }
.msg-aria   { align-self: flex-start; align-items: flex-start; }

.msg-role {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 4px;
}

.msg-text {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.msg-user .msg-text { background: var(--user-bg); border-bottom-right-radius: 4px; }
.msg-aria .msg-text { background: var(--aria-bg); border-bottom-left-radius: 4px; }

.msg-aria.streaming .msg-text::after {
  content: '▋';
  display: inline-block;
  margin-left: 2px;
  color: var(--accent);
  animation: cursor-blink .75s step-end infinite;
}
@keyframes cursor-blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── START OVERLAY ──────────────────────────────────────────────────────── */
.start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,8,16,.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: pointer;
  transition: opacity .5s ease;
  backdrop-filter: blur(6px);
}
.start-overlay.fade-out { opacity: 0; pointer-events: none; }

.start-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.start-orb {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c4b5fd, #8b5cf6 40%, #3b82f6 80%, #1e40af);
  box-shadow: 0 0 40px rgba(139,92,246,.5);
  animation: breathe 3s ease-in-out infinite;
}
.start-content h2 { font-size: 20px; font-weight: 600; color: var(--text); }
.start-content p  { font-size: 13px; color: var(--text-muted); }

/* ── ADMIN ──────────────────────────────────────────────────────────────── */
body.admin-page { overflow: auto; background: var(--bg); }

.admin-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 36px 20px 60px;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.admin-top h1 { font-size: 18px; font-weight: 700; letter-spacing: 3px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  margin-bottom: 18px;
}
.card-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.fg { margin-bottom: 14px; }
.fg label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.fg input, .fg textarea, .fg select {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color var(--t);
}
.fg input:focus, .fg textarea:focus, .fg select:focus { border-color: var(--accent); }
.fg textarea { min-height: 72px; }

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.voice-card {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: center;
  transition: all var(--t);
}
.voice-card:hover  { border-color: var(--accent); }
.voice-card.active { border-color: var(--accent); background: rgba(139,92,246,.1); }
.voice-card strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 3px; }
.voice-card em     { font-size: 11px; color: var(--text-muted); font-style: normal; }

.btn-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }

.btn-save {
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t);
}
.btn-save:hover { background: #7c3aed; box-shadow: 0 0 16px rgba(139,92,246,.35); }

.btn-back {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all var(--t);
}
.btn-back:hover { border-color: var(--text-dim); color: var(--text); }

.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t);
  font-size: 13px;
}
.history-item:hover { border-color: var(--accent); }
.history-item .h-date { color: var(--text-dim); }
.history-item .h-count { color: var(--text-muted); font-size: 11px; }

.history-msgs {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: none;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.history-msgs.open { display: flex; }
.history-msg { font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.history-msg b { color: var(--accent); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }

.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(6px);
  transition: all .3s ease;
  z-index: 999;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .login-card { padding: 36px 24px; }
  .orb-core { width: 88px; height: 88px; }
  .orb-container { width: 160px; height: 160px; }
}
