:root {
  color-scheme: dark;
  --primary: #0f1218;
  --secondary: #1a2f27;
  --border: #8a8f98;
  --inside: #ffffff;

  --bg: var(--primary);
  --panel: #151a22;
  --surface: #1a2030;
  --surface-hover: #222938;
  --text: #e8ebf0;
  --muted: #8a8f98;
  --muted-dim: rgba(138, 143, 152, 0.55);

  --user: #1e2d3d;
  --user-border: rgba(138, 143, 152, 0.4);
  --model: var(--secondary);
  --model-border: rgba(138, 143, 152, 0.35);

  --accent: #5a9a82;
  --accent-hover: #6bb396;
  --accent-border: #4a8570;
  --accent-text: var(--primary);

  --err: #e07070;
  --err-bg: rgba(224, 112, 112, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);

  font-family: "Segoe UI", system-ui, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.shell {
  display: flex;
  flex-direction: column;
  max-width: 880px;
  height: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  box-sizing: border-box;
}

.head {
  flex-shrink: 0;
  padding-bottom: 0.25rem;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.brand-logo {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  margin-top: 0.1rem;
}

.brand-text {
  min-width: 0;
  width: 100%;
}

.head h1 {
  margin: 0 0 0.2rem;
  font-size: 1.4rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--inside);
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.transcript {
  flex: 1;
  min-height: 0;
  margin: 1rem 0;
  overflow-y: auto;
  padding: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.transcript:empty::before {
  content: "Send a message to start a conversation.";
  display: block;
  margin: auto;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted-dim);
  font-size: 0.9rem;
}

.composer {
  flex-shrink: 0;
  margin-top: auto;
}

.msg {
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
  word-break: break-word;
}

.msg-user {
  align-self: flex-end;
  max-width: 92%;
  background: var(--user);
  border: 1px solid var(--user-border);
}

.msg-model {
  align-self: flex-start;
  max-width: 92%;
  background: var(--model);
  border: 1px solid var(--model-border);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.msg-body {
  line-height: 1.55;
  text-align: start;
}

.thinking-block {
  margin-bottom: 0.5rem;
  border: 1px solid rgba(138, 143, 152, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
}

.thinking-summary {
  cursor: pointer;
  list-style: none;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.thinking-summary::-webkit-details-marker {
  display: none;
}

.thinking-summary::before {
  content: "▸";
  display: inline-block;
  margin-inline-end: 0.35rem;
  transition: transform 0.15s ease;
}

.thinking-block[open] .thinking-summary::before {
  transform: rotate(90deg);
}

.thinking-content {
  padding: 0 0.6rem 0.6rem;
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid rgba(138, 143, 152, 0.25);
}

.answer-content:empty {
  display: none;
}

.msg-body.is-streaming {
  white-space: pre-wrap;
}

.msg-body :first-child {
  margin-top: 0;
}

.msg-body :last-child {
  margin-bottom: 0;
}

.msg-body p {
  margin: 0.4rem 0;
}

.msg-body h1,
.msg-body h2,
.msg-body h3,
.msg-body h4 {
  margin: 0.65rem 0 0.35rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--inside);
}

.msg-body h1 {
  font-size: 1.15rem;
}

.msg-body h2 {
  font-size: 1.05rem;
}

.msg-body h3 {
  font-size: 1rem;
}

.msg-body ul,
.msg-body ol {
  margin: 0.35rem 0;
  padding-inline-start: 1.25rem;
}

.msg-body li {
  margin: 0.2rem 0;
}

.msg-body blockquote {
  margin: 0.4rem 0;
  padding-inline-start: 0.75rem;
  border-inline-start: 3px solid var(--border);
  color: var(--muted);
}

.msg-body pre {
  position: relative;
  overflow-x: auto;
  padding: 0.55rem 0.65rem;
  padding-bottom: 2.25rem;
  margin: 0.45rem 0;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(138, 143, 152, 0.3);
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

.msg-body pre .code-copy-btn {
  position: absolute;
  inset-inline-end: 0.45rem;
  bottom: 0.35rem;
  max-width: calc(100% - 1rem);
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  border-radius: 4px;
  border: 1px solid rgba(138, 143, 152, 0.4);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.msg-body pre .code-copy-btn:hover {
  background: var(--surface-hover);
}

.msg-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.28);
}

.msg-body pre code {
  padding: 0;
  background: transparent;
  font-size: 0.85em;
}

.msg-body table {
  border-collapse: collapse;
  font-size: 0.9em;
  margin: 0.45rem 0;
}

.msg-body th,
.msg-body td {
  border: 1px solid rgba(138, 143, 152, 0.35);
  padding: 0.25rem 0.5rem;
}

.msg-body hr {
  border: none;
  border-top: 1px solid rgba(138, 143, 152, 0.35);
  margin: 0.65rem 0;
}

.msg a,
.msg-body a {
  color: var(--accent-hover);
  text-decoration-color: rgba(107, 179, 150, 0.45);
}

.msg a:hover,
.msg-body a:hover {
  text-decoration-color: var(--accent-hover);
}

.file-links-section {
  margin-top: 0.35rem;
}

.file-links {
  margin: 0.35rem 0 0;
  padding-inline-start: 1.25rem;
}

.file-links li {
  margin: 0.2rem 0;
}

.composer textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  text-align: start;
  font: inherit;
  line-height: 1.45;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer textarea::placeholder {
  color: var(--muted-dim);
}

.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(90, 154, 130, 0.25);
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.55rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-block;
  padding: 0.48rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.file-list {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.doc-citation {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: min(100%, 18rem);
  margin: 0 0.12rem;
  padding: 0.12rem 0.45rem;
  vertical-align: baseline;
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--text);
  background: var(--surface);
  border: 1px solid rgba(138, 143, 152, 0.45);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-citation-icon {
  flex-shrink: 0;
  font-size: 0.72rem;
  opacity: 0.85;
}

.doc-citation-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.typing-indicator {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  min-height: 1.25rem;
  padding: 0.15rem 0;
}

.typing-indicator span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-bounce 0.9s ease-in-out infinite;
}

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

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

@keyframes typing-bounce {
  0%,
  55%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  28% {
    transform: translateY(-0.5rem);
    opacity: 1;
  }
}

.brand-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  width: 100%;
}

.user-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-inline-start: auto;
  font-size: 0.92rem;
  font-weight: 500;
}

.user-fullname {
  color: var(--text);
}

.user-company {
  color: var(--accent);
  background: rgba(90, 154, 130, 0.12);
  border: 1px solid rgba(90, 154, 130, 0.35);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-with-icon svg {
  flex-shrink: 0;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--err);
  cursor: pointer;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.btn-logout:hover {
  color: #f08888;
  background: transparent;
  border: none;
}

.login-page {
  overflow: auto;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand h1 {
  margin: 0.75rem 0 0.35rem;
  font-size: 1.6rem;
  color: var(--inside);
}

.login-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.login-form label {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.login-form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent-border);
}

.login-error {
  margin: 0.5rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--err-bg);
  color: var(--err);
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
  margin-top: 1rem;
  justify-content: center;
}
