:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --muted-soft: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff4ff;
  --accent-ink: #1e3a8a;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --success: #067647;
  --success-soft: #ecfdf3;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 12px 32px rgba(16, 24, 40, 0.08);
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
}

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

.container {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
}

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

.muted {
  color: var(--muted);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  box-shadow: 0 4px 10px rgba(29, 78, 216, 0.22);
}

.brand__mark svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.brand__name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__name span {
  color: var(--accent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.btn--secondary:hover {
  border-color: var(--muted-soft);
  background: var(--surface-muted);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn--ghost:hover {
  background: #f2f4f7;
}

.btn--danger {
  color: var(--danger);
}

.btn--danger:hover {
  background: var(--danger-soft);
}

.btn--sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 9px;
}

.btn--sm svg {
  width: 16px;
  height: 16px;
}

.btn--lg {
  min-height: 48px;
  padding: 0 22px;
  font-size: 15px;
  border-radius: 11px;
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
}

.btn.is-loading {
  position: relative;
  color: transparent !important;
  opacity: 1;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn--secondary.is-loading::after,
.btn--ghost.is-loading::after {
  border-color: rgba(16, 24, 40, 0.2);
  border-top-color: var(--ink);
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: #f2f4f7;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.link-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ---------- Alerts and form fields ---------- */
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid transparent;
}

.alert--error {
  background: var(--danger-soft);
  border-color: #fecdca;
  color: var(--danger);
}

.alert--success {
  background: var(--success-soft);
  border-color: #abefc6;
  color: var(--success);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input,
.ask-form input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder,
textarea::placeholder,
.ask-form input::placeholder {
  color: var(--muted-soft);
}

.field input:focus,
.ask-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form .btn--block {
  margin-top: 4px;
}

/* ---------- Landing ---------- */
.landing-page {
  background: var(--surface);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.site-nav__link {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.site-nav__link:hover {
  color: var(--ink);
  text-decoration: none;
}

.hero {
  padding: 82px 0 72px;
  background:
    radial-gradient(circle at 82% 18%, rgba(29, 78, 216, 0.09), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 64px;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.eyebrow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
}

.hero h1 {
  margin-top: 20px;
  max-width: 640px;
  font-size: clamp(38px, 5.2vw, 56px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  font-weight: 750;
}

.hero__lead {
  margin-top: 22px;
  max-width: 590px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.hero__actions {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero__note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.hero__panel {
  display: flex;
  justify-content: center;
}

.preview-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.1);
}

.preview-card__top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.preview-card__mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}

.preview-card__mark svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.preview-card__top strong {
  display: block;
  font-size: 14px;
}

.preview-card__top span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.preview-steps {
  list-style: none;
  margin: 0;
  padding: 18px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.preview-steps li > span {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.preview-steps strong {
  display: block;
  font-size: 13.5px;
}

.preview-steps p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.preview-card__footer {
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.features {
  padding: 76px 0 92px;
  background: var(--surface);
}

.section-heading h2 {
  margin-top: 10px;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.feature-grid {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.feature {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.feature__icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.feature__icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feature h3 {
  margin-top: 18px;
  font-size: 16px;
}

.feature p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 26px 0;
}

.site-footer__inner {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Auth ---------- */
.auth-page {
  background:
    radial-gradient(circle at 20% 0%, rgba(29, 78, 216, 0.08), transparent 30%),
    radial-gradient(circle at 100% 100%, rgba(29, 78, 216, 0.05), transparent 30%),
    var(--bg);
}

.auth-shell {
  min-height: 100dvh;
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.auth-brand {
  margin-bottom: 2px;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.auth-card--center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.auth-card__head {
  margin-bottom: 24px;
}

.auth-card__head h1,
.auth-card--center h1 {
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.auth-card__head p,
.auth-card--center p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.auth-card .alert {
  margin-bottom: 16px;
}

.auth-card .btn--block {
  min-height: 46px;
}

.auth-switch {
  margin-top: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.auth-switch a {
  font-weight: 600;
}

.auth-footer {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.error-code {
  font-size: 44px;
  font-weight: 750;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.04em;
}

/* ---------- Dashboard layout ---------- */
.dashboard-page {
  background: var(--bg);
  overflow: hidden;
}

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

.sidebar {
  min-height: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #fbfbfc;
  border-right: 1px solid var(--line);
  z-index: 40;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}

.sidebar__close {
  display: none;
}

.sidebar__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar__actions .btn {
  justify-content: flex-start;
  padding-left: 13px;
}

.sidebar__history {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar__label {
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.history {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 2px;
}

.history-item {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-item:hover {
  background: #f2f4f7;
}

.history-item.is-active {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.history-item__title {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-soft);
}

.history-item.is-active .history-item__title {
  color: var(--ink);
}

.history-item__meta {
  color: var(--muted-soft);
  font-size: 11px;
}

.history-empty {
  padding: 8px 6px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.sidebar__footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.ai-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-soft);
  flex: 0 0 auto;
}

.ai-status[data-state="online"] {
  color: var(--success);
}

.ai-status[data-state="online"] .ai-status__dot {
  background: #12b76a;
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.14);
}

.ai-status[data-state="warning"] {
  color: var(--warning);
}

.ai-status[data-state="warning"] .ai-status__dot {
  background: #f79009;
  box-shadow: 0 0 0 3px rgba(247, 144, 9, 0.14);
}

.ai-status[data-state="offline"] {
  color: var(--danger);
}

.ai-status[data-state="offline"] .ai-status__dot {
  background: #f04438;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.12);
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 4px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
  text-transform: uppercase;
}

.account__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account__info strong,
.account__info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account__info strong {
  font-size: 13px;
}

.account__info span {
  color: var(--muted);
  font-size: 11.5px;
}

.main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.topbar {
  min-height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.94);
}

.topbar__menu {
  display: none;
}

.topbar__title {
  min-width: 0;
  flex: 1;
}

.topbar__title h1 {
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__title p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__docs {
  margin-left: auto;
  border-color: var(--line);
}

/* ---------- Chat ---------- */
.chat-view {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.messages {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 30px 28px 10px;
  scroll-behavior: smooth;
}

.empty-state {
  height: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

.empty-state__mark {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}

.empty-state__mark svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.empty-state h2 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.empty-state p {
  margin-top: 8px;
  max-width: 420px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.message {
  width: 100%;
  max-width: 820px;
  margin: 0 auto 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message--user {
  align-items: flex-end;
}

.message--assistant {
  align-items: flex-start;
}

.message__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 3px;
  color: var(--muted);
  font-size: 11.5px;
}

.message__meta strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.message__bubble {
  max-width: min(720px, 86%);
  padding: 13px 16px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message--user .message__bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.message--assistant .message__bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow-sm);
}

.message--assistant .message__bubble.is-error {
  background: var(--danger-soft);
  border-color: #fecdca;
  color: var(--danger);
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}

.typing__dots {
  display: inline-flex;
  gap: 4px;
}

.typing__dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-soft);
  animation: typing 1.2s infinite ease-in-out;
}

.typing__dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing__dots i:nth-child(3) {
  animation-delay: 0.3s;
}

.chat-error {
  width: calc(100% - 56px);
  max-width: 820px;
  margin: 0 auto 10px;
}

.composer {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 10px 28px 0;
}

.composer__box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer__box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.composer textarea {
  flex: 1;
  min-height: 28px;
  max-height: 200px;
  padding: 8px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14.5px;
  line-height: 1.55;
  field-sizing: content;
}

.send-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: background-color 0.15s ease;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:disabled {
  background: #d0d5dd;
  color: #fff;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send-btn.is-loading {
  position: relative;
  color: transparent;
}

.send-btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.composer__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 5px 0;
  color: var(--muted-soft);
  font-size: 11.5px;
}

.disclaimer {
  padding: 10px 20px 16px;
  text-align: center;
  color: var(--muted-soft);
  font-size: 11.5px;
}

.sidebar-backdrop {
  display: none;
}

/* ---------- Modal and documents ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.5);
}

.modal__panel {
  position: relative;
  width: min(780px, 100%);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(16, 24, 40, 0.24);
  overflow: hidden;
}

.modal__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal__header h2 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.modal__header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
}

.modal__body {
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 24px;
}

.upload-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-muted);
}

.upload-box__pick {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.upload-box__pick:hover {
  border-color: var(--muted-soft);
}

.upload-box__pick svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-box__name {
  min-width: 0;
  flex: 1;
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-box .alert {
  width: 100%;
}

.docs-heading {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.docs-heading > span {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.docs-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-item {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.doc-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.doc-item__icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.doc-item__info {
  min-width: 0;
  flex: 1;
}

.doc-item__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 600;
}

.doc-item__meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge--success {
  background: var(--success-soft);
  color: var(--success);
}

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-note {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.back-btn {
  margin-bottom: 14px;
}

.doc-detail__head h3 {
  font-size: 17px;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.doc-detail__head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.doc-preview {
  margin: 16px 0 0;
  padding: 14px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.doc-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.doc-actions .muted {
  font-size: 12px;
}

.ai-result {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--accent-soft);
}

.ai-result h4 {
  font-size: 12.5px;
  color: var(--accent-ink);
}

.ai-result__text {
  margin-top: 7px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ask-form {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ask-form label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.ask-form__row {
  display: flex;
  gap: 8px;
}

.ask-form input {
  flex: 1;
  height: 38px;
  font-size: 13px;
}

.ask-form .muted {
  font-size: 11.5px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(440px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.24);
}

.toast--error {
  background: var(--danger);
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: #d0d5dd;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero {
    padding: 60px 0 56px;
  }

  .hero__grid {
    grid-template-columns: 1fr;
    gap: 42px;
  }

  .hero__panel {
    justify-content: flex-start;
  }

  .preview-card {
    max-width: 560px;
  }

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 40px rgba(16, 24, 40, 0.18);
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar__close {
    display: inline-flex;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    background: rgba(16, 24, 40, 0.4);
  }

  .topbar {
    min-height: 64px;
    padding: 0 16px;
  }

  .topbar__menu {
    display: inline-flex;
  }

  .topbar__docs {
    padding: 0 10px;
  }

  .messages {
    padding: 20px 16px 8px;
  }

  .message {
    margin-bottom: 18px;
  }

  .message__bubble {
    max-width: 90%;
  }

  .chat-error {
    width: calc(100% - 32px);
  }

  .composer {
    padding: 8px 16px 0;
  }

  .disclaimer {
    padding: 8px 16px 12px;
  }

  .site-footer__inner {
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 560px) {
  .container {
    width: calc(100% - 36px);
  }

  .site-header__inner {
    height: 64px;
  }

  .site-nav {
    gap: 10px;
  }

  .site-nav__link {
    display: none;
  }

  .hero h1 {
    font-size: 36px;
  }

  .hero__lead {
    font-size: 15.5px;
  }

  .hero__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero__actions .btn {
    width: 100%;
  }

  .features {
    padding: 56px 0 64px;
  }

  .auth-card {
    padding: 24px 20px;
  }

  .auth-shell {
    padding: 24px 16px;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal__panel {
    width: 100%;
    max-height: 94dvh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
  }

  .modal__header {
    padding: 16px 18px;
  }

  .modal__body {
    padding: 16px 18px 22px;
  }

  .upload-box {
    align-items: stretch;
  }

  .upload-box__name {
    flex-basis: 100%;
    order: 3;
  }

  .doc-item {
    align-items: flex-start;
  }

  .doc-item .badge {
    display: none;
  }

  .ask-form__row {
    flex-direction: column;
  }

  .ask-form__row .btn {
    width: 100%;
  }

  .topbar__title p {
    display: none;
  }

  .composer__meta > span:first-child {
    display: none;
  }

  .composer__meta {
    justify-content: flex-end;
  }
}
