:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --ink: #18201d;
  --muted: #5f6b64;
  --line: #d9d4c7;
  --panel: #ffffff;
  --primary: #0f6b5f;
  --primary-ink: #ffffff;
  --accent: #d9923b;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.hero {
  min-height: 58vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.topbar span,
article span {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 12px 0;
  font-size: clamp(3rem, 7vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lead {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.6;
}

.lead.compact {
  font-size: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 28px;
  border: 1px solid var(--line);
  background: var(--line);
}

article {
  min-height: 112px;
  padding: 20px;
  background: var(--panel);
}

article strong {
  display: block;
  margin-top: 16px;
  font-size: 1.1rem;
}

.embed-section {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 28px;
  align-items: start;
  margin-top: 40px;
  padding: 32px 0 8px;
  border-top: 1px solid var(--line);
}

.embed-section h2 {
  margin: 10px 0 12px;
  font-size: clamp(1.8rem, 3vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.embed-box {
  display: grid;
  gap: 12px;
}

.embed-box textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #111714;
  color: #eaf3ed;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
}

.topbar a {
  font-weight: 800;
  text-decoration: none;
}

.panel {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel h1 {
  margin-top: 0;
  font-size: clamp(2rem, 4vw, 3.75rem);
}

.upload-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  padding: 24px;
  background: #f8fbf8;
  text-align: center;
  cursor: pointer;
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.dropzone span {
  font-weight: 800;
}

.dropzone small {
  margin-top: 8px;
  color: var(--muted);
}

.file-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.file-list div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.result {
  min-height: 72px;
  margin: 24px 0 0;
  padding: 16px;
  overflow: auto;
  border-radius: 8px;
  background: #111714;
  color: #eaf3ed;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
}

.chat-launcher {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #155aaa;
  color: #ffffff;
  box-shadow: 0 14px 32px rgba(21, 90, 170, 0.32);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.chat-launcher:hover {
  background: #0f4f99;
  box-shadow: 0 18px 42px rgba(21, 90, 170, 0.36);
  transform: translateY(-1px);
}

.chat-launcher-icon {
  width: 34px;
  height: 34px;
  display: block;
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 82px;
  width: min(376px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 118px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(16, 31, 27, 0.08);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(24, 32, 29, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transform-origin: right bottom;
  transition: opacity 160ms ease, transform 160ms ease;
}

.chat-widget[data-open="true"] .chat-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 16px 18px;
  background: #155aaa;
  color: #ffffff;
}

.chat-header p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.25;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chat-status span {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: #35d07f;
  box-shadow: 0 0 0 3px rgba(53, 208, 127, 0.18);
}

.chat-header strong {
  display: block;
  font-size: 1.02rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.chat-close {
  width: 34px;
  height: 34px;
  position: relative;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  cursor: pointer;
}

.chat-close span::before,
.chat-close span::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 10px;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.chat-close span::before {
  transform: rotate(45deg);
}

.chat-close span::after {
  transform: rotate(-45deg);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  overflow-y: auto;
  background: #f5f7fa;
}

.chat-message {
  max-width: min(78%, 292px);
  padding: 10px 12px;
  border-radius: 14px;
  color: #17211d;
  font-size: 0.88rem;
  line-height: 1.42;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.chat-message.assistant {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e4e8ee;
  border-bottom-left-radius: 5px;
}

.chat-message.user {
  align-self: flex-end;
  background: #155aaa;
  color: #ffffff;
  border-bottom-right-radius: 5px;
}

.chat-message.is-waiting {
  color: var(--muted);
}

.chat-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e4e8ee;
  color: #5f6b64;
  font-size: 0.78rem;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e4e8ee;
  background: #ffffff;
}

.chat-form label {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.chat-form textarea {
  min-height: 42px;
  max-height: 110px;
  resize: vertical;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.35;
}

.chat-send {
  align-self: end;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: #155aaa;
  color: #ffffff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 1040px);
    padding: 28px 0;
  }

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

  .embed-section {
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 28px;
    padding-top: 24px;
  }

  .panel {
    padding: 20px;
  }

  .chat-widget {
    right: 14px;
    bottom: 14px;
  }

  .chat-launcher {
    width: 58px;
    height: 58px;
  }

  .chat-launcher-icon {
    width: 30px;
    height: 30px;
  }

  .chat-panel {
    right: -2px;
    bottom: 72px;
    height: min(520px, calc(100vh - 96px));
  }

  .chat-messages {
    padding: 14px;
  }

  .chat-message {
    max-width: min(82%, 280px);
    font-size: 0.86rem;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-send {
    justify-self: stretch;
  }
}
