:root {

  --bg: #0d0d0d;

  --bg-elevated: #171717;

  --bg-hover: #212121;

  --border: #2a2a2a;

  --text: #ececec;

  --text-muted: #9b9b9b;

  --accent: #10a37f;

  --accent-blue: #3b82f6;

  --accent-green: #22c55e;

  --danger: #ef4444;

  --radius: 12px;

  --sidebar-width: 280px;

  --font: "Segoe UI", system-ui, -apple-system, sans-serif;

}



* { box-sizing: border-box; margin: 0; padding: 0; }



html, body {

  height: 100%;

  overflow: hidden;

}



body {

  font-family: var(--font);

  background: var(--bg);

  color: var(--text);

}



body.guest { overflow: hidden; background: #212121; }



a { color: var(--accent-blue); text-decoration: none; }

a:hover { text-decoration: underline; }



.hidden { display: none !important; }



/* ── App shell (fullscreen) ── */

.app {

  display: flex;

  height: 100vh;

  height: 100dvh;

  overflow: hidden;

}



.sidebar {

  width: var(--sidebar-width);

  background: var(--bg-elevated);

  border-right: 1px solid var(--border);

  display: flex;

  flex-direction: column;

  flex-shrink: 0;

  min-height: 0;

}



.sidebar-toolbar {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-action svg { flex-shrink: 0; opacity: 0.85; }

.sidebar-action:hover {
  background: #2a2a2a;
  border-color: #3a3a3a;
}

.sidebar-action-primary {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(34, 197, 94, 0.22));
  border-color: rgba(34, 197, 94, 0.35);
  color: #fff;
  font-weight: 600;
}

.sidebar-action-primary:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.38), rgba(34, 197, 94, 0.32));
  border-color: rgba(34, 197, 94, 0.5);
}

.btn-sidebar {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));

  color: #fff;

  border: none;

  border-radius: var(--radius);

  padding: 10px 14px;

  font-weight: 600;

  cursor: pointer;

  font: inherit;

  text-align: left;

}



.btn-sidebar-muted {

  background: var(--bg-hover);

  border: 1px solid var(--border);

  color: var(--text-muted);

  font-weight: 500;

}



.btn-sidebar:hover { opacity: 0.92; }



.sidebar-scroll {

  flex: 1;

  overflow-y: auto;

  overflow-x: hidden;

  min-height: 0;

  padding: 8px;

}



.loose-label {

  font-size: 0.7rem;

  text-transform: uppercase;

  letter-spacing: 0.06em;

  color: var(--text-muted);

  padding: 8px 8px 4px;

}



.project-group { margin-bottom: 8px; }



.project-header {

  display: flex;

  align-items: center;

  gap: 4px;

  padding: 4px 6px;

  border-radius: 8px;

}



.project-header:hover { background: var(--bg-hover); }



.project-toggle,

.project-add,

.project-delete {

  background: transparent;

  border: none;

  color: var(--text-muted);

  cursor: pointer;

  padding: 2px 6px;

  font-size: 0.85rem;

  line-height: 1;

  border-radius: 4px;

}



.project-add { color: var(--accent-green); font-weight: 700; font-size: 1rem; }

.project-delete { color: var(--danger); opacity: 0; font-size: 1.1rem; }

.project-header:hover .project-delete { opacity: 1; }

.project-toggle:hover, .project-add:hover, .project-delete:hover { background: var(--bg); }



.project-name {

  flex: 1;

  font-size: 0.82rem;

  font-weight: 600;

  color: var(--text-muted);

  white-space: nowrap;

  overflow: hidden;

  text-overflow: ellipsis;

}



.project-chats {

  padding-left: 4px;

  min-height: 4px;

}

.project-chats .conv-row-nested {

  margin-left: 12px;

  padding-left: 10px;

  border-left: 2px solid rgba(255, 255, 255, 0.08);

}

.loose-chats {

  padding-left: 4px;

  min-height: 4px;

}



.project-chats.drop-target,

.loose-chats.drop-target {

  background: rgba(34, 197, 94, 0.08);

  border-radius: 8px;

  outline: 1px dashed var(--accent-green);

}



.conv-row {

  display: flex;

  align-items: center;

  gap: 2px;

  border-radius: 8px;

}



.conv-row.dragging { opacity: 0.45; }

.conv-row.active { background: var(--bg-hover); }

.conv-row:hover { background: var(--bg-hover); }

.conv-row:hover .conv-delete { opacity: 1; }



.conv-item {

  flex: 1;

  display: block;

  text-align: left;

  background: transparent;

  border: none;

  color: var(--text-muted);

  padding: 8px 10px;

  border-radius: 8px;

  cursor: pointer;

  white-space: nowrap;

  overflow: hidden;

  text-overflow: ellipsis;

  font: inherit;

  font-size: 0.88rem;

}



