/* Claude-inspired: warm paper ground, clay accent, serif headings, soft edges.
   Claude's own fonts (Styrene, Tiempos) are proprietary - these are the closest
   free lookalikes: Inter for UI, Newsreader for headings. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Newsreader:opsz,wght@6..72,400;6..72,500&display=swap');

:root {
  --bg: #f4f2ec;
  --bg-soft: #eeebe2;
  --surface: #fefdfb;
  --ink: #1c1b17;
  --ink-soft: #45423b;
  --muted: #736f65;
  --line: #e4e0d5;
  --line-soft: #efece3;
  --accent: #c15f3c;
  --accent-hover: #a94f30;
  --accent-tint: #f3e4db;
  --ok: #4a7c59;
  --warn: #b5762a;
  --danger: #b64a3f;

  --r-sm: 7px;
  --r: 10px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(28, 27, 23, .04), 0 4px 16px rgba(28, 27, 23, .05);

  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624;
    --bg-soft: #21201e;
    --surface: #30302e;
    --ink: #e9e6df;
    --ink-soft: #c9c5bb;
    --muted: #a29d92;
    --line: #3d3c37;
    --line-soft: #363530;
    --accent: #d97757;
    --accent-hover: #e08a6c;
    --accent-tint: #3a2f28;
    --shadow: 0 1px 2px rgba(0,0,0,.28), 0 6px 22px rgba(0,0,0,.32);
  }
}
* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.62 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: var(--bg-soft); color: var(--ink-soft);
  padding: 1.5px 6px; border-radius: 5px; font-size: .85em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.005em; color: var(--ink); }

.wrap { max-width: 540px; margin: 0 auto; padding: 30px 18px 56px; }
.wrap.wide { max-width: 880px; }
.back {
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 20px;
  font-size: 13px; color: var(--muted); font-family: var(--font);
}
.back:hover { color: var(--ink); text-decoration: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--r-sm); padding: 10px 17px; font: 500 14px/1 var(--font); cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--ink); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 6px; }
.btn.block { width: 100%; }

/* ---------- landing ---------- */
.hero h1 { font-size: 27px; line-height: 1.25; margin: 4px 0 8px; }
.hero p { color: var(--muted); margin: 0 0 26px; font-size: 15px; }
.pick { display: grid; gap: 14px; }
.company {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.company .name { font-family: var(--serif); font-weight: 500; font-size: 18px; }
.company .tag { color: var(--muted); font-size: 13.5px; margin: 4px 0 16px; }
.company .actions { display: flex; gap: 9px; flex-wrap: wrap; }
.company .actions .btn { flex: 1 1 auto; min-width: 132px; }
.foot { margin-top: 30px; font-size: 13px; color: var(--muted); line-height: 1.75; }
.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 14px 2px 0; }

/* ---------- panels (chat + call) ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.chat-shell { height: calc(100dvh - 108px); min-height: 440px; }
.head { display: flex; align-items: center; gap: 11px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px; font-family: var(--font);
}
.head .who { flex: 1; min-width: 0; }
.head .who b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .who span { font-size: 12px; color: var(--muted); }

.seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
  background: var(--bg-soft); flex: none;
}
.seg button {
  border: 0; background: transparent; color: var(--muted); padding: 6px 13px; cursor: pointer;
  font: 500 12.5px var(--font); white-space: nowrap;
}
.seg button.on { background: var(--accent); color: #fff; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

.msgs { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 86%; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.6; }
.msg.user {
  align-self: flex-end; background: var(--accent-tint); color: var(--ink);
  padding: 10px 14px; border-radius: 14px 14px 4px 14px;
}
.msg.agent { align-self: flex-start; color: var(--ink-soft); }
.msg.sys { align-self: center; color: var(--muted); font-size: 12px; text-align: center; max-width: 100%; }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; padding: 2px 0; display: flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; } .typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,60%,100% { opacity: .2; } 30% { opacity: .9; } }

.composer { display: flex; gap: 9px; padding: 14px; border-top: 1px solid var(--line-soft); }
.composer input {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 12px; padding: 11px 15px; font: 15px var(--font); outline: none;
  transition: border-color .14s ease;
}
.composer input:focus { border-color: var(--accent); }
.composer button {
  border: 0; background: var(--accent); color: #fff; border-radius: 12px;
  padding: 0 18px; font: 500 14px var(--font); cursor: pointer; flex: none;
}
.composer button:hover { background: var(--accent-hover); }
.composer button:disabled { opacity: .5; }

/* ---------- voice call ---------- */
.call-shell { padding: 30px 22px 22px; align-items: center; min-height: calc(100dvh - 108px); }
.call-shell .avatar { width: 50px; height: 50px; font-size: 18px; }
.call-shell h2 { margin: 14px 0 2px; font-size: 21px; text-align: center; }
.call-shell .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; text-align: center; }
.seg-wrap { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin-bottom: 4px; }

