:root {
  --color-alabaster: #FBF9F6;
  --color-espresso: #33241C;
  --color-cobalt: #0020C2;
  --color-sand: #E6DFD3;
  --ink-2: rgba(51, 36, 28, 0.68);
  --ink-3: rgba(51, 36, 28, 0.48);
  --font-technical: "Space Grotesk", system-ui, sans-serif;
  --font-editorial: "EB Garamond", ui-serif, Georgia, serif;
  --text-size: 17px;
  --text-line: 1.5;
  --nav-size: 16px;
  --margin: 40px;
  --sidebar-width: 300px;
  --content-max: 800px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--color-alabaster);
  color: var(--color-espresso);
  font-family: var(--font-technical);
  -webkit-font-smoothing: antialiased;
}
:focus-visible {
  outline: 2px solid var(--color-cobalt);
  outline-offset: 3px;
}
.chat-input:focus-visible { outline: none; }

.icon-btn {
  position: fixed;
  z-index: 30;
  top: var(--margin);
  left: var(--margin);
  color: var(--color-espresso);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.top-fade {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 40px;
  z-index: 25;
  pointer-events: none;
  background: var(--color-alabaster);
  -webkit-mask-image: linear-gradient(180deg, black 0, transparent);
  mask-image: linear-gradient(180deg, black 0, transparent);
}

.sidebar-container {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 20;
  transform: translateX(calc(-1 * var(--sidebar-width)));
  transition: transform 0.3s ease;
  pointer-events: none;
}
.sidebar-container.open {
  transform: translateX(0);
  pointer-events: auto;
}
.sidebar {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background: #F5F0E7;
  padding: 120px var(--margin) max(var(--margin), env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
}
.sidebar-footer { margin-top: auto; padding-top: 1.5em; }
.nav-item {
  font-family: var(--font-technical);
  font-size: var(--nav-size);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: left;
  display: block;
}
.nav-item:hover,
.nav-item-home { color: var(--color-espresso); }
.nav-item-home {
  margin-bottom: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--color-cobalt);
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(51, 36, 28, 0.28);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.page-wrapper { transition: padding-left 0.3s ease; }
body.sidebar-open .page-wrapper { padding-left: var(--sidebar-width); }

.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 80px;
}
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding-top: 88px;
  padding-bottom: 16px;
  scrollbar-width: none;
}
.chat-thread::-webkit-scrollbar { display: none; }

.ascii-greeting,
.chat-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-technical);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--color-espresso);
  margin: 0 0 28px;
  padding: 0;
  border: none;
  white-space: nowrap;
}
.chat-brand-mark {
  color: var(--color-cobalt);
  font-weight: 700;
}
.greeting-sub {
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 20px;
  color: var(--ink-2);
  margin: 0 0 36px;
}

.user-message,
.assistant-message {
  margin: 0 0 28px;
}
.user-message {
  position: relative;
  padding-left: 16px;
  font-family: var(--font-technical);
  font-size: var(--text-size);
  line-height: var(--text-line);
  color: var(--color-espresso);
}
.user-message::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.25em;
  bottom: 0.25em;
  width: 2px;
  background: var(--color-cobalt);
}
.assistant-message {
  font-family: var(--font-editorial);
  font-size: 20px;
  line-height: 1.45;
  color: var(--color-espresso);
}
.assistant-message p { margin: 0 0 14px; }
.assistant-message p:last-child { margin-bottom: 0; }
.assistant-message a { color: var(--color-cobalt); }
.assistant-message ul {
  margin: 0 0 14px;
  padding-left: 1.1em;
}
.thinking-text {
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 20px;
  margin: 0 0 28px;
  color: var(--ink-3);
}

.chat-input-wrapper {
  position: relative;
  padding: 0 0 max(16px, env(safe-area-inset-bottom));
  background: var(--color-alabaster);
  flex-shrink: 0;
}
.starter-prompts {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 28px;
  padding-bottom: 0;
}
.starter-prompt-btn {
  font-family: var(--font-technical);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--color-espresso);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--color-sand);
  border-radius: 999px;
  cursor: pointer;
  padding: 0.65rem 1.05rem;
  min-height: 40px;
  text-align: left;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
.starter-prompt-btn:hover {
  color: var(--color-cobalt);
  border-color: var(--color-cobalt);
  background: #FFFEFB;
}
.starter-prompts.is-hidden { display: none; }

