/* ═══════════════════════════════════════════════════════════════
   SPECTR V4 — Glafira Stylesheet
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #000;
  --srf: rgba(255,255,255,.07);
  --sep: rgba(255,255,255,.1);
  --txt: #fff;
  --mut: rgba(255,255,255,.5);
  --acc: #0a84ff;
  --user-bg: rgba(10,132,255,.25);
  --user-txt: #fff;
  --code-bg: rgba(255,255,255,.04);
  --code-sep: rgba(255,255,255,.06);
  --blur: blur(50px);
  --radius: 22px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
}

.light {
  --bg: #f2f2f7;
  --srf: rgba(255,255,255,.75);
  --sep: rgba(0,0,0,.08);
  --txt: #000;
  --mut: rgba(0,0,0,.45);
  --acc: #007aff;
  --user-bg: rgba(0,122,255,.18);
  --user-txt: #000;
  --code-bg: rgba(0,0,0,.03);
  --code-sep: rgba(0,0,0,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  position: fixed; top: 0; left: 0;
  background: var(--bg); color: var(--txt);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body {
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
}

/* Sidebar */
#sb {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 300px;
  background: var(--srf);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  z-index: 100;
  transform: translateX(0);
  transition: transform .3s;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
}
#sb.hid { transform: translateX(-100%); }

