:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --woodland-brown: #9f7560;
  --woodland-gray: #9e9e9e;
  --woodland-lime: #aad31e;
  --woodland-blush: #d4af9f;
  --woodland-olive: #525034;
  --page: #f6f0eb;
  --surface: #efe2db;
  --surface-strong: #d4af9f;
  --sidebar: #525034;
  --sidebar-soft: #6a6844;
  --sidebar-line: rgba(212, 175, 159, 0.28);
  --text: #2f2b1f;
  --muted: #7a7169;
  --line: #c9b8ae;
  --accent: #aad31e;
  --accent-dark: #859c24;
  --danger: #c24132;
  --assistant: #efe2db;
  --user: #d4af9f;
  --space-card: 28px;
  --space-section: 72px;
  --space-gap: 16px;
  --shadow-soft: 0 14px 30px rgba(82, 80, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--page);
  font-weight: 400;
  transition: opacity 0.2s ease;
}

html {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

html.page-ready {
  opacity: 1;
  transform: translateY(0);
}

html.page-leaving {
  opacity: 0;
  transform: translateY(4px);
}

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

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: #fbf7f3;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(170, 211, 30, 0.26);
  border-color: var(--accent);
}

.login-section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 96px 28px 28px;
  background:
    linear-gradient(180deg, rgba(212, 175, 159, 0.34), rgba(246, 240, 235, 1)),
    var(--page);
}

.login-site-header {
  left: 0;
  position: fixed;
  right: 0;
}

.signup-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  position: fixed;
  inset: 0;
  background: rgba(246, 240, 235, 0.94);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: var(--space-card);
  background: #fbf7f3;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(82, 80, 52, 0.16);
  text-align: center;
}

.login-container h1 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: 0;
  font-weight: 850;
}

.login-container p {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 400;
  line-height: 1.55;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-gap);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 650;
}

.form-group input {
  min-height: 48px;
  padding: 0 13px;
  background: #fffaf7;
}

.form-group input::placeholder {
  color: #96857b;
}

.login-btn,
.signup-btn,
.back-btn,
.login-home-link {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  font-weight: 700;
  text-decoration: none;
}

.btn-primary,
.login-btn {
  color: var(--woodland-olive);
  background: var(--accent);
}

.btn-primary:hover,
.login-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  background: var(--accent-dark);
}

.btn-secondary,
.signup-btn,
.login-home-link {
  color: var(--text);
  background: #fbf7f3;
  border-color: var(--line);
}

.btn-secondary:hover,
.signup-btn:hover,
.login-home-link:hover {
  background: var(--surface);
  border-color: #b99887;
  box-shadow: var(--shadow-soft);
}

.login-divider {
  margin: 22px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.login-home-link {
  margin-top: 12px;
}

.btn-text,
.back-btn {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.btn-text:hover,
.back-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.9rem;
}

.chat-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--page);
}

.chat-site-header {
  position: sticky;
  top: 0;
  z-index: 30;
}

.chat-shell {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.chat-sidebar {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 14px;
  padding: 14px;
  color: #f6f0eb;
  background: var(--sidebar);
  border-right: 1px solid rgba(58, 56, 34, 0.75);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  font-weight: 750;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--woodland-olive);
  background: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
}

.new-chat-button,
.history-item,
.sidebar-home-link {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #f6f0eb;
  background: transparent;
  border-color: var(--sidebar-line);
  text-align: left;
  font-weight: 650;
  text-decoration: none;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
}

.new-chat-button:hover,
.history-item:hover,
.history-item.active,
.sidebar-home-link:hover {
  background: var(--sidebar-soft);
}

.chat-history {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
}

.sidebar-footer {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  color: #ddd3cb;
  font-size: 0.88rem;
}

.sidebar-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.chat-app {
  min-width: 0;
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: var(--page);
}

.chat-header {
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(360px, 520px);
  gap: 22px;
  align-items: center;
  padding: 14px 24px;
  background: rgba(246, 240, 235, 0.94);
  border-bottom: 1px solid var(--line);
}

