/* Testline Coach — Perplexity-inspired, Hindi-first, mobile-friendly */

:root {
  --bg: #fcfcf9;
  --surface: #ffffff;
  --ink: #13343b;
  --ink-soft: #5f7479;
  --line: #e8e8e3;
  --accent: #20808d;
  --accent-soft: #e8f3f4;
  --accent-ink: #0f5e69;
  --good: #1b8a5a;
  --good-soft: #e7f5ee;
  --bad: #c0392b;
  --bad-soft: #fdecea;
  --radius: 14px;
  --font: "Noto Sans Devanagari", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.65;
}
.hidden { display: none !important; }
.muted { color: var(--ink-soft); font-size: 13px; }

/* ---------- login ---------- */
#login-view {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), var(--bg));
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 18px 50px rgba(19, 52, 59, .08);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-coach {
  font-size: 18px; font-weight: 600; color: var(--accent);
  font-family: var(--font); line-height: 1;
}
.brand.small .brand-logo { height: 22px; }
.brand.small .brand-coach { font-size: 15px; }
.tagline { color: var(--ink-soft); margin: 10px 0 28px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.phone-row { display: flex; gap: 8px; }
.phone-row input {
  flex: 1; padding: 12px 14px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 12px;
  font-family: var(--font); outline: none;
}
.phone-row input:focus { border-color: var(--accent); }
.primary-btn {
  background: var(--accent); color: #fff; border: 0;
  padding: 12px 18px; border-radius: 12px; font-size: 15px;
  font-family: var(--font); font-weight: 600; cursor: pointer;
}
.primary-btn:hover { background: var(--accent-ink); }
.primary-btn:disabled { opacity: .5; cursor: wait; }
.error-text { color: var(--bad); font-size: 13.5px; margin-top: 10px; }
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-soft); font-size: 13px; margin: 26px 0 14px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.demo-users { display: flex; flex-direction: column; gap: 8px; }
.demo-user {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; background: var(--surface);
  cursor: pointer; font-family: var(--font); font-size: 14.5px; text-align: left;
}
.demo-user:hover { border-color: var(--accent); background: var(--accent-soft); }
.demo-user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.welcome-line { margin-bottom: 18px; font-size: 16px; }
.exam-chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 320px; overflow-y: auto; }
.exam-chip {
  border: 1.5px solid var(--line); background: var(--surface);
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  font-family: var(--font); font-size: 14px;
}
.exam-chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- coach layout ---------- */
#coach-view {
  display: flex; flex-direction: column;
  height: 100vh;        /* fallback */
  height: 100dvh;       /* tracks the visible area on mobile (no chrome overlap) */
  overflow: hidden;     /* only .thread scrolls; composer stays pinned */
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: rgba(252, 252, 249, .92); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand.small { flex: none; }
/* in-UI close button (only shown inside the Testline app WebView) */
.close-btn {
  flex: none; border: 0; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--ink-soft);
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-right: -4px;
}
.close-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.user-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; flex: none;
}
.exam-pill {
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12.5px; padding: 4px 12px; border-radius: 999px; font-weight: 600;
}

.topbar-btn { font-size: 12.5px; padding: 5px 12px; white-space: nowrap; }

/* Refresh button — sits above the chat (the app WebView has no browser reload). */
.refresh-row { display: flex; justify-content: center; padding: 8px 16px 0; flex: none; }
.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; padding: 5px 14px; color: var(--ink-soft);
}
.refresh-btn:hover { color: var(--accent); }
.refresh-btn .refresh-icon { font-size: 14px; line-height: 1; display: inline-block; }
.refresh-icon.spinning { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Floating transient message (works on any screen, incl. the exam picker). */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: #fff; font-family: var(--font); font-size: 13.5px;
  padding: 10px 16px; border-radius: 10px; max-width: 86%; text-align: center;
  box-shadow: 0 8px 28px rgba(0,0,0,.22); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* exam context bar — faded teal, full-width, tappable */
.exam-bar {
  display: block; width: 100%; text-align: center;
  border: 0; border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent); opacity: .92;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  padding: 8px 16px; flex: none;
}
.exam-bar b { font-weight: 700; color: var(--accent-ink); }

/* exam-switch popup */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(19, 52, 59, .42);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(19, 52, 59, .25);
  padding: 22px 22px 16px; max-height: 80vh; display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  border: 0; background: none; cursor: pointer;
  font-size: 18px; color: var(--ink-soft); line-height: 1; padding: 4px;
}
.exam-modal-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; margin-top: 14px; }
.exam-modal-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
  font-family: var(--font); font-size: 14.5px; text-align: left; color: var(--ink);
}
.exam-modal-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.exam-modal-item.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.exam-modal-item .tick { color: var(--accent); font-weight: 700; }

