@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@200;300;400&family=Cormorant+Garamond:ital,wght@0,300;1,300&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:     #1C0F06;
  --ink-mid: #5C3A1E;
  --ink-low: #9C7A60;
  --terra:   #FF671F;
  --terra-lt:#FF8040;
  --sand:    #F0EDE8;
  --paper:   #FAF9F7;
  --line:    rgba(255,103,31,0.18);
}

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── PAGE LAYOUT ── */
.page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: clamp(28px, 5vw, 56px) clamp(24px, 8vw, 80px);
  overflow: hidden;
}

/* ── NAV ── */
nav {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: fadein 0.8s ease both;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.logo-mark svg { display: block; }

.logo-wordmark {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 200;
  font-size: 26px;
  letter-spacing: 0.38em;
  color: var(--ink);
}

#new-chat {
  background: none;
  border: none;
  color: rgba(156, 122, 96, 0.45);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}

#new-chat.visible {
  opacity: 1;
  pointer-events: auto;
}

#new-chat:hover {
  color: var(--terra);
}

#new-chat[data-tooltip] {
  position: relative;
}

#new-chat[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

#new-chat[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── HERO (welcome state) ── */
main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: clamp(16px, 4vh, 48px) 0 clamp(16px, 3vh, 40px);
  animation: fadein 1s ease 0.1s both;
}

.hero.hidden { display: none; }

h1 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 200;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 24px;
  max-width: 14ch;
}

h1 em {
  font-style: italic;
  color: var(--terra);
}

.divider {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 auto 20px;
}

.subhead {
  font-size: clamp(14px, 2vw, 16px);
  font-weight: 300;
  color: var(--ink-mid);
  line-height: 1.7;
  max-width: 38ch;
  margin-bottom: 40px;
  letter-spacing: 0.01em;
}

/* ── INPUT (shared styles) ── */
.input-wrap {
  width: 100%;
  max-width: 520px;
}

.input-wrap textarea {
  width: 100%;
  background: #fff;
  border: 1px solid rgba(255,103,31,0.22);
  border-radius: 10px;
  padding: 15px 52px 15px 20px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 300;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: var(--terra);
  resize: none;
  max-height: 160px;
  line-height: 1.5;
  overflow: hidden;
}

.input-wrap textarea.has-overflow {
  overflow-y: auto;
}

.input-wrap textarea::placeholder {
  color: var(--ink-low);
  opacity: 0.7;
}

.input-wrap textarea:focus {
  border-color: rgba(255,103,31,0.55);
  box-shadow: 0 0 0 3px rgba(255,103,31,0.07);
}

#send, #send-chat {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-low);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  padding: 4px;
  line-height: 0;
}

#send:hover, #send-chat:hover { color: var(--terra); }
#send:disabled, #send-chat:disabled { opacity: 0.3; cursor: default; }

.input-hint {
  margin-top: 12px;
  font-size: 11px;
  font-weight: 300;
  color: var(--ink-low);
  letter-spacing: 0.08em;
}

/* ── CHAT (conversation state) ── */
.chat {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 24px 16px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 656px;
  width: 100%;
  margin: 0 auto;
}

.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: rgba(156, 122, 96, 0.25); border-radius: 3px; }
.chat::-webkit-scrollbar-thumb:hover { background: rgba(156, 122, 96, 0.4); }
.chat { scrollbar-width: thin; scrollbar-color: rgba(156, 122, 96, 0.25) transparent; }

.chat.hidden { display: none; }

.chat-input {
  padding-top: 20px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.chat-input.hidden { display: none; }

.chat-notice {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  font-weight: 300;
  color: var(--ink-low);
  letter-spacing: 0.04em;
}

.msg {
  line-height: 1.8;
  font-size: 15px;
  font-weight: 300;
  color: var(--ink);
  animation: fadein 0.4s ease both;
}

.msg.user {
  background: var(--sand);
  padding: 12px 20px;
  border-radius: 20px 20px 4px 20px;
  color: var(--ink);
  width: fit-content;
  max-width: 520px;
  margin-left: auto;
  font-weight: 400;
}

.msg.ai {
  padding: 0;
  color: var(--ink);
}

.msg.ai p { margin-bottom: 14px; }
.msg.ai p:last-child { margin-bottom: 0; }
.msg.ai strong { color: var(--ink); font-weight: 400; }
.msg.ai em { color: var(--ink-mid); font-style: italic; }

.msg.ai ol, .msg.ai ul {
  margin: 10px 0;
  padding-left: 24px;
}

.msg.ai li {
  margin-bottom: 8px;
}

.msg.ai hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

.msg.ai blockquote {
  border-left: 2px solid var(--terra);
  padding-left: 16px;
  color: var(--ink-mid);
  margin: 12px 0;
  font-style: italic;
}

.msg.ai code {
  background: rgba(28, 15, 6, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}

.typing {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  color: var(--terra);
  font-size: 14px;
  font-weight: 300;
  letter-spacing: 0.04em;
}

.typing span {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 15, 6, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadein-fast 0.15s ease both;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--paper);
  border-radius: 14px;
  padding: 28px 32px 24px;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(28, 15, 6, 0.12);
}

.modal-text {
  font-size: 14px;
  font-weight: 300;
  color: var(--ink);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btn {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 400;
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.modal-btn:hover { opacity: 0.85; }

.modal-btn-cancel {
  background: var(--sand);
  color: var(--ink-mid);
}

.modal-btn-confirm {
  background: var(--terra);
  color: #fff;
}

@keyframes fadein-fast {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── HERO NOTICE ── */
.hero-notice {
  position: absolute;
  bottom: clamp(16px, 3vw, 32px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 300;
  color: var(--ink-low);
  letter-spacing: 0.04em;
}

.hero-notice.hidden { display: none; }

.mobile-br { display: none; }

/* ── ANIMATIONS ── */
@keyframes fadein {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── DESKTOP CHAT TWEAKS ── */
@media (min-width: 601px) {
  .page { padding-top: 20px; padding-bottom: 16px; }
  .chat-input { padding-top: 12px; }
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .page { padding: 20px 18px; }
  .hero { padding: 0; }
  h1 { font-size: 48px; font-weight: 300; margin-bottom: 14px; }
  .divider { height: 14px; margin-bottom: 14px; }
  .subhead { font-size: 13px; margin-bottom: 24px; }
  .msg { font-size: 14px; }
  .msg.user { max-width: 85%; }
  .mobile-br { display: inline; }
  .input-hint { margin-bottom: 36px; }
  .hero-notice { font-size: 10px; line-height: 1.6; }
}
