:root {
  --bg: #f7f8fa;
  --ink: #1b1d22;
  --muted: #707684;
  --line: #e5e7eb;
  --blue: #2563eb;
  --green: #0c8c6b;
  --panel: #ffffff;
  --shadow: 0 20px 60px rgba(20, 26, 37, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 clamp(20px, 5vw, 64px);
  color: #1b1d22;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #1b1d22;
}

.nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

.hero {
  min-height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 56px clamp(18px, 5vw, 72px) 72px;
  color: var(--ink);
  background: radial-gradient(circle at 50% 0%, #edf3ff 0, #f7f8fa 40%, #f7f8fa 100%);
}

.hero-copy {
  width: min(100%, 980px);
  text-align: center;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 1.1;
  letter-spacing: 0;
}

.lead {
  max-width: 780px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.chat-shell {
  width: min(100%, 900px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.chat-shell.is-dragover .composer {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), var(--shadow);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 46vh;
  overflow: auto;
  padding: 0 4px;
}

.message-row {
  display: flex;
}

.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }

.bubble {
  min-width: 0;
  max-width: min(760px, 92%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 17px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-row.user .bubble {
  background: #1b1d22;
  color: #fff;
}

.message-row.assistant .bubble {
  background: #fff;
  color: #182230;
  border-color: rgba(219, 227, 239, 0.85);
}

.message-row.assistant .bubble p {
  margin: 0 0 12px;
  white-space: pre-wrap;
}

.message-row.assistant .bubble p:last-child { margin-bottom: 0; }

.message-row.assistant .bubble h3,
.message-row.assistant .bubble h4,
.message-row.assistant .bubble h5,
.message-row.assistant .bubble h6 {
  margin: 18px 0 8px;
  line-height: 1.35;
}

.message-row.assistant .bubble > :first-child { margin-top: 0; }

.message-row.assistant .bubble ul,
.message-row.assistant .bubble ol {
  margin: 8px 0 14px;
  padding-left: 24px;
  white-space: normal;
}

.message-row.assistant .bubble li { margin: 5px 0; }

.message-row.assistant .bubble a {
  color: #1d4ed8;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-row.assistant .bubble code {
  border-radius: 4px;
  background: #f2f4f7;
  padding: 2px 5px;
  font-size: 0.92em;
}

.markdown-table-wrap {
  width: 100%;
  margin: 12px 0 16px;
  overflow-x: auto;
  border: 1px solid #d8dee9;
  border-radius: 6px;
  background: #fff;
  white-space: normal;
}

.markdown-table-wrap table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown-table-wrap th,
.markdown-table-wrap td {
  min-width: 110px;
  padding: 10px 12px;
  border-right: 1px solid #e4e7ec;
  border-bottom: 1px solid #e4e7ec;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.markdown-table-wrap th {
  position: sticky;
  top: 0;
  background: #f2f5f9;
  color: #344054;
  font-weight: 700;
}

.markdown-table-wrap tr:nth-child(even) td { background: #fafbfc; }
.markdown-table-wrap th:last-child,
.markdown-table-wrap td:last-child { border-right: 0; }
.markdown-table-wrap tbody tr:last-child td { border-bottom: 0; }

.message-row.assistant .bubble.is-streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -0.16em;
  background: #2563eb;
  animation: stream-cursor 0.9s steps(1) infinite;
}

@keyframes stream-cursor {
  50% { opacity: 0; }
}

.upload-status {
  align-self: center;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 15px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.upload-status.is-ok {
  border-color: #9edccb;
  background: #effaf5;
}

.upload-status.is-error {
  border-color: #fecaca;
  background: #fff2f2;
  color: #9f1239;
}

.active-file {
  align-self: flex-start;
  border-radius: 999px;
  background: #eaf1ff;
  color: #315caa;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
}

.demo-controls {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.new-session-button {
  min-height: 36px;
  border: 1px solid #d8dde7;
  border-radius: 7px;
  background: #fff;
  color: #344054;
  padding: 7px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.new-session-button:hover,
.new-session-button:focus-visible {
  border-color: #98a2b3;
  background: #f8fafc;
  outline: none;
}

.new-session-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.composer {
  min-height: 66px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: center;
  border: 1px solid #cfd5df;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 14px 38px rgba(20, 26, 37, 0.1);
  padding: 10px 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.upload-hint {
  margin: -2px 0 0;
  color: #667085;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.attach-button,
#sendBtn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.attach-button {
  color: #475569;
  background: transparent;
}

.attach-button:hover,
.attach-button:focus {
  outline: none;
  background: #f2f4f7;
}

#sendBtn {
  background: #1b1d22;
  color: #fff;
  font-weight: 900;
}

#sendBtn.is-stop {
  background: #b42318;
  font-size: 14px;
}

#sendBtn:disabled {
  opacity: 0.6;
  cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
  .message-row.assistant .bubble.is-streaming::after {
    animation: none;
  }
}

textarea {
  width: 100%;
  min-height: 42px;
  max-height: 150px;
  resize: none;
  border: 0;
  outline: none;
  padding: 10px 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
}

textarea::placeholder { color: #9ca3af; }

.prompt-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.prompt-chip {
  border: 1px solid #d8dde7;
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  padding: 10px 16px;
  cursor: pointer;
}

.prompt-chip:hover,
.prompt-chip:focus {
  outline: none;
  border-color: var(--blue);
  color: var(--blue);
}

.sources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.retrieval-summary {
  grid-column: 1 / -1;
  padding: 11px 14px;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  background: #f7f9fc;
  color: #475467;
  font-size: 13px;
  line-height: 1.5;
}

.source-group {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.source-group h3 {
  margin: 0 0 10px;
  color: #344054;
  font-size: 14px;
}

.source-group ol {
  margin: 0;
  padding-left: 20px;
  color: #667085;
  font-size: 13px;
  line-height: 1.65;
}

.source-group li {
  min-width: 0;
  margin: 5px 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.source-group a {
  color: #2563eb;
  text-decoration: underline;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.answer { display: none; }

.section, .workflow {
  padding: 96px 7vw;
}

.section {
  background: #f5f7fb;
}

.section .eyebrow,
.section-head .eyebrow,
.split .eyebrow {
  color: var(--blue);
}

.section-head h2, .workflow h2 {
  margin: 0;
  font-size: clamp(30px, 3.2vw, 48px);
  line-height: 1.16;
}

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

.feature-grid article {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 28px;
}

.feature-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: #fff;
  background: var(--blue);
  font-weight: 900;
}

.feature-grid h3 {
  margin: 20px 0 10px;
  font-size: 21px;
}

.feature-grid p {
  color: var(--muted);
  line-height: 1.72;
}

.workflow {
  margin: 0 7vw;
  border-radius: 28px;
  background: #111827;
  color: #fff;
}

.workflow .eyebrow { color: #6ee7c8; }

.workflow ol {
  list-style: none;
  padding: 0;
  margin: 34px 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.workflow li {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.06);
}

.workflow strong {
  display: block;
  margin-bottom: 12px;
  color: #6ee7c8;
}

.workflow span {
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.55;
}

.demo-promo {
  padding: 96px 7vw;
  background: #f5f7fb;
}

.demo-promo-copy {
  max-width: 760px;
}

.demo-promo .eyebrow {
  color: var(--blue);
}

.demo-promo h2 {
  margin: 0;
  font-size: clamp(30px, 3.2vw, 48px);
  line-height: 1.16;
}

.demo-promo-copy > p:last-child {
  max-width: 680px;
  color: var(--muted);
  line-height: 1.72;
}

.demo-scenarios {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 34px;
}

.demo-scenarios article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
}

.demo-scenarios span {
  color: var(--blue);
  font-weight: 900;
}

.demo-scenarios h3 {
  margin: 20px 0 10px;
  font-size: 21px;
}

.demo-scenarios p {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 32px 7vw;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 14px;
}

@media (max-width: 960px) {
  .topbar { padding: 0 22px; }
  .nav { display: none; }
  .feature-grid, .workflow ol, .demo-scenarios, .sources { grid-template-columns: 1fr; }
  .workflow { margin: 0 20px; }
  .messages { max-height: 36vh; }
}

@media (max-width: 620px) {
  .hero { padding: 42px 16px 64px; }
  .section { padding: 70px 20px; }
  .demo-controls {
    justify-content: flex-end;
  }
  .new-session-button { align-self: flex-end; }
  .composer {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    min-height: 58px;
    border-radius: 26px;
  }
  .attach-button, #sendBtn {
    width: 38px;
    height: 38px;
  }
  .hero-copy h1 { font-size: 34px; }
  footer { flex-direction: column; padding: 28px 20px; }
}
