@font-face {
  font-family: "Anthropic Sans";
  src: url("./fonts/AnthropicSans_Roman.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Anthropic Sans";
  src: url("./fonts/AnthropicSans_Italic.woff2") format("woff2");
  font-weight: 400 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Anthropic Serif";
  src: url("./fonts/AnthropicSerif_Roman.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Anthropic Serif";
  src: url("./fonts/AnthropicSerif_Italic.woff2") format("woff2");
  font-weight: 400 600;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #faf9f5;
  --bg-secondary: #f5f4ed;
  --bg-tertiary: #f0eee6;
  --border: #e8e6dc;
  --border-strong: #d1cfc5;
  --ink: #141413;
  --ink-2: #30302e;
  --ink-3: #5e5d59;
  --ink-4: #87867f;
  --clay: #d97757;
  --clay-dark: #c46849;
  --clay-hover: #c6613f;
  --white: #fff;
  --sidebar-w: 68px;
  --sidebar-expanded: 260px;
  --composer-max: 680px;
  --radius-pill: 999px;
  --radius-composer: 22px;
  --shadow-composer: 0 2px 12px rgba(20, 20, 19, 0.04);
  --font-sans: "Anthropic Sans", "Noto Sans SC", "PingFang SC", sans-serif;
  --font-serif: "Anthropic Serif", "Noto Serif SC", "Songti SC", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
textarea { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
  min-height: 100vh;
}

/* —— Sidebar (icon rail) —— */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 16px;
  gap: 4px;
  z-index: 20;
}
.brand {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 10px;
}
.brand img { width: 28px; height: 36px; display: block; object-fit: contain; }
.nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: background .15s ease, color .15s ease;
}
.nav-btn:hover { background: var(--bg-tertiary); }
.nav-btn.is-active { background: var(--bg-tertiary); color: var(--ink); }
.nav-btn svg { width: 20px; height: 20px; display: block; }
.sidebar-spacer { flex: 1; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ebc9b7, var(--clay));
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  margin-top: 8px;
}

/* —— Main —— */
.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--bg);
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
  gap: 8px;
  flex-shrink: 0;
}
.top-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  padding: 6px 4px;
  border-radius: 10px;
}
.top-brand:hover { opacity: 0.88; }
.top-brand-mark {
  width: 26px;
  height: 34px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}
.top-brand-text {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1;
  color: #141413;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

/* Empty / greeting */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 12px;
  gap: 18px;
  animation: rise .45s var(--ease, cubic-bezier(.25, 1, .5, 1)) both;
}
.empty[hidden] { display: none !important; }
.greeting-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}
.greeting-mark img { width: 36px; height: 46px; display: block; object-fit: contain; }
.greeting-title {
  font-family: var(--font-serif);
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
  text-align: center;
}

/* Chat thread */
.thread {
  flex: 1;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 12px 20px 28px;
  display: none;
  flex-direction: column;
  gap: 22px;
}
.thread.is-on { display: flex; }
.msg {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  align-items: start;
  animation: rise .35s cubic-bezier(.25, 1, .5, 1) both;
}
.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-top: 2px;
}
.msg-avatar.is-claude {
  background: transparent;
}
.msg-avatar.is-claude svg { width: 22px; height: 22px; }
.msg-avatar.is-user {
  background: var(--bg-tertiary);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
}
.msg-body {
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  padding-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.is-user .msg-body {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 16px;
}
.typing {
  display: inline-flex;
  gap: 5px;
  padding: 8px 0;
}
.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-4);
  animation: bounce 1.1s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

/* Composer dock */
.composer-dock {
  width: min(var(--composer-max), calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 10px;
  flex-shrink: 0;
}
.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  transition: opacity .2s ease;
}
.pills[hidden] { display: none !important; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink-2);
  font-size: 13.5px;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.pill:hover {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
}
.pill:active { transform: scale(0.98); }
.pill svg { width: 15px; height: 15px; color: var(--ink-3); }

.composer {
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-composer);
  box-shadow: var(--shadow-composer);
  padding: 12px 12px 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer:focus-within {
  border-color: #c2c0b6;
  box-shadow: 0 4px 18px rgba(20, 20, 19, 0.06);
}
.composer textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  min-height: 28px;
  max-height: 180px;
  padding: 4px 8px 8px;
  font-size: 16px;
  line-height: 1.5;
}
.composer textarea::placeholder { color: var(--ink-4); }
.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
}
.composer-left, .composer-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tool-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 13px;
}
.tool-btn:hover { background: var(--bg-tertiary); color: var(--ink); }
.tool-btn svg { width: 18px; height: 18px; }
.model-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.model-btn:hover { background: var(--bg-tertiary); }
.model-btn svg.chev { width: 14px; height: 14px; color: var(--ink-4); }
.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  transition: opacity .15s ease, transform .15s ease;
}
.send-btn:disabled {
  opacity: 0.28;
  cursor: default;
}
.send-btn:not(:disabled):hover { background: var(--ink-2); }
.send-btn:not(:disabled):active { transform: scale(0.96); }
.send-btn svg { width: 16px; height: 16px; }

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--ink-4);
  padding: 6px 16px 16px;
  flex-shrink: 0;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: 56px 1fr; }
  .greeting-title { font-size: 26px; }
  .composer-dock { width: calc(100% - 20px); }
  .msg { grid-template-columns: 24px 1fr; gap: 10px; }
}

/* WA modal — no browser chrome, only the card */
.wa-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.wa-modal[hidden] { display: none !important; }
.wa-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 19, 0.45);
  backdrop-filter: blur(2px);
}
.wa-modal-panel {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  height: auto;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  background: #fff;
  animation: rise .28s cubic-bezier(.25, 1, .5, 1) both;
}
.wa-modal-panel iframe {
  width: 100%;
  height: 560px;
  max-height: calc(100vh - 48px);
  border: 0;
  display: block;
  background: #fff;
  vertical-align: top;
}
.wa-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #f0f2f5;
  color: #667781;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.wa-modal-close:hover { background: #e8eaed; color: #111b21; }