.sbh {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
}
.sbl {
  font-weight: 700; font-size: 17px;
  background: linear-gradient(135deg, var(--acc), #5eb8ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: 1px;
}
.light .sbl {
  background: linear-gradient(135deg, #007aff, #3399ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sbh-actions { display: flex; gap: 6px; }

.bi {
  background: rgba(128,128,128,.1); border: none; color: var(--txt);
  cursor: pointer; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.bi svg {
  width: 16px; height: 16px; stroke: var(--txt);
  fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

#ncb {
  margin: 8px 16px; padding: 12px;
  background: var(--acc); color: #fff; border: none;
  border-radius: var(--radius); cursor: pointer;
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

/* Chat list */
#cl { flex: 1; overflow-y: auto; padding: 4px 8px; }
.cr {
  display: flex; align-items: center; padding: 10px 12px;
  border-radius: 18px; cursor: pointer; font-size: 14px;
  gap: 10px; margin-bottom: 2px;
}
.cr.ac { background: rgba(128,128,128,.08); }
.cr span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd {
  background: none; border: none; color: var(--mut);
  cursor: pointer; opacity: 0; padding: 4px;
}
.cr:hover .cd { opacity: 1; }
.cd svg { width: 14px; height: 14px; stroke: var(--mut); fill: none; stroke-width: 2; }
.sbf {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; font-size: 11px; color: var(--mut);
}

/* Main area */
#mn {
  flex: 1; display: flex; flex-direction: column;
  max-width: 900px; margin: 0 auto; width: 100%; overflow: hidden;
}
.ch {
  display: flex; align-items: center; padding: 14px 16px 6px;
  gap: 8px; flex-shrink: 0; justify-content: space-between;
}
#logo-sigma { display: none; font-weight: 600; font-size: 17px; }
#header-actions {
  display: none; align-items: center; gap: 2px;
  background: rgba(128,128,128,.1); border-radius: 100px; padding: 4px;
}
#header-actions .bi { width: 28px; height: 28px; background: transparent; }

body:not(.sb-open) #logo-sigma { display: inline; }
body:not(.sb-open) #header-actions { display: flex; }
body:not(.sb-open) .ch h1 { display: none; }
.ch h1 {
  font-size: 13px; font-weight: 400; color: var(--mut);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Messages */
#msgs { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 16px; width: 100%; }
.msg { display: flex; margin-bottom: 14px; width: 100%; }
.msg.b { justify-content: flex-start; flex-direction: column; align-items: flex-start; }
.msg.u { justify-content: flex-end; }

.bub {
  padding: 14px 20px; border-radius: var(--radius);
  font-size: 16px; line-height: 1.5;
  word-break: break-word; overflow-wrap: break-word;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.msg.b .bub {
  background: var(--srf); border: 1px solid var(--sep);
  color: var(--txt); width: 100%;
}
.msg.u .bub {
  background: var(--user-bg); border: 1px solid rgba(10,132,255,.15);
  color: var(--user-txt); max-width: 70%;
}

/* Code blocks */
.code-bubble { background: var(--code-bg)!important; border: 1px solid var(--code-sep)!important; padding: 0!important; overflow: hidden; }
.code-bubble pre { padding: 14px 16px!important; margin: 0!important; overflow-x: auto; font-size: 14px; border: none!important; background: transparent!important; }
.code-bubble code { font-family: 'SF Mono', Monaco, monospace; font-size: 13px; background: transparent!important; }
.hljs { background: transparent!important; padding: 0!important; }
.code-actions { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; border-top: 1px solid var(--code-sep); }
.code-lang { font-size: 10px; color: var(--mut); text-transform: uppercase; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(128,128,128,.08); border: 1px solid rgba(128,128,128,.1);
  color: var(--mut); cursor: pointer; padding: 5px 10px; border-radius: 6px; font-size: 11px;
}
.copy-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Input */
.ia { padding: 12px 16px 20px; flex-shrink: 0; width: 100%; }
.qr { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; flex-wrap: nowrap; width: 100%; }
.qb {
  background: rgba(128,128,128,.06); border: 1px solid rgba(128,128,128,.08);
  color: var(--mut); padding: 6px 12px; border-radius: 100px;
  cursor: pointer; font-size: 12px; white-space: nowrap;
  flex-shrink: 0; display: flex; align-items: center;
}
.qb:active, .qb:hover { background: rgba(128,128,128,.12); color: var(--txt); }
#wth {
  font-size: 12px; color: var(--mut); cursor: pointer;
  white-space: nowrap; flex-shrink: 0; margin-left: auto;
}
.ir { display: flex; gap: 8px; align-items: flex-end; width: 100%; }
#inp {
  flex: 1; min-width: 0; background: transparent; border: none;
  padding: 14px 0; color: var(--txt); font-size: 16px;
  resize: none; outline: none; font-family: inherit;
}
#inp:focus { outline: none; border: none; }
#snd {
  width: 44px; height: 44px; background: var(--acc); border: none;
  border-radius: 50%; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 2px 12px rgba(10,132,255,.25);
}
#snd:active { transform: scale(.92); }
#snd svg {
  width: 18px; height: 18px; stroke: #fff; fill: none;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}

/* Loading */
.wv { display: flex; gap: 3px; align-items: center; height: 20px; }
.wv span { width: 4px; height: 14px; background: var(--acc); border-radius: 4px; animation: w .9s infinite; }
.wv span:nth-child(2) { animation-delay: .15s; }
.wv span:nth-child(3) { animation-delay: .3s; }
@keyframes w {
  0%, 100% { height: 6px; opacity: .4; }
  50% { height: 18px; opacity: 1; }
}

/* Footer */
.chat-footer {
  text-align: center; padding: 8px 0 0;
  font-size: 10px; color: var(--mut); user-select: none;
}

/* Search buttons */
.search-btn {
  display: inline-block; padding: 6px 14px; margin: 4px 4px 0 0;
  background: rgba(128,128,128,.1); border: 1px solid rgba(128,128,128,.15);
  border-radius: 100px; color: var(--acc); text-decoration: none; font-size: 13px;
}
.search-btn:hover { background: rgba(128,128,128,.2); }

/* Architect mode */
.architect-mode {
  --bg: #0a0e0a; --srf: rgba(0,255,65,.06); --sep: rgba(0,255,65,.15);
  --txt: #b8f0b8; --mut: rgba(0,255,65,.5); --acc: #00ff41;
  --user-bg: rgba(0,255,65,.15); --user-txt: #b8f0b8;
}
.architect-mode .sbl { color: #00ff41!important; -webkit-text-fill-color: #00ff41 !important; }
.architect-mode #ncb { border-color: rgba(0,255,65,.3)!important; color: #00ff41!important; }
.architect-mode .qb { border-color: rgba(0,255,65,.2)!important; color: #00ff41!important; }
.architect-mode #snd { background: #00ff41!important; box-shadow: 0 2px 12px rgba(0,255,65,.3)!important; }
.architect-mode .ch h1 { color: #00ff41!important; }
.architect-mode::after {
  content: "ARCHITECT MODE"; position: fixed; bottom: 4px; right: 8px;
  font-size: 8px; color: rgba(0,255,65,.3); letter-spacing: .2em; z-index: 999;
}

/* Responsive */
@media (max-width: 768px) {
  #sb { width: 280px; } #mn { max-width: 100%; } #msgs { padding: 8px 12px; }
  .msg.u .bub { max-width: 85%; } .bub { font-size: 15px; padding: 10px 14px; }
  .qb { font-size: 10px; padding: 4px 8px; } #wth { font-size: 10px; }
  .ch { padding: 12px 12px 4px; } .ia { padding: 8px 12px 16px; } #inp { font-size: 15px; padding: 12px 0; }
}
@media (max-width: 400px) {
  #sb { width: 260px; } #msgs { padding: 6px 10px; } .msg.u .bub { max-width: 90%; }
  .bub { font-size: 14px; padding: 8px 12px; } .qb { font-size: 9px; padding: 3px 6px; } #wth { font-size: 9px; }
  .ch { padding: 10px 10px 2px; } .ia { padding: 6px 10px 12px; } #inp { font-size: 14px; padding: 10px 0; }
}
@media (max-width: 360px) {
  .qb { font-size: 8px; padding: 3px 5px; } #wth { font-size: 8px; }
}

/* ═══════════════════════════════════════════════════════════════
   SPECTR V4 — Mode Switch & Socrates Theme
   ═══════════════════════════════════════════════════════════════ */

/* Mode switch tabs */
#mode-switch { flex-shrink: 0; }
.mode-btn {
  background: transparent; border: none; color: var(--mut);
  padding: 5px 14px; border-radius: 100px; cursor: pointer;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  transition: all .2s;
}
.mode-btn.active { background: rgba(128,128,128,.15); color: var(--txt); font-weight: 600; }
.mode-btn:hover { color: var(--txt); }

/* Socrates mode overrides */
body.sōkratēs-mode {
  --bg: #0a0a0a; --srf: rgba(255,255,255,.03);
  --sep: rgba(255,255,255,.06); --txt: #ccc;
  --mut: rgba(255,255,255,.35); --acc: #888;
  --user-bg: rgba(255,255,255,.06); --user-txt: #ccc;
}
body.sōkratēs-mode .bub { font-size: 15px; font-style: italic; }
body.sōkratēs-mode .msg.u .bub { font-style: normal; }
body.sōkratēs-mode #snd { background: #555; box-shadow: none; }
body.sōkratēs-mode .qb { display: none; }
body.sōkratēs-mode .chat-footer { color: rgba(255,255,255,.15); }
body.sōkratēs-mode #logo-sigma { color: var(--mut); }
body.sōkratēs-mode .mode-btn.active { background: rgba(255,255,255,.08); }
body.sōkratēs-mode #wth { display: none; }
body.sōkratēs-mode .qr { display: none !important; }

/* Socrates timer */
#socrates-timer {
  display: none; text-align: center; padding: 4px 0;
  font-size: 10px; color: var(--mut);
}
body.sōkratēs-mode #socrates-timer { display: block; }

/* Responsive: hide sidebar toggle in Socrates */
body.sōkratēs-mode #h-sidebar { opacity: .3; }

/* ═══════════════════════════════════════════════════════════════
   SPECTR V4 — Adaptive sidebar offset
   ═══════════════════════════════════════════════════════════════ */

/* Desktop: push main when sidebar open */
@media (min-width: 769px) {
  body.sb-open #mn {
    margin-left: 300px;
    transition: margin-left .3s;
  }
  body:not(.sb-open) #mn {
    margin: 0 auto;
    transition: margin-left .3s;
  }
}

/* Mobile: sidebar overlay, no push */
@media (max-width: 768px) {
  body.sb-open #mn {
    margin-left: 0;
  }
}



/* Message actions — under bubble, round buttons */
.msg-actions {
  display: flex; gap: 4px; margin-top: 6px;
}
.act-btn {
  background: none; border: 1px solid transparent; cursor: pointer; 
  padding: 6px; border-radius: 50%; color: var(--mut); transition: all .2s;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
}
.act-btn:hover { 
  color: var(--txt); background: rgba(128,128,128,.1); 
  border-color: var(--sep); border-radius: 50%;
}
.like-btn:hover { color: #34c759; border-color: rgba(52,199,89,.3); }
.like-btn.active { color: #34c759; background: rgba(52,199,89,.1); border-color: rgba(52,199,89,.3); }
.dislike-btn:hover { color: #ff3b30; border-color: rgba(255,59,48,.3); }
.dislike-btn.active { color: #ff3b30; background: rgba(255,59,48,.1); border-color: rgba(255,59,48,.3); }
.share-btn:hover { color: #5eb8ff; border-color: rgba(94,184,255,.3); }
.regen-btn:hover { color: #ff9f0a; border-color: rgba(255,159,10,.3); }
.copy-btn:hover { color: var(--acc); border-color: rgba(10,132,255,.3); }
