/* ── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Bebas+Neue&family=DM+Sans:wght@300;400;600;700&display=swap');

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg:       #000000;
  --surface:  #0a0a0a;
  --panel:    #0f0f0f;
  --raised:   #161616;
  --border:   rgba(255,255,255,0.06);
  --border-hi:rgba(255,255,255,0.14);

  --text:     #f0f0f0;
  --muted:    #555;
  --dim:      #333;

  /* Single vivid accent — cold crimson */
  --red:      #e63946;
  --red-glow: rgba(230,57,70,0.25);
  --red-dim:  rgba(230,57,70,0.08);

  /* Occasional silver sheen */
  --silver:   #c8c8c8;
  --white:    #ffffff;

  --radius:   10px;
  --radius-lg:16px;
  --mono:     'DM Mono', monospace;
  --sans:     'DM Sans', sans-serif;
  --display:  'Bebas Neue', sans-serif;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.6);
  --shadow-md: 0 8px 30px rgba(0,0,0,0.8);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.9);

  --ease:     cubic-bezier(.22,.9,.22,1);
  --ease-back:cubic-bezier(.34,1.56,.64,1);
  --t:        200ms;
}

/* ── Keyframes ────────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity:0; transform:translateY(14px); }
  to   { opacity:1; transform:translateY(0); }
}
@keyframes fadeIn {
  from { opacity:0; }
  to   { opacity:1; }
}
@keyframes slideInLeft {
  from { opacity:0; transform:translateX(-20px); }
  to   { opacity:1; transform:translateX(0); }
}
@keyframes slideInRight {
  from { opacity:0; transform:translateX(20px); }
  to   { opacity:1; transform:translateX(0); }
}
@keyframes scaleIn {
  from { opacity:0; transform:scale(.92); }
  to   { opacity:1; transform:scale(1); }
}
@keyframes pulse-border {
  0%,100% { box-shadow: 0 0 0 0 var(--red-glow); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
@keyframes scanline {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}
@keyframes blink {
  0%,100% { opacity:1; }
  50%      { opacity:0; }
}
@keyframes msgIn-me {
  from { opacity:0; transform:translateX(16px) scale(.97); }
  to   { opacity:1; transform:translateX(0) scale(1); }
}
@keyframes msgIn-other {
  from { opacity:0; transform:translateX(-16px) scale(.97); }
  to   { opacity:1; transform:translateX(0) scale(1); }
}
@keyframes liIn {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
@keyframes glowPulse {
  0%,100% { text-shadow: 0 0 8px rgba(255,255,255,0.1); }
  50%      { text-shadow: 0 0 20px rgba(255,255,255,0.35); }
}

/* ── Reset / Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing:border-box; }
html, body, #app { height:100%; margin:0; }

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;

  /* Subtle scanline overlay */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255,255,255,0.012) 2px,
      rgba(255,255,255,0.012) 4px
    );
}

/* Animated scanline sweep — purely decorative */
body::after {
  content:'';
  position:fixed;
  inset:0;
  pointer-events:none;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(255,255,255,0.018) 50%,
    transparent 100%
  );
  height: 120px;
  animation: scanline 8s linear infinite;
  z-index: 9999;
  opacity:.5;
}

#app {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
  animation: fadeIn 400ms var(--ease) both;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 300px;
  min-width: 64px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: width var(--t) var(--ease), padding var(--t) var(--ease);
  animation: slideInLeft 400ms var(--ease) both;
  position: relative;
  overflow: hidden;
}

/* Decorative top-left corner glow */
.sidebar::before {
  content: '';
  position: absolute;
  top: -60px; left: -60px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, var(--red-glow) 0%, transparent 70%);
  pointer-events: none;
  transition: opacity var(--t);
}

.sidebar.collapsed {
  width: 64px;
  padding-left: 10px;
  padding-right: 10px;
}
.sidebar.collapsed .title       { opacity:0; transform:translateX(-8px); pointer-events:none; height:0; overflow:hidden; }
.sidebar.collapsed .tab         { padding:10px 8px; justify-content:center; }
.sidebar.collapsed .tab .label  { display:none; }
.sidebar.collapsed .search input { width:36px; padding-left:8px; }
.sidebar.collapsed .brand       { justify-content:center; }
.sidebar.collapsed .icon-btn    { transform:rotate(180deg); }

