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

:root {
  --bg:        #111111;
  --surface:   #1c1c1e;
  --surface2:  #2a2a2e;
  --border:    rgba(255,255,255,.08);
  --accent:    #7c6fcd;
  --accent-lo: rgba(124,111,205,.15);
  --text:      #f0f0f0;
  --text2:     rgba(240,240,240,.45);
  --red:       #ef4444;
  --green:     #22c55e;
  --seg-idle:  rgba(255,255,255,.06);
  --seg-hover: rgba(124,111,205,.35);
  --seg-border:rgba(255,255,255,.12);
  --r: 14px;
}

html, body {
  height: 100%;
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: ltr;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Pages ── */
.page { display: none; height: 100dvh; flex-direction: column; }
.page.active { display: flex; }

/* ═══════════════════════════════════
   LOGIN
═══════════════════════════════════ */
#page-login {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,111,205,.18) 0%, transparent 65%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.auth-logo {
  position: relative;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.logo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: .6;
  animation: spin-slow 8s linear infinite;
}
.logo-icon {
  font-size: 2rem;
  color: var(--accent);
}
@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

.auth-card h1 { font-size: 2rem; font-weight: 700; letter-spacing: .04em; }
.auth-sub { color: var(--text2); font-size: .9rem; }

.tabs {
  display: flex;
  width: 100%;
  background: var(--surface);
  border-radius: 12px;
  padding: 4px;
  margin-top: 8px;
}
.tab-btn {
  flex: 1;
  padding: 9px;
  border-radius: 9px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: .9rem;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.tab-btn.active { background: var(--surface2); color: var(--text); }

.tab-panel { display: none; width: 100%; }
.tab-panel.active { display: block; }

.auth-card input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 10px;
  outline: none;
  transition: border-color .2s;
}
.auth-card input:focus { border-color: var(--accent); }

.btn-submit {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: opacity .2s, transform .1s;
}
.btn-submit:hover { opacity: .88; }
.btn-submit:active { transform: scale(.97); }
.btn-submit:disabled { opacity: .45; cursor: default; }

.err {
  color: var(--red);
  font-size: .82rem;
  min-height: 1.2em;
  text-align: center;
  margin-top: 6px;
}

/* ═══════════════════════════════════
   CHAT
═══════════════════════════════════ */
#page-chat {
  background: radial-gradient(ellipse at 50% 100%, rgba(124,111,205,.12) 0%, transparent 60%);
}

/* Messages */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#messages::-webkit-scrollbar { width: 3px; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#empty-hint {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  color: var(--text2);
  font-size: .85rem;
  letter-spacing: .02em;
}

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: .95rem;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
  animation: pop-in .2s ease;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.bubble-user {
  align-self: flex-end;
  background: var(--accent);
  border-bottom-right-radius: 4px;
}
.bubble-assistant {
  align-self: flex-start;
  background: var(--surface2);
  border-bottom-left-radius: 4px;
}

/* Status */
#status-bar {
  text-align: center;
  padding: 4px 0 10px;
}
#status-text {
  font-size: .8rem;
  color: var(--text2);
  transition: color .3s;
}

/* ── Radial area ── */
#radial-wrap {
  position: relative;
  width: 320px;
  height: 320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#radial-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
}
#radial-svg.open {
  opacity: 1;
  pointer-events: all;
}

/* SVG segment styles */
.seg {
  fill: var(--seg-idle);
  stroke: var(--seg-border);
  stroke-width: 1;
  transition: fill .15s;
  cursor: pointer;
}
.seg.active {
  fill: var(--seg-hover);
  filter: url(#glow);
}

.seg-icon {
  pointer-events: none;
  opacity: .6;
  transition: opacity .15s;
}
.seg-icon path,
.seg-icon circle {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.seg-icon.active {
  opacity: 1;
}
.seg-icon.active path,
.seg-icon.active circle {
  stroke: #a89be0;
}

/* Center mic button */
#mic-btn {
  position: relative;
  z-index: 10;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  box-shadow:
    0 0 0 1px var(--border),
    0 8px 32px rgba(0,0,0,.5);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition:
    width .3s cubic-bezier(.34,1.56,.64,1),
    height .3s cubic-bezier(.34,1.56,.64,1),
    background .3s,
    box-shadow .3s;
  touch-action: none;
}
#mic-btn.recording {
  background: rgba(239,68,68,.18);
  box-shadow: 0 0 0 1px rgba(239,68,68,.4), 0 0 32px rgba(239,68,68,.3);
  animation: breathe 1.4s ease-in-out infinite;
}
#mic-btn.menu-open {
  width: 84px;
  height: 84px;
  background: var(--surface2);
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px rgba(124,111,205,.3);
}

@keyframes breathe {
  0%,100% { box-shadow: 0 0 0 1px rgba(239,68,68,.4), 0 0 24px rgba(239,68,68,.25); }
  50%      { box-shadow: 0 0 0 1px rgba(239,68,68,.6), 0 0 48px rgba(239,68,68,.45); }
}

.mic-icon {
  width: 32px;
  height: 32px;
  transition: all .3s;
}
#mic-btn.menu-open .mic-icon { width: 22px; height: 22px; opacity: .6; }
#mic-btn.recording .mic-icon { stroke: var(--red); }

#menu-label {
  font-size: .7rem;
  color: var(--text2);
  text-align: center;
  max-width: 70px;
  line-height: 1.3;
  min-height: 1em;
  transition: opacity .2s;
}

/* Bottom bar */
#bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 20px;
  flex-shrink: 0;
}
#user-chip {
  font-size: .78rem;
  color: var(--text2);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.icon-action {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background .15s;
}
.icon-action:hover { background: var(--surface); }

/* ── Panels ── */
.panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  animation: panel-in .25s ease;
}
.panel.hidden { display: none; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}

.panel-header {
  width: 100%;
  max-width: 500px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  font-weight: 600;
}
.panel-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
}
.panel-body {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-body textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: .95rem;
  resize: none;
  outline: none;
}
.muted { color: var(--text2); font-size: .9rem; }

.ss-item {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--border);
}
.ss-item .ss-cat { font-size: .75rem; color: var(--accent); margin-bottom: 4px; }
.ss-item .ss-summary { font-size: .9rem; line-height: 1.5; }
.ss-item .ss-url { font-size: .75rem; color: var(--text2); margin-top: 4px; word-break: break-all; }

/* ── Voice selector ── */
.settings-section {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.settings-section:last-child { border-bottom: none; margin-bottom: 0; }
.settings-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text2);
  margin-bottom: 10px;
}
.voice-options {
  display: flex;
  gap: 10px;
}
.voice-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.voice-btn:hover { border-color: var(--accent); }
.voice-btn.active {
  border-color: var(--accent);
  background: var(--accent-lo);
}
.voice-icon { font-size: 1.3rem; }
.voice-name { font-size: .9rem; font-weight: 600; }
.voice-sub  { font-size: .72rem; color: var(--text2); }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text2); font-size: .9rem; }
.stat-val { font-weight: 600; }

/* Notification banner */
#notif-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .85rem;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: pop-in .3s ease;
}
#notif-banner.hidden { display: none; }
#notif-enable {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: .82rem;
}
#notif-dismiss {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: .9rem;
}
