:root {
  --bg: #f3efe5;
  --paper: #fffaf0;
  --ink: #18230f;
  --muted: #55624c;
  --line: #c8c1ad;
  --accent: #d95d39;
  --accent-dark: #8f2d14;
  --sidebar: #e6ddca;
  --success: #275d38;
  --shadow: 0 18px 60px rgba(24, 35, 15, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(217, 93, 57, 0.16), transparent 32%),
    linear-gradient(180deg, #f8f4eb 0%, var(--bg) 100%);
  color: var(--ink);
}

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

code,
pre,
textarea,
select {
  font-family: "IBM Plex Mono", monospace;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248, 244, 235, 0.9);
  backdrop-filter: blur(10px);
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.menu-wrap {
  position: relative;
  z-index: 60;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.nav-button {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.9);
}

.menu-toggle,
.cta,
.chat-list-item,
.text-link {
  cursor: pointer;
}

.menu-toggle,
select,
textarea,
.chat-list-item,
.cta {
  border: 1px solid var(--line);
  border-radius: 14px;
}

.menu-toggle {
  background: var(--paper);
  padding: 0.6rem 0.9rem;
}

.user-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  display: grid;
  gap: 0.25rem;
  min-width: 200px;
  padding: 0.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 80;
}

.user-menu a {
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
}

.user-menu a:hover {
  background: rgba(24, 35, 15, 0.06);
}

.hidden {
  display: none !important;
}

.hero {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 2rem;
  padding: 3rem 1.5rem 4rem;
  max-width: 1200px;
  margin: 0 auto;
}