.chat-input-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  border-top: 1px solid var(--color-sand);
}
.chat-input-row:focus-within { border-top-color: var(--color-espresso); }
.chat-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-technical);
  font-size: var(--text-size);
  line-height: var(--text-line);
  color: var(--color-espresso);
  background: transparent;
  border: none;
  padding: 16px 0;
  resize: none;
  outline: none;
  caret-color: transparent;
  min-height: calc(var(--text-size) * var(--text-line) + 32px);
  max-height: 200px;
  overflow-y: auto;
}
.chat-input::placeholder { color: var(--ink-3); }
.chat-submit-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  font-family: var(--font-technical);
  font-size: 32px;
  line-height: 1;
  color: var(--color-cobalt);
  padding: 8px 0 0 12px;
  cursor: default;
  opacity: 0.25;
}
.chat-submit-btn:not(:disabled) {
  opacity: 1;
  cursor: pointer;
}
.chat-cursor-block {
  display: none;
  position: absolute;
  top: 16px;
  left: 0;
  width: 10px;
  height: 18px;
  background: var(--color-cobalt);
  pointer-events: none;
  animation: cursor-blink 1s step-end infinite;
}
.chat-cursor-block.is-empty {
  display: block;
}
.chat-input-row:has(.chat-cursor-block.is-empty) .chat-input {
  padding-left: 16px;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.chat-input-row.is-capped {
  opacity: 0.4;
  pointer-events: none;
}

.chat-footer-ctas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  padding-top: 0.25rem;
}
.chat-footer-contact,
.chat-footer-book {
  font-family: var(--font-technical);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.1rem;
  border-radius: 12px;
  cursor: pointer;
}
.chat-footer-contact {
  color: var(--color-cobalt);
  background: transparent;
  border: 1px solid var(--color-cobalt);
}
.chat-footer-contact:hover {
  background: var(--color-cobalt);
  color: var(--color-alabaster);
}
.chat-footer-book {
  color: var(--color-alabaster);
  background: var(--color-cobalt);
  border: 1px solid var(--color-cobalt);
}
.chat-footer-book:hover {
  background: var(--color-espresso);
  border-color: var(--color-espresso);
  color: var(--color-alabaster);
  text-decoration: none;
}
.chat-footer-email {
  font-family: var(--font-technical);
  font-size: 14px;
  color: var(--color-cobalt);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.chat-footer-email.is-hidden {
  display: none;
}

/* Persistent notice under the composer: the transcript reaching a human inbox is the thing a visitor
   is least likely to assume, so it is stated before they type rather than only in the policy. */
.chat-disclaimer {
  margin: 0.75rem 0 0;
  font-family: var(--font-technical);
  font-size: 11px;
  line-height: 1.55;
  /* ink-2 rather than the fainter ink-3 used for hints: a notice nobody can read is not a notice. */
  color: var(--ink-2);
  max-width: 62ch;
}
.chat-disclaimer a {
  color: var(--color-cobalt);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.lead-form {
  margin: 0 0 28px;
  padding: 20px 0 0;
  border-top: 1px solid var(--color-sand);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 28rem;
}
.lead-form-intro {
  margin: 0;
  font-family: var(--font-editorial);
  font-size: 20px;
  line-height: 1.45;
}
.lead-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-technical);
  font-size: 13px;
  color: var(--ink-2);
}
.lead-form .optional {
  color: var(--ink-3);
  font-weight: 400;
}
.lead-form input[type="text"],
.lead-form input[type="email"] {
  font-family: var(--font-technical);
  font-size: var(--text-size);
  color: var(--color-espresso);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-sand);
  padding: 8px 0;
  outline: none;
}
.lead-form input[type="text"]:focus,
.lead-form input[type="email"]:focus {
  border-bottom-color: var(--color-espresso);
}
.lead-consent {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px !important;
  line-height: 1.4;
}
.lead-consent input {
  margin-top: 3px;
  accent-color: var(--color-cobalt);
}
.lead-form-legal {
  /* Sits slightly clear of the two ticks above it: it is notice about the whole form, not a note on
     the marketing checkbox it would otherwise appear glued to. */
  margin: 4px 0 0;
  font-family: var(--font-technical);
  font-size: 11px;
  line-height: 1.55;
  color: var(--ink-2);
}
.lead-form-legal a {
  color: var(--color-cobalt);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lead-submit {
  align-self: flex-start;
  font-family: var(--font-technical);
  font-size: var(--text-size);
  color: var(--color-alabaster);
  background: var(--color-cobalt);
  border: none;
  padding: 10px 18px;
  cursor: pointer;
}
.lead-submit:disabled {
  opacity: 0.45;
  cursor: default;
}
.lead-error {
  margin: 0;
  font-family: var(--font-technical);
  font-size: 13px;
  color: var(--color-cobalt);
}

@media (max-width: 767px) {
  :root { --margin: 24px; }
  .chat-page { padding: 0 24px; }
  .sidebar-container {
    width: 100%;
    transform: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .sidebar-container.open {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar {
    padding-top: 80px;
    background: var(--color-alabaster);
  }
  .overlay { display: block; }
  body.sidebar-open .page-wrapper { padding-left: 0; }
}
