:root {
  --bg: #f7f8fb;
  --card: #ffffff;
  --ink: #0e1b3d;
  --muted: #68738a;
  --border: #e4e8f0;
  --soft: #edf4ff;
  --primary: #155eef;
  --danger: #b42318;
  --success: #067647;
  --warning: #b54708;
  --shadow: 0 18px 50px rgb(15 23 42 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell { display: flex; height: 100vh; min-height: 680px; }
.sidebar { display: flex; width: 304px; flex: 0 0 304px; flex-direction: column; border-right: 1px solid var(--border); background: var(--card); }
.brand { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding: 18px; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; }
.brand-title { font-weight: 750; }
.brand-title span { color: var(--primary); }
.sidebar-actions { padding: 14px; }
.primary-btn, .secondary-btn, .ghost-btn { border-radius: 12px; border: 0; }
.primary-btn { width: 100%; background: var(--ink); color: #fff; padding: 11px 14px; font-size: 14px; font-weight: 650; box-shadow: 0 8px 20px rgb(14 27 61 / 15%); }
.secondary-btn { border: 1px solid var(--border); background: var(--card); color: var(--ink); padding: 10px 13px; font-size: 13px; font-weight: 650; }
.ghost-btn { background: transparent; color: var(--muted); padding: 8px 10px; font-size: 12px; font-weight: 650; }
.ghost-btn:hover { background: var(--bg); color: var(--ink); }
.session-list { flex: 1; overflow-y: auto; padding: 8px; }
.eyebrow { margin: 4px 8px 8px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.session-card { width: 100%; border: 0; border-radius: 12px; background: transparent; color: var(--ink); padding: 10px; text-align: left; }
.session-card:hover, .session-card.active { background: var(--soft); }
.session-title { overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.session-meta { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.session-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; background: #eef2f6; color: #475467; padding: 3px 8px; font-size: 10px; font-weight: 750; text-transform: capitalize; }
.badge.complete, .badge.low { background: #ecfdf3; color: var(--success); }
.badge.investigating, .badge.medium { background: #eff8ff; color: var(--primary); }
.badge.failed, .badge.high, .badge.critical { background: #fef3f2; color: var(--danger); }
.badge.needs_info, .badge.draft { background: #fffaeb; color: var(--warning); }
.sidebar-footer { border-top: 1px solid var(--border); padding: 13px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.main { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); background: rgb(255 255 255 / 88%); padding: 16px 24px; backdrop-filter: blur(10px); }
.topbar-label { color: var(--muted); font-size: 12px; }
.topbar-title { margin-top: 3px; font-size: 15px; font-weight: 760; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.chat-scroll { flex: 1; overflow-y: auto; }
.chat-inner { margin: 0 auto; max-width: 880px; padding: 32px 24px; }
.empty { margin: 28px auto; max-width: 760px; text-align: center; }
.empty h1 { margin: 14px 0 8px; font-size: clamp(30px, 5vw, 52px); letter-spacing: -0.04em; }
.empty p { margin: 0 auto; max-width: 580px; color: var(--muted); line-height: 1.6; }
.prompt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 28px; }
.prompt-card { border: 1px solid var(--border); border-radius: 18px; background: var(--card); padding: 16px; text-align: left; box-shadow: var(--shadow); }
.prompt-card strong { display: block; margin-bottom: 6px; }
.prompt-card span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.messages { display: flex; flex-direction: column; gap: 24px; }
.message { display: flex; gap: 12px; }
.message.user { justify-content: flex-end; }
.bubble { max-width: min(760px, 82%); border-radius: 20px; padding: 13px 16px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.message.user .bubble { border-bottom-right-radius: 6px; background: var(--ink); color: #fff; }
.message.assistant .bubble { border: 1px solid var(--border); border-top-left-radius: 6px; background: var(--card); box-shadow: var(--shadow); }
.avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 999px; background: var(--soft); color: var(--primary); font-size: 11px; font-weight: 850; }
.markdown-body { white-space: normal; }
.markdown-body p { margin: 0 0 12px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h3, .markdown-body h4, .markdown-body h5 { margin: 18px 0 8px; line-height: 1.25; }
.markdown-body h3:first-child, .markdown-body h4:first-child, .markdown-body h5:first-child { margin-top: 0; }
.markdown-body h3 { font-size: 18px; }
.markdown-body h4 { font-size: 15px; }
.markdown-body h5 { font-size: 14px; color: var(--muted); }
.markdown-body ul, .markdown-body ol { margin: 8px 0 14px; padding-left: 22px; }
.markdown-body li { margin: 5px 0; }
.markdown-body code { border: 1px solid var(--border); border-radius: 7px; background: #f6f8fb; padding: 1px 5px; font-size: 0.92em; }
.markdown-body pre { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: #0e1b3d; color: #eef4ff; padding: 14px; }
.markdown-body pre code { border: 0; background: transparent; color: inherit; padding: 0; }
.md-table-wrap { overflow-x: auto; margin: 12px 0 16px; border: 1px solid var(--border); border-radius: 14px; }
.markdown-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.markdown-body th, .markdown-body td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; vertical-align: top; }
.markdown-body th { background: #f8fafc; font-weight: 750; }
.markdown-body tr:last-child td { border-bottom: 0; }
.typing-cursor { display: inline-block; width: 7px; height: 1.1em; margin-left: 2px; background: var(--primary); vertical-align: -2px; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.composer-wrap { border-top: 1px solid var(--border); background: var(--card); }
.composer { display: flex; max-width: 880px; align-items: flex-end; gap: 9px; margin: 0 auto; padding: 16px 24px; }
.composer-box { display: flex; flex: 1; align-items: flex-end; gap: 8px; border: 1px solid var(--border); border-radius: 20px; background: #fff; padding: 8px; box-shadow: 0 8px 24px rgb(15 23 42 / 6%); }
.composer-box-stacked { display: block; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { min-height: 42px; max-height: 160px; flex: 1; resize: none; border: 0; outline: 0; padding: 10px 12px; }
.attachment-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 4px 8px; }
.attachment-preview { position: relative; width: 86px; height: 62px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; }
.attachment-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attachment-preview button { position: absolute; top: 4px; right: 4px; display: grid; width: 20px; height: 20px; place-items: center; border: 0; border-radius: 999px; background: rgb(14 27 61 / 85%); color: #fff; font-size: 14px; line-height: 1; }
.send-btn { display: grid; width: 42px; height: 42px; place-items: center; border: 0; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 900; }
.send-btn:disabled { cursor: default; opacity: 0.4; }
.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; background: rgb(14 27 61 / 45%); padding: 20px; }
.modal { width: min(760px, 100%); max-height: 88vh; overflow-y: auto; border-radius: 24px; background: var(--card); padding: 24px; box-shadow: 0 30px 90px rgb(14 27 61 / 24%); }
.modal h2 { margin: 0 0 6px; }
.modal p { margin: 0 0 20px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; outline: 0; background: #fff; }
.field textarea { min-height: 90px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.login { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); border: 1px solid var(--border); border-radius: 28px; background: var(--card); padding: 34px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin-bottom: 8px; }
.error { margin: 12px auto; max-width: 880px; border: 1px solid #fecdca; border-radius: 14px; background: #fef3f2; color: var(--danger); padding: 12px 14px; font-size: 13px; }

@media (max-width: 860px) {
  .shell { min-height: 100vh; }
  .sidebar { display: none; }
  .prompt-grid, .form-grid { grid-template-columns: 1fr; }
  .topbar, .composer, .chat-inner { padding-left: 16px; padding-right: 16px; }
}
