/* ── Mortis Web Chat — Claude-like ──────────────────────────────────────── */

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

:root {
  --base: #080808;
  --raise: #0D0D0D;
  --surface: #121212;
  --border: #1C0000;
  --border-md: #380000;
  --red: #CC3333;
  --red-dk: #8B0000;
  --red-hi: #E83333;
  --text: #D4C4A8;
  --dim: #7A6A54;
  --faint: #3D2D1A;
  --gold: #9B7A1A;
}

html, body {
  height: 100%; overflow: hidden;
  background: var(--base); color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 14px;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: var(--base); }
::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--red); }
::selection { background: rgba(204,51,51,0.35); }

/* ── Layout ────────────────────────────────────────────────────────────── */
#app {
  display: flex; height: 100%;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
#sidebar {
  width: 260px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--raise);
  border-right: 1px solid var(--border);
}
.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.btn-new {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 14px;
  background: var(--base); border: 1px solid var(--border-md);
  border-radius: 8px; color: var(--text);
  font-size: 0.85rem; cursor: pointer;
  transition: all 0.15s;
}
.btn-new:hover {
  border-color: var(--red); color: var(--red);
}

.chat-list {
  flex: 1; overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.chat-item {
  padding: 10px 12px;
  border-radius: 6px; cursor: pointer;
  font-size: 0.8rem; color: var(--dim);
  transition: all 0.12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item:hover { background: var(--surface); color: var(--text); }
.chat-item.active { background: var(--border); color: var(--text); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.status-row {
  display: flex; align-items: center; gap: 6px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online { background: #5a5; box-shadow: 0 0 4px #5a5; }
.status-dot.offline { background: var(--dim); }
.status-label {
  font-size: 0.7rem; color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Main area ─────────────────────────────────────────────────────────── */
#main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0;
}

/* ── Welcome ───────────────────────────────────────────────────────────── */
#welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 16px;
  padding: 40px;
}
.welcome-icon {
  font-family: Georgia, serif; font-size: 5rem; font-weight: bold;
  color: var(--border-md);
  text-shadow: 0 0 40px rgba(204,51,51,0.15);
  user-select: none;
  line-height: 1;
}
.welcome-title {
  font-family: 'Cinzel', serif; font-size: 1.4rem;
  letter-spacing: 0.25em; color: var(--red);
  text-shadow: 0 0 20px rgba(204,51,51,0.3);
}
.welcome-sub {
  font-size: 0.85rem; color: var(--dim); line-height: 1.7;
  max-width: 400px;
}
.welcome-hints {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 8px;
}
.hint-btn {
  padding: 8px 16px;
  background: var(--raise); border: 1px solid var(--border-md);
  border-radius: 20px; color: var(--dim);
  font-size: 0.78rem; cursor: pointer;
  transition: all 0.15s;
}
.hint-btn:hover {
  border-color: var(--red); color: var(--red);
  background: var(--base);
}

/* ── Messages ──────────────────────────────────────────────────────────── */
#messages {
  flex: 1; overflow-y: auto;
  padding: 24px 0;
  display: none; flex-direction: column; gap: 0;
}
#messages.active { display: flex; }

.msg {
  padding: 20px 0;
  animation: slide-in 0.18s ease-out;
}
.msg-inner {
  max-width: 720px; margin: 0 auto;
  padding: 0 24px;
}

.msg-user {
  background: transparent;
}
.msg-user .msg-inner {
  display: flex; justify-content: flex-end;
}
.msg-user .bubble {
  max-width: 80%; padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  background: var(--border); border: 1px solid var(--border-md);
  font-size: 0.88rem; line-height: 1.65;
  white-space: pre-wrap; word-wrap: break-word;
}

.msg-assistant {
  background: var(--raise);
  border-top: 1px solid rgba(28,0,0,0.5);
  border-bottom: 1px solid rgba(28,0,0,0.5);
}
.msg-assistant .msg-inner {
  display: flex; flex-direction: column; gap: 6px;
}
.msg-assistant .label {
  display: flex; align-items: center; gap: 6px;
}
.msg-assistant .label .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 6px var(--red);
}
.msg-assistant .label span {
  font-family: 'Cinzel', serif; font-size: 0.65rem;
  letter-spacing: 0.12em; color: var(--red);
}
.msg-assistant .content {
  font-size: 0.88rem; line-height: 1.75;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg-assistant .content.streaming::after {
  content: '▋'; color: var(--red);
  animation: blink 1s step-start infinite;
}

/* Typing indicator */
.typing-indicator {
  padding: 20px 0;
  background: var(--raise);
  border-top: 1px solid rgba(28,0,0,0.5);
}
.typing-inner {
  max-width: 720px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 8px;
}
.typing-dots {
  display: flex; gap: 4px;
}
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--red); opacity: 0.4;
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Markdown in messages */
.content strong { color: var(--red-hi); }
.content em { color: var(--dim); font-style: italic; }
.content code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.82rem;
  background: var(--base); padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border);
}
.content pre {
  background: var(--base); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; margin: 10px 0;
  overflow-x: auto; position: relative;
}
.content pre code {
  background: none; border: none; padding: 0;
  font-size: 0.8rem; line-height: 1.55;
}
.content ul, .content ol { padding-left: 20px; margin: 6px 0; }
.content li { margin: 3px 0; }
.content h3, .content h4 {
  color: var(--gold); font-size: 0.9rem; margin: 12px 0 6px;
}

/* Error state */
.content.error {
  color: #a66; font-style: italic;
}

/* ── Input bar ─────────────────────────────────────────────────────────── */
#input-bar {
  padding: 16px 24px 20px;
  flex-shrink: 0;
  max-width: 720px; width: 100%;
  margin: 0 auto;
}
.input-wrap {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--raise); border: 1px solid var(--border-md);
  border-radius: 16px; padding: 12px 16px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: var(--red-dk); }
#input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: 'Inter', sans-serif;
  font-size: 0.9rem; resize: none; line-height: 1.55;
  max-height: 150px;
}
#input::placeholder { color: var(--faint); }
#btn-send {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 10px; cursor: pointer;
  background: var(--border); color: var(--dim);
  transition: all 0.15s;
}
#btn-send:not(:disabled) {
  background: var(--red-dk); color: var(--red-hi);
  box-shadow: 0 0 10px rgba(204,51,51,0.3);
}
#btn-send:disabled { cursor: default; }
.hint {
  text-align: center; font-size: 0.65rem;
  color: var(--faint); margin-top: 8px;
}

/* ── Animations ────────────────────────────────────────────────────────── */
@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
@keyframes slide-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes typing-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: scale(1); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { display: none; }
  #app { flex-direction: column; }
  .msg-inner { padding: 0 16px; }
  #input-bar { padding: 12px 16px 16px; }
  .msg-user .bubble { max-width: 90%; }
  .welcome-hints { flex-direction: column; align-items: center; }
}