.conv-row.active .conv-item { color: var(--text); }



.conv-delete {

  background: transparent;

  border: none;

  color: var(--danger);

  cursor: pointer;

  padding: 4px 8px;

  opacity: 0;

  font-size: 1.1rem;

  line-height: 1;

}



.sidebar-footer {

  padding: 12px;

  border-top: 1px solid var(--border);

  flex-shrink: 0;

  display: flex;

  flex-direction: column;

  gap: 8px;

}



.user-panel {

  display: flex;

  align-items: center;

  gap: 10px;

}



.user-meta {

  flex: 1;

  font-size: 0.85rem;

  min-width: 0;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;

}



.user-avatar-btn {

  position: relative;

  width: 34px;

  height: 34px;

  padding: 0;

  border: 1px solid transparent;

  border-radius: 50%;

  background: transparent;

  cursor: pointer;

  flex-shrink: 0;

  overflow: hidden;

  transition: border-color 0.15s, background 0.15s;

}



.user-avatar-btn:hover {

  border-color: var(--border);

  background: var(--bg-hover);

}



.user-avatar-btn .user-avatar {

  width: 100%;

  height: 100%;

  border-radius: 50%;

  display: block;

  object-fit: cover;

  transition: opacity 0.15s;

}



.user-logout-icon {

  position: absolute;

  inset: 0;

  display: flex;

  align-items: center;

  justify-content: center;

  opacity: 0;

  transition: opacity 0.15s;

  color: var(--text-muted);

  background: var(--bg-hover);

  border-radius: 50%;

}



.user-avatar-btn:hover .user-avatar {

  opacity: 0;

}



.user-avatar-btn:hover .user-logout-icon {

  opacity: 1;

  color: var(--danger);

}



.sidebar-footer-action {

  display: flex;

  align-items: center;

  justify-content: center;

  gap: 8px;

  width: 100%;

  padding: 11px 14px;

  border-radius: var(--radius);

  border: 1px solid var(--border);

  background: var(--bg-hover);

  color: var(--text);

  font-size: 0.88rem;

  font-weight: 600;

  font-family: inherit;

  text-decoration: none;

  cursor: pointer;

  transition: border-color 0.15s, background 0.15s;

}



.sidebar-footer-action:hover {

  text-decoration: none;

  border-color: var(--accent-green);

  background: #252525;

}