.chat-title {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: 1.52rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.model-controls {
  display: grid;
  gap: 8px;
}

.model-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.model-topline label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.model-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.model-actions select {
  min-height: 42px;
  padding: 0 12px;
}

#load-models,
.logout-button {
  min-height: 42px;
  padding: 0 14px;
  font-weight: 750;
}

#load-models {
  color: var(--woodland-olive);
  background: var(--accent);
}

#load-models:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  background: var(--accent-dark);
}

.logout-button {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.logout-button:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface);
}

.messages {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 26px 24px 18px;
  background:
    linear-gradient(180deg, rgba(212, 175, 159, 0.3), rgba(246, 240, 235, 1)),
    var(--page);
}

.message {
  width: min(100%, 860px);
  display: flex;
  margin: 0 auto;
  padding: 0;
  border-bottom: 0;
  line-height: 1.65;
  font-size: 1rem;
}

.message p {
  max-width: min(72%, 720px);
  margin: 0;
  padding: 12px 15px;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(82, 80, 52, 0.1);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.assistant {
  justify-content: flex-start;
  background: transparent;
}

.message.user {
  justify-content: flex-end;
  background: transparent;
}

.message.assistant p {
  color: var(--text);
  background: #fbf7f3;
  border: 1px solid var(--line);
}

.message.user p {
  color: var(--woodland-olive);
  background: var(--user);
  border: 1px solid #b99887;
}

.typing-dots {
  min-width: 120px;
  min-height: 70px;
  color: transparent;
  position: relative;
}

.typing-dots::after {
  content: "...";
  position: absolute;
  left: 15px;
  top: 4px;
  color: var(--muted);
  font-size: 3rem;
  line-height: 1;
  animation: typingDots 1s steps(4, end) infinite;
  overflow: hidden;
  white-space: nowrap;
}

@keyframes typingDots {
  0% {
    width: 0;
  }

  25% {
    width: 0.35em;
  }

  50% {
    width: 0.7em;
  }

  75%,
  100% {
    width: 1.05em;
  }
}

.composer {
  width: min(100% - 48px, 860px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 18px 0 8px;
  background: var(--page);
}

textarea {
  min-height: 54px;
  max-height: 180px;
  padding: 15px 16px;
  resize: none;
  box-shadow: 0 8px 26px rgba(82, 80, 52, 0.12);
}

.composer button {
  min-width: 84px;
  min-height: 54px;
  padding: 0 18px;
  color: var(--woodland-olive);
  background: var(--accent);
  font-weight: 800;
}

.composer button:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  background: var(--accent-dark);
}

.status {
  width: min(100% - 48px, 860px);
  min-height: 28px;
  margin: 0 auto;
  padding: 0 0 12px;
  color: var(--muted);
  background: var(--page);
  font-size: 0.86rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.site-body {
  min-height: 100vh;
  color: var(--text);
  background: var(--page);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  background: rgba(246, 240, 235, 0.96);
  border-bottom: 1px solid var(--line);
}

.site-header.login-site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  width: 100%;
}

.site-brand,
.site-nav,
.hero-actions,
.contact-panel {
  display: flex;
  align-items: center;
}

.site-brand {
  gap: 10px;
  color: var(--text);
  font-weight: 850;
  text-decoration: none;
}

.site-nav {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.site-nav a,
.primary-link,
.secondary-link,
.btn-primary,
.btn-secondary,
.btn-text {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 750;
  text-decoration: none;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.site-nav a {
  color: var(--muted);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
  background: var(--surface);
}

.site-nav a.active {
  box-shadow: inset 0 0 0 1px var(--line);
}

.site-nav a:hover,
.primary-link:hover,
.secondary-link:hover,
.feature-card:hover,
.project-card:hover {
  transform: translateY(-1px);
}

.site-hero {
  min-height: calc(100vh - 72px);
  display: grid;
  align-items: end;
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 5vw, 64px);
  background: var(--woodland-olive);
}

.site-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.52;
}

.site-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(82, 80, 52, 0.9),
    rgba(159, 117, 96, 0.52)
  );
}

.hero-copy {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  color: #fff9f4;
}

.hero-copy h1,
.page-intro h1 {
  font-size: 4.8rem;
  line-height: 0.96;
  font-weight: 900;
}

.hero-copy p {
  max-width: 620px;
  font-size: 1.08rem;
  line-height: 1.7;
  font-weight: 400;
}

