@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/assets/fonts/montserrat-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/assets/fonts/cormorant-garamond-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  font-family: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --gold: #ffb500;
  --gold-dark: #c98900;
  --olive: #6d712e;
  --ink: #232323;
  --muted: #757575;
  --cream: #fff8e4;
  --paper: #ffffff;
  --line: #e7e7e7;
  --danger: #a11818;
  background: var(--cream);
  color: var(--ink);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(255, 181, 0, 0.11) calc(50% - 0.5px), rgba(255, 181, 0, 0.11) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    var(--cream);
}

button, input, textarea { font: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--olive);
  border-radius: 0.2rem;
  background: var(--olive);
  color: #fff;
  padding: 0.78rem 1.1rem;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover:not(:disabled) {
  background: var(--ink);
  border-color: var(--ink);
  transform: translateY(-1px);
}

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

button.secondary {
  background: transparent;
  border-color: currentColor;
  color: var(--ink);
}

button.secondary:hover:not(:disabled) {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.shell {
  max-width: 1120px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  box-shadow: 0 18px 48px rgba(35, 35, 35, 0.09);
}

.auth-card {
  max-width: 460px;
  margin: clamp(2rem, 10vh, 7rem) auto;
  padding: clamp(1.5rem, 4vw, 2.5rem);
}

.brand-lockup {
  display: flex;
  width: 136px;
  padding: 0.25rem;
  background: var(--ink);
  border-bottom: 3px solid var(--gold);
  line-height: 0;
}

.brand-lockup-login { margin: 0 0 1.75rem; }

.brand-lockup-header {
  width: 76px;
  flex: 0 0 auto;
  padding: 0.16rem;
  border-bottom-width: 2px;
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--olive);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.13em;
}

h1,
h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 0.95;
}

.lede {
  max-width: 34rem;
  margin: 1rem 0 1.75rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

form { display: grid; gap: 1rem; }

label {
  display: grid;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cfcfc9;
  border-radius: 0.15rem;
  background: #fffef9;
  color: var(--ink);
  padding: 0.78rem 0.85rem;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(109, 113, 46, 0.16);
}

textarea { min-height: 5.6rem; resize: vertical; }

.chat-view {
  display: grid;
  height: calc(100dvh - 3rem);
  min-height: 34rem;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  background: var(--paper);
  box-shadow: 0 18px 48px rgba(35, 35, 35, 0.09);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.9rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
}

.brand-header {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.9rem;
}

.topbar .eyebrow { color: var(--gold); }
.topbar h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); }

.account {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.8rem;
  color: #efefef;
  font-size: 0.78rem;
}

.topbar button.secondary { color: var(--paper); }

.messages {
  display: grid;
  min-height: 0;
  align-content: start;
  gap: 1rem;
  overflow-y: auto;
  padding: clamp(1rem, 3vw, 1.75rem);
  background: linear-gradient(180deg, #fffdf7 0, var(--paper) 12rem);
}

.message {
  max-width: min(82%, 46rem);
  padding: 1rem 1.1rem;
  border-radius: 0.35rem;
  line-height: 1.6;
}

.message > p,
.markdown > p {
  margin: 0;
  white-space: pre-wrap;
}

.markdown {
  display: grid;
  gap: 0.78rem;
}

.markdown strong { font-weight: 700; }
.markdown em { font-style: italic; }
.markdown a {
  color: var(--gold-dark);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.markdown a:hover { color: var(--gold); }

.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 0;
  color: var(--ink);
  font-family: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  line-height: 1.3;
}

.markdown h2 { font-size: 1.2rem; }
.markdown h3 { font-size: 1.06rem; }
.markdown h4 { font-size: 0.96rem; }

.markdown code {
  padding: 0.1rem 0.28rem;
  border-radius: 0.18rem;
  background: #f3f0e5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

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

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

.message.user {
  justify-self: end;
  background: var(--olive);
  color: var(--paper);
  border-bottom-right-radius: 0;
}

.message.assistant {
  justify-self: start;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-bottom-left-radius: 0;
  background: var(--paper);
}

.message.pending {
  color: var(--muted);
  font-style: italic;
}

.composer {
  padding: 1rem 1.15rem 1.15rem;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.error { margin: 0; color: var(--danger); font-size: 0.84rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 760px) {
  .shell { padding: 0.9rem; }
  .chat-view { height: calc(100dvh - 1.8rem); min-height: 30rem; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 0.9rem; }
  .account { width: 100%; justify-content: space-between; }
}

@media (max-width: 480px) {
  .auth-card { margin: 1rem auto; }
  .brand-lockup-login { width: 118px; margin-bottom: 1.4rem; }
  .brand-lockup-header { width: 64px; }
  .topbar { padding: 0.75rem; }
  .messages { padding: 1rem 0.75rem; }
  .message { max-width: 94%; }
  .composer { padding: 0.8rem; }
}