/* ── Brand ────────────────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand .logo {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--red);
  display: flex; align-items:center; justify-content:center;
  font-family: var(--display);
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), var(--shadow-sm);
  transition: transform var(--t) var(--ease-back), box-shadow var(--t);
  cursor: default;
}
.brand .logo:hover {
  transform: scale(1.08) rotate(-3deg);
  box-shadow: 0 0 24px var(--red-glow), var(--shadow-md);
}
.brand .title {
  font-family: var(--display);
  font-size: 1.3rem;
  letter-spacing: .06em;
  color: var(--white);
  transition: opacity var(--t), transform var(--t);
  animation: glowPulse 4s ease-in-out infinite;
}

.icon-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  padding: 7px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: transform var(--t) var(--ease-back), color var(--t), border-color var(--t), background var(--t);
  display: flex; align-items:center; justify-content:center;
  font-size: .9rem;
}
.icon-btn:hover {
  transform: scale(1.1);
  color: var(--text);
  border-color: var(--border-hi);
  background: var(--raised);
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 4px;
  border: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 8px 6px;
  border-radius: 7px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: color var(--t), background var(--t), transform var(--t) var(--ease-back), box-shadow var(--t);
  display: flex; align-items:center; gap:6px; justify-content:center;
  white-space: nowrap;
}
.tab .icon  { opacity:.7; font-size:1rem; }
.tab .label { flex:1; text-align:left; }
.tab.active {
  background: var(--raised);
  color: var(--white);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.06);
}
.tab:hover:not(.active) {
  color: var(--silver);
  transform: translateY(-1px);
}
.tab:active { transform: scale(.97); }

/* Active tab has a red underline dot */
.tab.active::after {
  content:'';
  position:absolute;
  bottom: 3px; left:50%;
  transform:translateX(-50%);
  width:16px; height:2px;
  background:var(--red);
  border-radius:2px;
}
.tab { position:relative; }

/* ── Panels ───────────────────────────────────────────────────────────────── */
.tab-panels { flex:1; overflow:auto; padding-top:8px; }
.panel { display:none; padding-bottom:12px; }
.panel.active {
  display:block;
  animation: fadeUp 300ms var(--ease) both;
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */
.search { padding: 4px 0 8px; }
.input,
input[type="text"],
input[type="password"],
input:not([type="submit"]):not([type="button"]),
textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t) var(--ease);
}
.input::placeholder,
input::placeholder,
textarea::placeholder { color: var(--dim); }
.input:focus,
input:focus,
textarea:focus {
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04), 0 4px 20px rgba(0,0,0,0.5);
  transform: translateY(-1px);
}

/* ── Lists ────────────────────────────────────────────────────────────────── */
.list { list-style:none; padding:4px 0; margin:0; display:flex; flex-direction:column; gap:6px; }
.list li {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex; align-items:center; gap:12px;
  cursor: pointer;
  transition: transform var(--t) var(--ease-back), background var(--t), border-color var(--t), box-shadow var(--t);
  animation: liIn 300ms var(--ease) both;
  position: relative;
  overflow: hidden;
}

/* Shimmer hover effect */
.list li::before {
  content:'';
  position:absolute;
  inset:0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.04) 50%,
    transparent 100%
  );
  background-size: 400px 100%;
  opacity:0;
  transition: opacity var(--t);
}
.list li:hover::before { opacity:1; animation: shimmer 600ms linear; }
.list li:hover {
  transform: translateX(4px);
  background: var(--raised);
  border-color: var(--border-hi);
  box-shadow: var(--shadow-sm);
}
.list li:active { transform: scale(.99); }

/* Stagger list item animations */
.list li:nth-child(1)  { animation-delay:  40ms; }
.list li:nth-child(2)  { animation-delay:  80ms; }
.list li:nth-child(3)  { animation-delay: 120ms; }
.list li:nth-child(4)  { animation-delay: 160ms; }
.list li:nth-child(5)  { animation-delay: 200ms; }
.list li:nth-child(6)  { animation-delay: 240ms; }
.list li:nth-child(7)  { animation-delay: 280ms; }
.list li:nth-child(8)  { animation-delay: 320ms; }

/* ── Avatar ───────────────────────────────────────────────────────────────── */
.avatar {
  width: 44px; height: 44px;
  border-radius: 9px;
  background: var(--raised);
  border: 1px solid var(--border-hi);
  display: flex; align-items:center; justify-content:center;
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing:.04em;
  color: var(--silver);
  flex-shrink: 0;
  transition: transform var(--t) var(--ease-back), box-shadow var(--t), border-color var(--t);
}
.list li:hover .avatar {
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 0 14px rgba(255,255,255,0.06);
}
.avatar.small { width:34px; height:34px; border-radius:7px; font-size:.85rem; }

/* ── Meta text ────────────────────────────────────────────────────────────── */
.meta { flex:1; display:flex; flex-direction:column; gap:2px; min-width:0; }
.small  { font-size:.82rem; }
.muted  { color:var(--muted); }
.bold   { font-weight:700; }

/* ── Main area ────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  animation: fadeIn 500ms var(--ease) 100ms both;
}

.topbar {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: relative;
}
/* Red accent line at very top */
.topbar::before {
  content:'';
  position:absolute;
  top:0; left:0; right:0;
  height:1px;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  opacity:.6;
}

#currentChatTitle {
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: .06em;
  color: var(--white);
}
.spacer { flex:1; }

/* ── Chat area ────────────────────────────────────────────────────────────── */
.chat-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse 60% 40% at 80% 20%, rgba(230,57,70,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 40% 50% at 20% 80%, rgba(255,255,255,0.018) 0%, transparent 70%),
    var(--bg);
}