.btn-admin {

  display: flex;

  align-items: center;

  justify-content: center;

  gap: 8px;

  padding: 10px 14px;

  background: linear-gradient(135deg, #1e3a5f, #14532d);

  border: 1px solid var(--border);

  border-radius: var(--radius);

  color: var(--text);

  font-weight: 600;

  font-size: 0.85rem;

  text-decoration: none;

  transition: opacity 0.15s;

}



.btn-admin:hover {

  opacity: 0.9;

  text-decoration: none;

  border-color: var(--accent-green);

}



.btn-icon {

  background: transparent;

  border: 1px solid var(--border);

  color: var(--text);

  border-radius: var(--radius);

  padding: 6px 10px;

  cursor: pointer;

  font: inherit;

}



.main {

  flex: 1;

  display: flex;

  flex-direction: column;

  min-width: 0;

  min-height: 0;

  overflow: hidden;

}



.topbar {

  display: flex;

  align-items: center;

  gap: 12px;

  padding: 10px 20px;

  border-bottom: 1px solid var(--border);

  flex-shrink: 0;

}



.logo {

  height: 32px;

  width: auto;

  max-width: 220px;

  object-fit: contain;

}



.main-body {

  flex: 1;

  min-height: 0;

  overflow: hidden;

  display: flex;

  flex-direction: column;

}



.welcome {

  flex: 1;

  display: flex;

  flex-direction: column;

  align-items: center;

  justify-content: center;

  text-align: center;

  padding: 40px 20px;

  gap: 16px;

  overflow-y: auto;

}



.welcome-logo {

  height: 48px;

  width: auto;

  max-width: 280px;

  object-fit: contain;

}



.welcome h1 {

  font-size: 1.75rem;

  background: linear-gradient(90deg, #fff, var(--accent-green));

  -webkit-background-clip: text;

  -webkit-text-fill-color: transparent;

}



.welcome p { color: var(--text-muted); max-width: 520px; }



.suggestions {

  display: flex;

  flex-wrap: wrap;

  gap: 10px;

  justify-content: center;

  margin-top: 8px;

}



.suggestion {

  background: var(--bg-elevated);

  border: 1px solid var(--border);

  color: var(--text);

  padding: 10px 16px;

  border-radius: 20px;

  cursor: pointer;

  font: inherit;

}



.suggestion:hover { border-color: var(--accent-green); }



.messages {

  flex: 1;

  overflow-y: auto;

  overflow-x: hidden;

  padding: 24px 0 16px;

  min-height: 0;

}



.message {

  max-width: 800px;

  margin: 0 auto 24px;

  padding: 0 20px;

  display: flex;

  gap: 14px;

}



.message-avatar {

  width: 32px;

  height: 32px;

  border-radius: 6px;

  flex-shrink: 0;

}



.message-body { flex: 1; min-width: 0; }



.message-role {

  font-size: 0.8rem;

  color: var(--text-muted);

  margin-bottom: 6px;

}



.message-content {

  line-height: 1.65;

  word-break: break-word;

}



.message-sources {

  display: flex;

  flex-wrap: wrap;

  gap: 8px;

  margin-top: 12px;

}



.source-chip {

  display: inline-flex;

  align-items: center;

  gap: 6px;

  background: var(--bg-elevated);

  border: 1px solid var(--border);

  border-radius: 20px;

  padding: 4px 10px 4px 6px;

  font-size: 0.78rem;

  color: var(--text-muted);

  text-decoration: none;

}



.source-chip:hover {

  border-color: var(--accent-blue);

  color: var(--text);

  text-decoration: none;

}



.source-chip img { width: 16px; height: 16px; border-radius: 3px; }

.message-images {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
}

.message-image {
  margin: 0;
  max-width: 100%;
  width: fit-content;
}

.message-image-link {
  display: inline-block;
  line-height: 0;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.message-image-img {
  display: block;
  width: auto;
  max-width: min(100%, 480px);
  height: auto;
  max-height: 360px;
  object-fit: contain;
  border-radius: 6px;
}

.message-image-caption {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}



/* ── Chat HTML formatting ── */

.chat-formatted .chat-p { margin: 0 0 0.75em; }

.chat-formatted .chat-p:last-child { margin-bottom: 0; }

.chat-formatted .chat-h { margin: 1em 0 0.5em; font-size: 1.05em; font-weight: 600; color: var(--text); }

.chat-formatted h3.chat-h { font-size: 1em; }

.chat-formatted h4.chat-h, .chat-formatted h5.chat-h { font-size: 0.95em; }

.chat-formatted .chat-list { margin: 0.5em 0 0.75em 1.25em; }

.chat-formatted .chat-list-ol { list-style: decimal; }

.chat-formatted .chat-quote {

  margin: 0.75em 0;

  padding: 8px 14px;

  border-left: 3px solid var(--accent-green);

  color: var(--text-muted);

  background: var(--bg-elevated);

  border-radius: 0 8px 8px 0;

}

.chat-formatted .chat-hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }

.chat-formatted .chat-link { color: var(--accent-blue); word-break: break-all; }

.chat-formatted .chat-code-inline {

  background: var(--bg-elevated);

  padding: 2px 6px;

  border-radius: 4px;

  font-size: 0.9em;

  font-family: Consolas, monospace;

}

.chat-formatted .chat-code-block {

  background: var(--bg-elevated);

  border: 1px solid var(--border);

  border-radius: 8px;

  padding: 12px 14px;

  margin: 0.75em 0;

  overflow-x: auto;

  position: relative;

}

.chat-formatted .chat-code-lang {

  display: block;

  font-size: 0.7rem;

  color: var(--text-muted);

  margin-bottom: 6px;

  text-transform: uppercase;

}

.chat-formatted .chat-code-block code {

  font-family: Consolas, monospace;

  font-size: 0.88em;

  white-space: pre-wrap;

}

.chat-formatted .chat-table-wrap { overflow-x: auto; margin: 0.75em 0; }

.chat-formatted .chat-table {

  width: 100%;

  border-collapse: collapse;

  font-size: 0.9em;

}

.chat-formatted .chat-table th,

.chat-formatted .chat-table td {

  border: 1px solid var(--border);

  padding: 8px 10px;

  text-align: left;

}

.chat-status {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  padding: 2px 0 6px;
}

.chat-formatted .chat-table th { background: var(--bg-elevated); }



.composer {

  flex-shrink: 0;

  background: var(--bg);

  border-top: 1px solid var(--border);

  padding: 12px 20px 16px;

}



.composer-inner {

  max-width: 800px;

  margin: 0 auto;

  display: flex;

  align-items: flex-end;

  gap: 8px;

  background: var(--bg-elevated);

  border: 1px solid var(--border);

  border-radius: 24px;

  padding: 8px 12px;

}



.composer-inner:focus-within { border-color: var(--accent-green); }



#input {

  flex: 1;

  background: transparent;

  border: none;

  color: var(--text);

  resize: none;

  max-height: 200px;

  font: inherit;

  line-height: 1.5;

  padding: 6px 4px;

}



#input:focus { outline: none; }



.btn-send {

  background: var(--accent-green);

  border: none;

  color: #fff;

  width: 36px;

  height: 36px;

  border-radius: 50%;

  cursor: pointer;

  display: flex;

  align-items: center;

  justify-content: center;

  flex-shrink: 0;

}



.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }



.mobile-only { display: none; }



@media (max-width: 768px) {

  .sidebar {

    position: fixed;

    left: 0;

    top: 0;

    bottom: 0;

    z-index: 100;

    transform: translateX(-100%);

    transition: transform 0.2s;

  }

  .sidebar.open { transform: translateX(0); }

  .mobile-only { display: inline-flex; }

}



/* ── Landing ── */

.landing {

  position: fixed;

  inset: 0;

  z-index: 200;

  display: flex;

  flex-direction: column;

  align-items: center;

  justify-content: center;

  background: #212121;

  overflow: hidden;

}



.landing-inner {

  flex: 1;

  display: flex;

  flex-direction: column;

  align-items: center;

  justify-content: center;

  text-align: center;

  padding: 48px 24px 80px;

  max-width: 680px;

  width: 100%;

  overflow-y: auto;

}



.reveal {

  opacity: 0;

  transform: translateY(20px);

  animation: revealIn 0.75s cubic-bezier(0.22, 1, 0.36, 1) forwards;

  animation-delay: var(--d, 0s);

}



@keyframes revealIn {

  to { opacity: 1; transform: translateY(0); }

}



.landing-logo-wrap { margin-bottom: 40px; line-height: 0; }



.landing-logo {

  display: block;

  width: min(520px, 92vw);

  height: auto;

  max-height: 110px;

  object-fit: contain;

}



.landing-headline {

  font-size: clamp(1.75rem, 4.5vw, 2.25rem);

  font-weight: 600;

  letter-spacing: -0.025em;

  color: #ececec;

  line-height: 1.25;

  margin-bottom: 16px;

}



.landing-lead {

  font-size: 1rem;

  line-height: 1.65;

  color: #8e8ea0;

  margin-bottom: 32px;

  max-width: 480px;

}



.landing-free { color: #ececec; font-weight: 500; }



.landing-steam-btn {

  display: inline-flex;

  align-items: center;

  justify-content: center;

  gap: 10px;

  min-width: 240px;

  padding: 14px 28px;

  font-size: 0.95rem;

  font-weight: 600;

  font-family: inherit;

  color: #fff;

  background: #171a21;

  border: 1px solid #2a475e;

  border-radius: 999px;

  cursor: pointer;

  transition: background 0.2s, border-color 0.2s, transform 0.15s;

}



.landing-steam-btn:hover {

  background: #1b2838;

  border-color: #66c0f4;

  transform: scale(1.02);

}



.steam-btn-icon { display: block; width: 22px; height: 22px; flex-shrink: 0; }

.landing-steam-btn:active { transform: scale(0.98); }



.landing-hint {

  margin-top: 20px;

  font-size: 0.8rem;

  color: #6b6b7b;

}



.landing-footer {

  position: absolute;

  bottom: 0;

  left: 0;

  right: 0;

  height: 48px;

  display: flex;

  align-items: center;

  justify-content: center;

  gap: 10px;

  font-size: 0.75rem;

  color: #6b6b7b;

}



.landing-footer a { color: #6b6b7b; text-decoration: none; }

.landing-footer a:hover { color: #ececec; }



.legal-page .legal-content {

  max-width: 720px;

  margin: 60px auto;

  padding: 0 20px;

}



.legal-content h1 { margin: 20px 0; }

.back-link { color: var(--text-muted); font-size: 0.9rem; }



@media (max-width: 520px) {

  .landing-logo { max-height: 80px; width: min(340px, 94vw); }

  .landing-headline { font-size: 1.5rem; }

}



@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none !important; opacity: 1; transform: none; }
}

/* ── Shared UI modal ── */
#ui-modal-root .ui-modal,
.ui-modal:not(.hidden) {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ui-modal.hidden { display: none !important; }

.ui-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.ui-modal-box {
  position: relative;
  width: min(440px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ui-modal-box-wide { width: min(720px, 100%); max-height: 85vh; }

.ui-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.ui-modal-title { font-size: 1rem; font-weight: 600; }

.ui-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.ui-modal-close:hover { background: var(--bg-hover); color: var(--text); }

.ui-modal-body {
  padding: 20px;
  overflow-y: auto;
}

.ui-modal-text { line-height: 1.6; color: var(--text-muted); }

.ui-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.ui-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.ui-btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.ui-btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.ui-btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
  color: #fff;
}

.ui-btn-primary:hover { opacity: 0.92; }

.ui-btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.ui-field { display: flex; flex-direction: column; gap: 8px; }

.ui-label { font-size: 0.85rem; color: var(--text-muted); }

.ui-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.ui-input:focus {
  outline: none;
  border-color: var(--accent-green);
}