.exam-modal-footer { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.modal-note {
  background: #fff7e6; border: 1px solid #f3d99a; color: #8a6a1a;
  font-size: 13px; border-radius: 10px; padding: 9px 12px; margin-bottom: 12px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions .ghost-btn, .modal-actions .primary-btn { font-size: 14px; }

@media (max-width: 560px) {
  .topbar { padding: 9px 12px; gap: 8px; }
  .topbar-btn { padding: 5px 9px; }
  .brand.small .brand-coach { display: none; }
  .user-badge #badge-name { display: none; }
}
@media (max-width: 380px) {
  .brand.small .brand-logo { height: 18px; }
  .topbar-btn { font-size: 11.5px; }
  .exam-bar { font-size: 12px; }
}

.thread {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 28px 18px 40px;
  width: 100%; max-width: 780px; margin: 0 auto;
  overflow-wrap: anywhere; word-break: break-word;
}

.hero { text-align: center; padding: 9vh 8px 0; }
.hero h2 { font-size: 30px; margin-bottom: 10px; }
.hero p { color: var(--ink-soft); max-width: 420px; margin: 0 auto 26px; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.chip {
  border: 1.5px solid var(--line); background: var(--surface);
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  font-family: var(--font); font-size: 14px; color: var(--ink);
  transition: all .12s;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

/* External-launch chip: opens a real quiz OUTSIDE the WebView (native app). */
.chip-external {
  display: inline-flex; align-items: center; gap: 7px;
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent-ink); font-weight: 600;
}
.chip-external:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip-external .chip-ext-arrow { font-size: 15px; line-height: 1; }
/* Review chip: subtle, sits next to the open-quiz chip. */
.chip-review { color: var(--ink-soft); }
.chip-review:hover { border-color: var(--good); background: var(--good-soft); color: var(--good); }

/* Card wrapping a real-quiz deeplink: title + question count + the two chips. */
.quiz-link-card {
  border: 1.5px solid var(--accent); border-radius: var(--radius);
  background: var(--surface); margin: 16px 0; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 6px 24px rgba(19, 52, 59, .06);
}
.quiz-link-card .chips-row { margin: 0; }
.quiz-link-meta { display: flex; flex-direction: column; gap: 2px; }
.quiz-link-title { font-weight: 700; font-size: 15px; color: var(--accent-ink); }
.quiz-link-count { font-size: 13px; color: var(--ink-soft); }
/* TEMP (testing): full deeplink + copy button. Remove with the JS block. */
.quiz-link-debug {
  display: flex; align-items: center; gap: 8px;
  margin-top: 2px; padding-top: 10px; border-top: 1px dashed var(--line);
}
.quiz-link-url {
  flex: 1; font-size: 12px; color: var(--ink-soft); word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all;
}
.quiz-link-copy {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer;
  color: var(--accent-ink); font-family: var(--font);
}
.quiz-link-copy:hover { background: var(--accent-soft); border-color: var(--accent); }

/* Recent-sessions picker on the exam screen: tap a card to resume that chat. */
.recent-sessions { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 20px; }
.recent-sessions-header {
  font-size: 14px; font-weight: 600; color: var(--ink); margin: 2px 2px 4px;
}
.recent-session-card {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 11px 14px; cursor: pointer;
  font-family: var(--font); text-align: left; transition: all .12s;
}
.recent-session-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.recent-session-card .rs-body { flex: 1; min-width: 0; }
.recent-session-card .rs-top {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.recent-session-card .rs-exam { font-weight: 600; font-size: 14px; color: var(--accent-ink); }
.recent-session-card .rs-time { font-size: 12px; color: var(--ink-soft); flex: none; }
.recent-session-card .rs-msg {
  font-size: 13px; color: var(--ink-soft); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-session-card .rs-arrow {
  flex: none; font-size: 18px; line-height: 1; color: var(--ink-soft);
  transition: transform .12s, color .12s;
}
.recent-session-card:hover .rs-arrow { color: var(--accent); transform: translateX(2px); }

/* ---------- messages ---------- */
.msg-user {
  margin: 26px 0 6px; display: flex; justify-content: flex-end;
}
.msg-user .bubble {
  background: var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 18px 18px 4px 18px;
  max-width: 85%; font-size: 15px;
}
.msg-note {
  text-align: center; color: var(--ink-soft); font-size: 12.5px; margin: 14px 0;
}
.msg-assistant { margin: 14px 0 8px; }

/* "thinking" loader shown before the agent's first step/text arrives */
.thinking { display: flex; gap: 5px; align-items: center; padding: 4px 0 2px; }
.thinking .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); opacity: .35;
  animation: thinking-pulse 1.1s ease-in-out infinite;
}
.thinking .dot:nth-child(2) { animation-delay: .18s; }
.thinking .dot:nth-child(3) { animation-delay: .36s; }
@keyframes thinking-pulse {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.steps { margin-bottom: 10px; }
.step-line {
  display: flex; align-items: center; gap: 8px;
  color: var(--ink-soft); font-size: 13px; padding: 2px 0;
}
.step-line .dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin .8s linear infinite; flex: none;
}
.step-line.done .dot {
  border: 0; animation: none;
  background: var(--good); position: relative;
}
.step-line.done .dot::after {
  content: "✓"; color: #fff; font-size: 9px; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
@keyframes spin { to { transform: rotate(360deg); } }

.answer { font-size: 15.5px; }
.answer p { margin: 10px 0; }
.answer ul, .answer ol { margin: 10px 0 10px 22px; }
.answer li { margin: 5px 0; }
.answer strong { color: var(--accent-ink); }
.answer h1, .answer h2, .answer h3 { font-size: 17px; margin: 16px 0 8px; }
.answer table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 14px; }
.answer th, .answer td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.answer th { background: var(--accent-soft); }
.answer code { background: var(--accent-soft); border-radius: 4px; padding: 1px 5px; word-break: break-word; }
.answer pre { overflow-x: auto; }
.answer p, .answer li { overflow-wrap: anywhere; }

.chips-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }

/* ---------- quiz widget ---------- */
.quiz-card {
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin: 16px 0;
  box-shadow: 0 6px 24px rgba(19, 52, 59, .06);
  overflow: hidden;
}
.quiz-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
}
.quiz-head .title { font-weight: 700; font-size: 15px; color: var(--accent-ink); }
.quiz-head .count { font-size: 13px; color: var(--accent-ink); }
.quiz-body { padding: 18px; }
.q-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.q-topic { font-size: 12px; color: var(--ink-soft); text-transform: none; }
.q-pyq {
  font-size: 11.5px; font-weight: 600; color: var(--accent-ink);
  background: var(--accent-soft); padding: 2px 9px; border-radius: 999px;
}
.q-text { font-weight: 600; margin-bottom: 14px; }
.q-text p { margin: 6px 0; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 10px 14px; cursor: pointer; background: var(--surface);
  font-family: var(--font); font-size: 14.5px; text-align: left; width: 100%;
}
.option:hover { border-color: var(--accent); }
.option:disabled { cursor: default; }
.option:disabled:hover { border-color: var(--line); }
.option.selected:disabled:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option .key {
  font-weight: 700; color: var(--ink-soft); font-family: Inter, sans-serif;
  flex: none; width: 18px;
}
.quiz-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.q-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.q-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line); cursor: pointer; border: 0; padding: 0;
}
.q-dot.visited { background: var(--ink-soft); }
.q-dot.current { background: var(--accent); transform: scale(1.3); }
.q-dot.dot-ok { background: var(--good); }
.q-dot.dot-no { background: var(--bad); }
.nav-btns { display: flex; gap: 8px; }
.ghost-btn {
  border: 1.5px solid var(--line); background: var(--surface);
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  font-family: var(--font); font-size: 14px;
}
.ghost-btn:hover { border-color: var(--accent); }

