:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #e3e8ef;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #dff7f3;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body:has(.app:not(.hidden)) {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 750;
  padding: 0 16px;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 11px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.file-label {
  gap: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

h3 {
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100dvh;
}

.login-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 48px;
  align-items: center;
  min-height: 100vh;
  max-width: 980px;
  margin: 0 auto;
  padding: 32px;
}

.brand-panel {
  display: grid;
  gap: 14px;
}

.login-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
  overflow: hidden;
  padding: 20px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px;
}

.profile p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
}

.admin-stack {
  display: grid;
  gap: 12px;
}

.panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px;
}

.list-panel,
.users-panel {
  min-height: 0;
}

.list-panel {
  flex: 1 1 220px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title span {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.status-line {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  border-radius: 8px;
  padding: 0;
}

.documents {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}

.documents li,
.user-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 10px;
}

.documents li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.empty-item {
  color: var(--muted);
  font-size: 14px;
}

.doc-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 850;
  padding: 4px 8px;
}

.pill.failed {
  background: #fee4e2;
  color: var(--danger);
}

.users-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-row strong,
.user-row span {
  display: block;
  overflow-wrap: anywhere;
}

.user-row strong {
  font-size: 13px;
}

.user-row span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.user-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 750;
}

.ghost-button {
  margin-top: auto;
  background: #eef2f6;
  color: var(--ink);
}

.ghost-button:hover {
  background: #e3e8ef;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
}

.chat-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  padding: 22px 28px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 28px;
}

.message {
  max-width: 820px;
  border-radius: 14px;
  padding: 14px 16px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.message.assistant {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.message.loading {
  min-width: 82px;
}

.typing {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-bounce 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.citations {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.citation {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 16px 28px;
}

.composer textarea {
  min-height: 48px;
  max-height: 160px;
  resize: vertical;
}

@media (max-width: 900px) {
  .login-view {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 22px;
  }

  .app {
    grid-template-columns: 1fr;
    height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 42dvh;
    min-height: 0;
    overflow-y: auto;
  }

  .chat {
    height: 58dvh;
  }

  .composer {
    grid-template-columns: 1fr;
  }
}