.hero-actions,
.contact-panel {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.primary-link {
  color: var(--woodland-olive);
  background: var(--accent);
}

.primary-link:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  background: var(--accent-dark);
  box-shadow: 0 10px 24px rgba(170, 211, 30, 0.28);
}

.secondary-link {
  color: var(--text);
  background: #fbf7f3;
  border: 1px solid var(--line);
}

.secondary-link:hover {
  border-color: #b99887;
  box-shadow: 0 10px 24px rgba(82, 80, 52, 0.14);
}

.site-hero .secondary-link {
  color: #fff9f4;
  background: rgba(212, 175, 159, 0.18);
  border-color: rgba(255, 249, 244, 0.4);
}

.site-section,
.content-page {
  padding: var(--space-section) clamp(18px, 4vw, 56px);
}

.section-heading,
.page-intro,
.project-list {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.section-heading {
  margin-bottom: 24px;
}

h2 {
  margin: 0;
  font-size: 2.8rem;
  line-height: 1.05;
  letter-spacing: 0;
  font-weight: 850;
}

.feature-grid,
.project-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-gap);
}

.feature-card,
.project-card {
  padding: var(--space-card);
  background: #fbf7f3;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.feature-card:hover,
.project-card:hover {
  border-color: #b99887;
  box-shadow: var(--shadow-soft);
}

.feature-card h3,
.project-card h2 {
  margin: 0 0 12px;
}

.feature-card p,
.project-card p,
.page-intro p {
  color: var(--muted);
  line-height: 1.7;
  font-weight: 400;
}

.feature-card a {
  color: var(--accent-dark);
  font-weight: 750;
}

.content-page {
  min-height: calc(100vh - 72px);
  background: var(--surface);
}

.page-intro {
  padding: 0;
}

.page-intro > p {
  max-width: 760px;
  font-size: 1.08rem;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 480px);
  gap: 34px;
  align-items: center;
}

.two-column img,
.featured-project img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
  border-radius: 8px;
}

.about-image-frame {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 260px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--woodland-olive);
  border-radius: 8px;
  overflow: hidden;
}

.two-column img.about-pipeline-image {
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  object-fit: contain;
  background: var(--woodland-olive);
  border-radius: 8px;
}

.project-list {
  margin-top: 32px;
}

.featured-project {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1fr);
  gap: 26px;
  align-items: center;
}

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

  .chat-sidebar {
    min-height: auto;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    align-items: center;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(58, 56, 34, 0.75);
  }

  .chat-history,
  .sidebar-footer,
  .sidebar-home-link {
    display: none;
  }

  .chat-app {
    min-height: auto;
  }

  .chat-header {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px 16px;
  }

  .model-actions {
    grid-template-columns: 1fr;
  }

  .message {
    font-size: 0.96rem;
  }

  .message p {
    max-width: 86%;
  }

  .composer,
  .status {
    width: min(100% - 24px, 860px);
  }

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

@media (max-width: 820px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .site-hero {
    min-height: 78vh;
  }

  .feature-grid,
  .project-list,
  .two-column,
  .featured-project {
    grid-template-columns: 1fr;
  }

  .featured-project img,
  .two-column img {
    min-height: 240px;
  }

  .two-column img.about-pipeline-image {
    height: auto;
    max-height: none;
    min-height: 0;
  }

  .about-image-frame {
    min-height: 0;
  }
}

@media (max-width: 680px) {
  .hero-copy h1,
  .page-intro h1 {
    font-size: 3.1rem;
  }

  h2 {
    font-size: 2.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html,
  button,
  .site-nav a,
  .primary-link,
  .secondary-link,
  .feature-card,
  .project-card {
    transition: none;
  }

  html,
  html.page-ready,
  html.page-leaving,
  button:hover:not(:disabled),
  .site-nav a:hover,
  .primary-link:hover,
  .secondary-link:hover,
  .feature-card:hover,
  .project-card:hover {
    transform: none;
  }
}

@media (max-width: 560px) {
  .login-section,
  .signup-container {
    padding: 16px;
  }

  .login-container {
    padding: 26px;
  }

  .sidebar-brand span:last-child {
    display: none;
  }

  .new-chat-button {
    text-align: center;
  }
}