/* floating "Rate ★" entry point — sticky top-right inside the chat area.
   Deliberately understated (Flutter REPORT-button look): faint ink fill +
   border, muted label. Only shown when the user scrolls up and hasn't rated. */
.rate-float {
  position: sticky; top: -12px; z-index: 6;
  float: right; margin: -12px -4px 0 0;   /* hug the very top-right of the thread, tucked up to the exam-bar */
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(19, 52, 59, .16);
  color: var(--ink-soft);
  font-family: var(--font); font-size: 11px; font-weight: 600; letter-spacing: .5px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* default = hidden: faded out and inert. JS adds .rate-float--show. */
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.rate-float--show { opacity: 1 !important; transform: none !important; pointer-events: auto; }
.rate-float:hover { background: #ffffff; border-color: rgba(19, 52, 59, .26); }
.rate-float .rate-float-star { color: #f5b301; font-size: 13px; line-height: 1; }

/* results (review mode — same single card) */
.score-chip {
  font-weight: 700; background: var(--surface); color: var(--accent-ink);
  padding: 1px 9px; border-radius: 999px; border: 1.5px solid var(--accent);
}
.verdict { font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 999px; }
.verdict.ok { color: var(--good); background: var(--good-soft); }
.verdict.no { color: var(--bad); background: var(--bad-soft); }
.verdict.skip { color: var(--ink-soft); background: var(--accent-soft); }
.sol-toggle {
  background: none; border: 0; color: var(--accent); cursor: pointer;
  font-family: var(--font); font-size: 13.5px; padding: 4px 0; font-weight: 600;
}
.solution {
  background: var(--accent-soft); border-radius: 10px;
  padding: 10px 14px; margin-top: 8px; font-size: 14px;
}
.solution p { margin: 6px 0; }

/* ---------- composer ---------- */
.composer-wrap {
  padding: 10px 16px 14px;
  background: linear-gradient(transparent, var(--bg) 30%);
}
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 780px; margin: 0 auto;
  border: 1.5px solid var(--line); border-radius: 18px;
  background: var(--surface); padding: 10px 10px 10px 18px;
  box-shadow: 0 8px 30px rgba(19, 52, 59, .07);
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none;
  font-family: var(--font); font-size: 15.5px; line-height: 1.5;
  max-height: 130px; background: transparent;
}
.send-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 0;
  background: var(--accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.send-btn:hover { background: var(--accent-ink); }
.send-btn:disabled { opacity: .4; cursor: wait; }
.footnote { text-align: center; color: var(--ink-soft); font-size: 11.5px; margin-top: 8px; }

/* ---------- credits ---------- */
.credits-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; font-size: 13px; font-weight: 600;
}
.credits-pill.low { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-soft); }

.limit-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin: 14px 0;
  text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.limit-msg { font-weight: 600; font-size: 15.5px; }
.limit-note { margin: 0; }
.boost-btn { display: inline-flex; align-items: center; gap: 6px; }
.boost-btn .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #fff; opacity: .6;
  animation: thinking-pulse 1.1s ease-in-out infinite; display: inline-block;
}
.boost-btn .dot:nth-child(2) { animation-delay: .18s; }
.boost-btn .dot:nth-child(3) { animation-delay: .36s; }