.eyebrow {
  color: var(--accent-dark);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero h1 {
  font-size: clamp(2.8rem, 6vw, 5.5rem);
  line-height: 0.95;
  margin: 0 0 1rem;
  max-width: 10ch;
}

.hero-text {
  max-width: 55ch;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-actions {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
}

.cta {
  width: fit-content;
  padding: 0.9rem 1.2rem;
  background: var(--accent);
  color: white;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.cta.secondary {
  background: var(--paper);
  color: var(--ink);
  box-shadow: none;
}

.model-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.model-preview code {
  padding: 0.2rem 0.5rem;
  background: rgba(24, 35, 15, 0.06);
  border-radius: 999px;
}

.hero-card,
.simple-page,
.pricing-card,
.pricing-panel,
.chat-main,
.chat-sidebar {
  background: rgba(255, 250, 240, 0.82);
  border: 1px solid rgba(200, 193, 173, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.hero-card {
  border-radius: 28px;
  padding: 2rem;
  display: grid;
  gap: 1rem;
  align-self: center;
}

.pricing-page {
  min-height: 100vh;
  max-width: none;
  margin: 0;
  padding: 4rem 1.5rem;
  display: grid;
  align-items: center;
  background:
    radial-gradient(circle at top left, rgba(217, 93, 57, 0.16), transparent 30%),
    linear-gradient(180deg, #f4ede2 0%, #ebe1d0 100%);
  color: var(--ink);
}

.pricing-intro {
  max-width: 560px;
}

.pricing-intro h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.8rem, 6vw, 4.8rem);
  line-height: 0.95;
  max-width: 11ch;
}

.pricing-kicker {
  margin: 0 0 0.8rem;
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pricing-lead,
.pricing-support {
  margin: 0;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.6;
  max-width: 52ch;
}

.pricing-support {
  margin-top: 1rem;
}

.pricing-layout {
  width: min(100%, 1100px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 460px);
  gap: 2rem;
  align-items: center;
}

.pricing-card,
.pricing-panel {
  border-radius: 28px;
  padding: 2rem;
}

.pricing-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  background: rgba(255, 250, 240, 0.84);
  border: 1px solid rgba(200, 193, 173, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.pricing-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 8px;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
}

.plan-price {
  margin: 0 0 0.65rem;
  font-size: clamp(2.7rem, 5vw, 4.1rem);
  line-height: 0.92;
  font-weight: 700;
}

.plan-price span {
  margin-left: 0.35rem;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 500;
}

.pricing-card h2 {
  margin: 0 0 1.1rem;
  font-size: 1.3rem;
}

.plan-features {
  display: grid;
  gap: 0.7rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.plan-features li {
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  font-size: 1.02rem;
}

.plan-actions {
  margin: 1.2rem 0 0;
}

.plan-actions form {
  margin: 0;
}

.pricing-cta {
  width: 100%;
  justify-content: center;
  text-align: center;
  background: var(--accent);
  color: white;
}

.pricing-cta.secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.metric {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.metric:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.metric-label {
  display: block;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.chat-shell {
  --sidebar-width: 320px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1rem 1.5rem 1.5rem 0;
  min-height: calc(100vh - 90px);
  transition: grid-template-columns 0.2s ease;
}

.chat-shell.sidebar-collapsed {
  --sidebar-width: 63px;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.chat-shell.sidebar-collapsed .chat-sidebar {
  padding: 0.85rem 0.35rem;
}

.chat-shell.sidebar-collapsed .chat-list,
.chat-shell.sidebar-collapsed .new-chat-trigger-label {
  display: none;
}

.chat-shell.sidebar-collapsed .sidebar-top {
  justify-content: center;
}

.chat-shell.sidebar-collapsed .new-chat-trigger {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  margin-top: 0.75rem;
  align-self: center;
  justify-content: center;
}

.chat-sidebar,
.chat-main,
.simple-page {
  border-radius: 24px;
}

.simple-page {
  max-width: 760px;
  margin: 2rem auto;
  padding: 2rem;
}

.support-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.support-form label {
  font-weight: 600;
}

.support-form input,
.support-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.95);
  padding: 0.9rem 1rem;
  color: var(--ink);
  font-size: 1rem;
}

.support-form textarea {
  resize: vertical;
  min-height: 180px;
}

.form-alert {
  padding: 0.85rem 1rem;
  border-radius: 16px;
  margin-top: 1rem;
}

.form-alert.success {
  background: rgba(39, 93, 56, 0.12);
  color: var(--success);
}

.form-alert.error {
  background: rgba(143, 45, 20, 0.1);
  color: var(--accent-dark);
}

.chat-sidebar-slot {
  position: relative;
  min-width: 0;
}

.chat-sidebar {
  padding: 1rem;
  border-radius: 0 24px 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 90px;
  width: var(--sidebar-width);
  height: calc(100vh - 90px - 1rem);
  max-height: calc(100vh - 90px - 1rem);
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.new-chat-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  width: 100%;
  min-height: 2.6rem;
  margin-top: 0.75rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.95);
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.new-chat-trigger:hover {
  background: #f4eddf;
}

.new-chat-trigger-label {
  white-space: nowrap;
}

.new-chat-trigger .plus-icon {
  margin-top: 0;
  flex: 0 0 auto;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.95);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  background: #f4eddf;
}

.sidebar-icon {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plus-icon {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  overflow: auto;
  padding-right: 0.25rem;
}

.chat-list-item {
  width: 100%;
  text-align: left;
  background: transparent;
  padding: 0.9rem;
  position: relative;
}

.chat-list-item.active {
  background: rgba(217, 93, 57, 0.12);
  border-color: var(--accent);
}

.chat-list-title {
  display: block;
  padding-right: 2.8rem;
}

.chat-item-actions {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
}

.chat-delete-button {
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.98);
}

.chat-delete-button:hover {
  background: #f9dfd6;
  color: var(--accent-dark);
}

.trash-icon {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-list-item small {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
}

.chat-main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 1rem;
  gap: 1rem;
  min-height: 72vh;
  position: relative;
  width: min(1120px, 100%);
  justify-self: center;
  min-width: 0;
  overflow: hidden;
}

.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.chat-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  min-width: 0;
}

.subscription-banner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--accent-dark);
}

.messages {
  overflow: auto;
  display: grid;
  gap: 1rem;
  align-content: start;
  padding-right: 0.4rem;
  min-width: 0;
}

.message {
  max-width: 900px;
  min-width: 0;
}

.message .message-body {
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--line);
  min-width: 0;
  overflow-wrap: anywhere;
}

.message.user .message-body {
  background: #f0e6d6;
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.55;
}

.markdown-body {
  white-space: normal;
  overflow-wrap: anywhere;
}

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

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

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre,
.markdown-body blockquote,
.markdown-body table {
  margin: 0 0 0.9rem;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.25rem;
}

.markdown-body li + li {
  margin-top: 0.25rem;
}

.markdown-body code {
  background: #f4eddf;
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
}

.markdown-body pre {
  overflow: auto;
  background: #f8f4eb;
  border-radius: 14px;
  padding: 1rem;
  white-space: pre-wrap;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1rem 0 0.6rem;
  line-height: 1.15;
}

.markdown-body blockquote {
  margin-left: 0;
  padding-left: 0.9rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.message.pending .message-body {
  border-style: dashed;
  color: var(--muted);
}

.message-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.typing-dots {
  display: inline-flex;
  gap: 0.25rem;
}

.typing-dots span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 1s infinite ease-in-out;
}

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

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

.csv-viewer {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  max-width: 100%;
}

.csv-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: #f4eddf;
}

.csv-table-wrap {
  overflow: auto;
  max-width: 100%;
}

.csv-table {
  width: max-content;
  min-width: 980px;
  border-collapse: collapse;
}

.csv-table th,
.csv-table td {
  padding: 0.75rem;
  text-align: left;
  border-top: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}

.csv-table th {
  background: #fbf7ef;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(24, 35, 15, 0.28);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(520px, 100%);
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 0.6rem;
  line-height: 1.15;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 1.25rem;
}

.cta.danger {
  background: var(--accent-dark);
}

@keyframes pulse {
  0%, 80%, 100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.chat-form {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.chat-form-actions {
  display: flex;
  align-items: end;
  justify-content: flex-start;
  gap: 0.8rem;
  min-width: 0;
}

#composer-model-wrap {
  min-width: 0;
}

.composer-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 1rem;
  background: white;
  min-width: 0;
}

select {
  padding: 0.7rem 0.8rem;
  background: white;
}

.simple-page {
  max-width: 860px;
  margin: 2rem auto;
  padding: 2rem;
}

@media (max-width: 900px) {
  .hero,
  .pricing-layout,
  .chat-shell {
    grid-template-columns: 1fr;
  }

  .chat-shell.sidebar-collapsed {
    --sidebar-width: 54px;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .hero h1 {
    max-width: none;
  }

  .chat-shell {
    min-height: auto;
    padding-right: 1rem;
  }

  .chat-sidebar {
    position: static;
    width: auto;
    max-height: none;
    height: auto;
    overflow: visible;
  }

  .chat-list {
    overflow: visible;
  }

  .chat-toolbar,
  .chat-toolbar-actions,
  .chat-form-actions {
    flex-wrap: wrap;
    align-items: center;
  }

  .chat-main {
    width: 100%;
  }

  .chat-form-actions > * {
    width: 100%;
  }

  .pricing-page {
    padding: 2.5rem 1rem;
  }

  .pricing-card {
    padding: 1.4rem;
  }

  .pricing-intro h1 {
    max-width: none;
  }
}
