/* Chat home. Builds on the tokens in app.css. */

body.chat-body { padding: 0; display: block; height: 100dvh; overflow: hidden; }

.chat {
  max-width: 760px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------------------- header */

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.chat-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-logo {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--brand);
  color: var(--brand-ink);
  display: grid; place-items: center;
  font: 700 1.25rem var(--serif);
}
.chat-title { font: 700 1.1rem/1.2 var(--serif); }
.chat-sub {
  font-size: 0.8rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: min(60vw, 480px);
}

.chat-menu { position: relative; }
.chat-menu-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font-size: 1.2rem; cursor: pointer;
}
.chat-menu-list {
  position: absolute; right: 0; top: 46px; z-index: 5;
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex; flex-direction: column;
}
.chat-menu-list.hidden { display: none; }
.chat-menu-list a, .chat-menu-list button {
  all: unset;
  box-sizing: border-box;
  display: block; width: 100%;
  padding: 10px 12px; border-radius: 10px;
  font-size: 0.92rem; color: var(--ink); cursor: pointer;
}
.chat-menu-list a.hidden { display: none; }
.chat-menu-list a:hover, .chat-menu-list button:hover { background: var(--brand-soft); }
.chat-menu-list button { color: var(--warn); }

/* ----------------------------------------------------------------------- log */

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}

.msg { max-width: 88%; font-size: 0.97rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg p { margin: 0 0 8px; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ul { margin: 0 0 8px; padding-left: 20px; }
.msg a { color: var(--brand); font-weight: 600; }

.msg-user {
  align-self: flex-end;
  background: var(--brand); color: var(--brand-ink);
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  white-space: pre-wrap;
}
.msg-bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 18px 18px 18px 4px;
}
.msg-error { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }

.msg-status {
  align-self: flex-start;
  color: var(--muted); font-size: 0.88rem;
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px;
}
.dots { display: inline-flex; gap: 4px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand); opacity: 0.35;
  animation: dot 1.1s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.18s; }
.dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* --------------------------------------------------------------------- cards */

.ccard {
  align-self: stretch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  font-size: 0.93rem;
}
.ccard h3 { margin: 0 0 4px; font-size: 1rem; }
.ccard .sub { color: var(--muted); font-size: 0.84rem; margin: 0 0 12px; }
.ccard .row { margin-top: 12px; }
.ccard-eyebrow {
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 6px;
}

.pick {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: block; width: 100%;
  border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-top: 8px;
}
.pick:hover, .pick:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.pick[disabled] { opacity: 0.55; cursor: default; }
.pick b { display: block; }
.pick span { color: var(--muted); font-size: 0.84rem; }

.score { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.score-ring {
  --pct: 0;
  flex: 0 0 auto;
  width: 84px; height: 84px; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--pct) * 1%), var(--line) 0);
  display: grid; place-items: center;
}
.score-ring > div {
  width: 66px; height: 66px; border-radius: 50%;
  background: var(--card);
  display: grid; place-items: center;
  font: 700 1.5rem var(--serif);
}
.bar { display: grid; grid-template-columns: 1fr 44px; gap: 4px 10px; align-items: center; margin: 7px 0; font-size: 0.84rem; }
.bar-track { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand); }
.bar-fill.low { background: #c2573f; }
.bar-fill.mid { background: var(--star); }
.bar .pct { text-align: right; color: var(--muted); }

.fixes { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: fix; }
.fixes li {
  counter-increment: fix;
  position: relative; padding: 8px 0 8px 30px;
  border-top: 1px solid var(--line);
}
.fixes li::before {
  content: counter(fix);
  position: absolute; left: 0; top: 9px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  font-size: 0.75rem; font-weight: 700;
  display: grid; place-items: center;
}
.fixes li.hard::before { background: var(--warn-soft); color: var(--warn); }
.fixes b { display: block; }
.fixes span { color: var(--muted); font-size: 0.86rem; }

.qr { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.qr img { width: 128px; height: 128px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.qr > div { flex: 1; min-width: 200px; }

.linkline {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 0.82rem; word-break: break-all; margin: 6px 0;
}

.draft {
  border-top: 1px solid var(--line);
  padding: 12px 0 4px;
}
.draft:first-of-type { border-top: 0; padding-top: 4px; }
.draft .meta { font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.draft .quote { font-size: 0.86rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; margin: 0 0 8px; }
.draft .text {
  background: var(--brand-soft); border-radius: 12px;
  padding: 10px 12px; white-space: pre-wrap;
}
.draft .note { font-size: 0.82rem; color: var(--warn); margin-top: 6px; }
.draft .idea { font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.draft .tools { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.stars-sm { color: var(--star); letter-spacing: 1px; }

.mini {
  all: unset; box-sizing: border-box; cursor: pointer;
  font-size: 0.82rem; font-weight: 600;
  padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--line); color: var(--ink);
}
.mini:hover { border-color: var(--brand); color: var(--brand); }
.mini.solid { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.tag {
  display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--star-soft); color: var(--ink);
}

.checks { list-style: none; margin: 8px 0 0; padding: 0; }
.checks li { padding: 7px 0 7px 26px; position: relative; border-top: 1px solid var(--line); }
.checks li::before { position: absolute; left: 0; top: 7px; font-weight: 700; }
.checks li.pass::before { content: "✓"; color: var(--good); }
.checks li.fail::before { content: "✕"; color: #c2573f; }
.checks span { display: block; color: var(--muted); font-size: 0.84rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .n { font: 700 1.45rem/1.1 var(--serif); }
.stat .l { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.stat .d { font-size: 0.78rem; color: var(--good); font-weight: 600; margin-top: 2px; }
.spark { width: 100%; height: 54px; margin-top: 12px; display: block; }
.fine { font-size: 0.8rem; color: var(--muted); margin: 12px 0 0; }

/* --------------------------------------------------------- suggestions, input */

.chat-suggest {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 6px 16px 8px;
  scrollbar-width: none;
}
.chat-suggest::-webkit-scrollbar { display: none; }
.chat-suggest button {
  all: unset; box-sizing: border-box; cursor: pointer; white-space: nowrap;
  font-size: 0.86rem; font-weight: 600;
  padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
.chat-suggest button:hover { border-color: var(--brand); color: var(--brand); }

.chat-input {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.chat-input textarea {
  flex: 1; resize: none;
  min-height: 46px; max-height: 160px;
  padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: 22px;
  background: var(--card); color: var(--ink);
  font: inherit; line-height: 1.4;
}
.chat-input textarea:focus { outline: none; border-color: var(--brand); }
.chat-input button {
  flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-ink);
  font-size: 1.1rem;
}
.chat-input button:disabled { opacity: 0.45; cursor: default; }