/* ---------- Paywall ladder (trial arms) ---------- */
.paywall-ladder {
  width: 100%; max-width: 320px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
}
.paywall-tier {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-size: 15px; color: var(--ink); transition: border-color .15s, transform .05s;
}
.paywall-tier:hover { border-color: var(--accent, #6c5ce7); }
.paywall-tier:active { transform: scale(.99); }
.paywall-tier:disabled { opacity: .5; cursor: default; }
.paywall-tier .tier-main { font-weight: 600; }
.paywall-tier .tier-price { font-weight: 700; }
.paywall-tier.best { border-color: var(--accent, #6c5ce7); border-width: 2px; }
.paywall-tier .tier-tag {
  position: absolute; top: -9px; right: 12px;
  background: var(--accent, #6c5ce7); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 999px;
}
/* "Already paid? check status" — manual recovery under the ladder for when the
   native return callback doesn't fire. Understated, full ladder width. */
.check-payment-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; max-width: 320px; margin: 14px auto 0;
  text-align: center; color: var(--muted, #888);
}
.check-payment-btn:disabled { opacity: .7; cursor: default; }
.check-payment-btn .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted, #888); opacity: .6;
  animation: thinking-pulse 1.1s ease-in-out infinite; display: inline-block;
}
.check-payment-btn .dot:nth-child(2) { animation-delay: .18s; }
.check-payment-btn .dot:nth-child(3) { animation-delay: .36s; }

/* ---------- Rating / feedback ---------- */
.rating-card {
  /* Keep the block just a bit wider than the 5-star row, centered — not the
     full card/modal width. */
  width: 100%; max-width: 300px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
/* On the limit card, separate the rating from the credits message above it. */
.limit-card .rating-card {
  border-top: 1px solid var(--line); padding-top: 14px; margin-top: 2px;
}
.rating-title { margin: 0; font-weight: 600; font-size: 14.5px; color: var(--ink); }
.rating-stars { display: inline-flex; gap: 6px; }
.rating-star {
  background: none; border: none; cursor: pointer; padding: 0 2px;
  font-size: 30px; line-height: 1; color: var(--line);
  transition: color .12s, transform .12s;
}
.rating-star:hover { transform: scale(1.12); }
.rating-star.on { color: #f5b301; }
.rating-text {
  width: 100%; box-sizing: border-box; resize: none;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg);
}
.rating-text:focus { outline: none; border-color: var(--accent); }
.rating-submit { align-self: stretch; }
.rating-thanks { margin: 0; font-weight: 600; font-size: 15px; color: var(--good); text-align: center; }
.rating-err { margin: 0; }
.feedback-modal-body { padding: 4px 2px 2px; }

@media (max-width: 560px) {
  body { font-size: 15px; }
  .hero h2 { font-size: 24px; }
  .login-card { padding: 28px 20px; }
  .thread { padding: 20px 12px 30px; }
  .composer-wrap { padding: 8px 12px 12px; }
  .composer { padding: 8px 8px 8px 14px; }
  .msg-user .bubble { max-width: 90%; }
}