.messages {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.messages.empty {
  align-items: center;
  justify-content: center;
  color: var(--dim);
}
.placeholder {
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .08em;
  color: var(--dim);
  text-align: center;
}
/* Blinking cursor after placeholder text */
.placeholder::after {
  content: '█';
  animation: blink 1.2s step-start infinite;
  margin-left: 2px;
  font-size:.65rem;
  vertical-align: middle;
  color: var(--red);
}

/* ── Messages ─────────────────────────────────────────────────────────────── */
.msg {
  max-width: 68%;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
  transition: transform 140ms var(--ease-back), box-shadow 140ms;
  animation: msgIn-other 280ms var(--ease) both;
}
.msg:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.msg.me {
  margin-left: auto;
  background: var(--raised);
  border-color: rgba(255,255,255,0.1);
  animation: msgIn-me 280ms var(--ease) both;
}
/* Red left bar on own messages */
.msg.me::before {
  content:'';
  position:absolute;
  left:-1px; top:20%; bottom:20%;
  width:2px;
  background:var(--red);
  border-radius:2px;
  opacity:.8;
}
.msg .meta {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--dim);
  margin-bottom: 6px;
  letter-spacing: .04em;
}
.msg.me .meta { color: var(--muted); }
.msg .text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.5;
}

/* ── Composer ─────────────────────────────────────────────────────────────── */
.composer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
}
.composer .input,
.composer input {
  flex: 1;
  padding: 11px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: var(--sans);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t) var(--ease);
}
.composer .input:focus,
.composer input:focus {
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.03);
  transform: translateY(-1px);
}
.send-btn {
  padding: 11px 18px;
  border-radius: var(--radius);
  border: none;
  background: var(--red);
  color: #fff;
  font-family: var(--display);
  font-size: .95rem;
  letter-spacing: .08em;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--red-glow);
  transition: transform var(--t) var(--ease-back), box-shadow var(--t), opacity var(--t);
  white-space: nowrap;
}
.send-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 28px var(--red-glow);
}
.send-btn:active {
  transform: scale(.97);
  opacity: .9;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: transform var(--t) var(--ease-back), background var(--t), border-color var(--t), box-shadow var(--t);
  white-space: nowrap;
}
.btn:hover {
  transform: translateY(-2px);
  border-color: var(--border-hi);
  background: #1a1a1a;
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--red);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px var(--red-glow);
}
.btn.primary:hover {
  background: #f04050;
  box-shadow: 0 6px 24px var(--red-glow);
}
.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn.ghost:hover {
  color: var(--text);
  border-color: var(--border-hi);
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  z-index: 100;
  animation: fadeIn 200ms var(--ease) both;
}
.modal-inner {
  background: var(--surface);
  padding: 32px 28px;
  border-radius: var(--radius-lg);
  width: 400px;
  border: 1px solid var(--border-hi);
  box-shadow: var(--shadow-lg);
  animation: scaleIn 280ms var(--ease-back) both;
  position: relative;
  overflow: hidden;
}
/* Top accent bar */
.modal-inner::before {
  content: '';
  position: absolute;
  top:0; left:0; right:0;
  height: 2px;
  background: var(--red);
}
.modal-inner h2 {
  font-family: var(--display);
  font-size: 1.6rem;
  letter-spacing: .06em;
  margin: 0 0 20px;
  color: var(--white);
}
.modal input {
  width: 100%;
  padding: 11px 13px;
  margin: 7px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: var(--sans);
}
.row { display:flex; gap:10px; }
.error { color: var(--red); font-family: var(--mono); font-size: .8rem; margin-top:8px; }

/* ── Settings panel ───────────────────────────────────────────────────────── */
.settings { display:flex; flex-direction:column; gap:14px; }
.me-card {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeUp 300ms var(--ease) both;
}

/* ── System message actions ───────────────────────────────────────────────── */
.msg .actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}
.msg .actions .btn {
  padding: 6px 12px;
  font-size: .8rem;
  border-radius: 7px;
}

/* ── Scrollbars ───────────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--raised) transparent; }
.messages::-webkit-scrollbar,
.tab-panels::-webkit-scrollbar,
.list::-webkit-scrollbar { width:5px; }
.messages::-webkit-scrollbar-track,
.tab-panels::-webkit-scrollbar-track,
.list::-webkit-scrollbar-track { background:transparent; }
.messages::-webkit-scrollbar-thumb,
.tab-panels::-webkit-scrollbar-thumb,
.list::-webkit-scrollbar-thumb {
  background: var(--raised);
  border-radius: 6px;
}
.messages::-webkit-scrollbar-thumb:hover,
.tab-panels::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ── Send request row ─────────────────────────────────────────────────────── */
.send-request {
  animation: fadeUp 200ms var(--ease) 60ms both;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width:900px) {
  .sidebar {
    position: fixed;
    left:0; top:0; bottom:0;
    z-index: 60;
    width: 280px;
    transform: translateX(0);
  }
  .sidebar.collapsed { transform: translateX(-100%); }
  #app { overflow:hidden; }
  .messages { padding: 16px; }
  .msg { max-width: 88%; }
}

/* ── Accessibility ────────────────────────────────────────────────────────── */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
  border-radius: 6px;
}