.orb {
  width: clamp(124px, 38vw, 160px); aspect-ratio: 1; border-radius: 50%;
  background: var(--bg-soft); display: grid; place-items: center; margin: 30px 0 20px;
  transition: background .3s ease; position: relative;
}
.orb::after {
  content: ''; position: absolute; inset: -12px; border-radius: 50%;
  border: 1.5px solid transparent; transition: border-color .3s ease;
}
.orb .core {
  width: 42%; aspect-ratio: 1; border-radius: 50%;
  background: var(--accent); transition: transform .24s ease, border-radius .24s, background .3s;
}
.orb.listening { background: rgba(74, 124, 89, .12); }
.orb.listening::after { border-color: rgba(74, 124, 89, .3); }
.orb.listening .core { background: var(--ok); animation: pulse 1.35s ease-in-out infinite; }
.orb.thinking .core { border-radius: 34%; animation: spin 1.15s linear infinite; }
.orb.speaking { background: var(--accent-tint); }
.orb.speaking::after { border-color: rgba(193, 95, 60, .32); }
.orb.speaking .core { animation: pulse .62s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.26); } }
@keyframes spin { to { transform: rotate(360deg); } }

.status { font-family: var(--serif); font-size: 18px; font-weight: 500; min-height: 24px; text-align: center; }
.status.sub2 { font-family: var(--font); font-weight: 400; color: var(--muted); font-size: 13px; min-height: 36px; margin-top: 4px; max-width: 300px; line-height: 1.5; }
.call-log {
  width: 100%; max-width: 430px; margin: 18px 0 4px; display: flex; flex-direction: column; gap: 12px;
  flex: 1; overflow-y: auto; min-height: 0;
}
.call-log .line { font-size: 14px; line-height: 1.55; }
.call-log .line.user { color: var(--muted); }
.call-log .line.agent { color: var(--ink-soft); }
.call-log .line b {
  display: block; color: var(--muted); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 3px;
}
.call-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; padding-top: 8px; width: 100%; }
.round {
  border: 1px solid transparent; border-radius: 999px; padding: 12px 24px;
  font: 500 14px var(--font); cursor: pointer; transition: filter .12s, background .14s;
}
.round:active { filter: brightness(.96); }
.round.start { background: var(--accent); color: #fff; }
.round.start:hover { background: var(--accent-hover); }
.round.end { background: transparent; color: var(--danger); border-color: var(--line); }
.round.soft { background: var(--bg-soft); color: var(--ink-soft); border-color: var(--line); }
.call-fallback { width: 100%; max-width: 430px; margin-top: 12px; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; margin: 16px 0 20px; flex-wrap: wrap; }
.tabs button {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 7px 15px; font: 500 13px var(--font); cursor: pointer;
}
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 11px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-family: var(--serif); font-size: 24px; font-weight: 500; }
.stat span { font-size: 12px; color: var(--muted); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px; vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 1.5px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.open { background: rgba(181,118,42,.16); color: var(--warn); }
.pill.resolved { background: rgba(74,124,89,.16); color: var(--ok); }
.pill.voice { background: var(--accent-tint); color: var(--accent); }
.pill.chat { background: var(--bg-soft); color: var(--muted); }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin-bottom: 8px; }
summary { cursor: pointer; font-size: 13px; }
.t-turn { font-size: 13px; margin: 4px 0; }
.t-turn b { color: var(--muted); }
.kb-entry { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.kb-entry label { display: block; font-size: 10.5px; color: var(--muted); margin: 8px 0 3px; text-transform: uppercase; letter-spacing: .06em; }
.kb-entry input, .kb-entry textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 8px; padding: 8px 11px; font: 13px var(--font);
}
.kb-entry textarea { min-height: 54px; resize: vertical; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 24px 0 10px; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.abar { display: grid; grid-template-columns: 88px 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; }
.abar .al { color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abar .at { height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.abar .at span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.abar .av { font-weight: 600; color: var(--ink); }
.abar .av em { color: var(--muted); font-weight: 400; font-style: normal; }

.gate { max-width: 340px; margin: 72px auto; text-align: center; }
.gate h1 { font-size: 20px; }
.gate input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--r-sm); padding: 12px 15px; font: 15px var(--font); margin: 14px 0;
}
.gate input:focus { border-color: var(--accent); outline: none; }

/* ---------- embeddable widget ---------- */
#cca-w-btn {
  position: fixed; right: 18px; bottom: 18px; z-index: 2147483000;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 13px 20px;
  font: 500 14px var(--font); box-shadow: 0 6px 22px rgba(28,27,23,.24); cursor: pointer;
}
#cca-w-panel {
  position: fixed; right: 18px; bottom: 78px; z-index: 2147483000;
  width: 384px; max-width: calc(100vw - 32px); height: 588px; max-height: calc(100dvh - 116px);
  border-radius: var(--r-lg); overflow: hidden; background: var(--surface);
  box-shadow: 0 16px 48px rgba(28,27,23,.28); display: none;
}
#cca-w-panel.open { display: block; }
#cca-w-panel iframe { width: 100%; height: 100%; border: 0; }
#cca-w-tabs { display: flex; }
#cca-w-tabs button { flex: 1; border: 0; padding: 11px; background: var(--bg-soft); color: var(--ink-soft); font: 500 13px var(--font); cursor: pointer; }
#cca-w-tabs button.on { background: var(--accent); color: #fff; }

/* ---------- mobile ---------- */
@media (max-width: 520px) {
  .wrap { padding: 20px 14px 36px; }
  .hero h1 { font-size: 23px; }
  .chat-shell { height: calc(100dvh - 84px); border-radius: 14px; }
  .call-shell { min-height: calc(100dvh - 84px); }
  .company .actions .btn { flex-basis: 100%; }
  .msg { max-width: 90%; }
  .head { padding: 12px 13px; }
  .round { padding: 12px 20px; flex: 1 1 42%; }
}
