/* Kiafarin smart assistant — public chat and sign-in pages.
   Brand: clinic turquoise #256C78/#3591A0/#48B7C0 + coral #F79489 (kiafarinclinic.com, logo), club ivory and
   champagne gold (vip.kiafarinclinic.com). System of tokens, light + dark, RTL first, motion only on transform/opacity
   and switched off for «reduce motion». */
@font-face { font-family: "Vazirmatn"; src: url("/static/Vazirmatn-wght.woff2") format("woff2"); font-weight: 100 900;
  font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }

:root {
  --bg: #FBF8F3; --bg-2: #F3EEE5; --surface: #FFFFFF; --surface-2: #F7F3EC; --ink: #1B2A30; --muted: #66747C;
  --line: #E8E0D2; --line-2: #F0EAE0;
  --teal: #256C78; --teal-2: #3591A0; --aqua: #48B7C0; --teal-soft: #E4F2F3; --teal-ink: #17505A;
  --coral: #F79489; --coral-d: #E0786C; --coral-soft: #FDEDEA;
  --gold-1: #F6E7BD; --gold-3: #C9A24D; --gold-5: #6E5120;
  --goldgrad: linear-gradient(135deg, #FBF0CF 0%, #E8CF8A 28%, #C9A24D 52%, #F3DFA6 70%, #B88F3E 100%);
  --brandgrad: linear-gradient(135deg, #48B7C0 0%, #256C78 55%, #1B4F59 100%);
  --orbgrad: conic-gradient(from 200deg, #F79489, #F6B2A9, #48B7C0, #256C78, #F79489);
  --ok: #2F7D4F; --warn: #9A6A12; --bad: #B3362A; --bad-soft: #FBECEA;
  --r-lg: 22px; --r-md: 16px; --r-sm: 12px;
  --shadow: 0 18px 44px rgba(27, 42, 48, .10); --shadow-s: 0 6px 18px rgba(27, 42, 48, .08);
  --font: Vazirmatn, system-ui, -apple-system, "Segoe UI", Roboto, Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1417; --bg-2: #121C20; --surface: #152126; --surface-2: #1A282E; --ink: #E6EEF0; --muted: #93A4AB;
    --line: #24343A; --line-2: #1E2D33;
    --teal: #5FC3CC; --teal-2: #48B7C0; --aqua: #7FD3DA; --teal-soft: #15343A; --teal-ink: #A6E3E8;
    --coral: #F79489; --coral-d: #F79489; --coral-soft: #3A2220;
    --gold-1: #3A3020; --gold-5: #F0D58F; --bad-soft: #3A1714; --bad: #FF8A7E;
    --shadow: 0 18px 44px rgba(0, 0, 0, .35); --shadow-s: 0 6px 18px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 15.5px/1.9 var(--font); color: var(--ink); -webkit-font-smoothing: antialiased;
  background: radial-gradient(900px 520px at 100% -8%, rgba(72, 183, 192, .16), transparent 60%),
              radial-gradient(700px 480px at -10% 105%, rgba(247, 148, 137, .14), transparent 60%), var(--bg);
  background-attachment: fixed; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--teal); }
bdi { unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); } .small { font-size: 13px; }
:focus-visible { outline: 2.5px solid var(--aqua); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- buttons */
.k-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  border-radius: 999px; padding: 10px 20px; font-weight: 700; text-decoration: none; white-space: nowrap;
  background: var(--brandgrad); color: #fff; box-shadow: 0 10px 24px rgba(37, 108, 120, .25);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s; }
.k-btn:hover { transform: translateY(-1px); filter: saturate(1.1); }
.k-btn:active { transform: translateY(0); }
.k-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.k-btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.k-btn.coral { background: linear-gradient(135deg, #F9A79E, #F07F72); box-shadow: 0 10px 24px rgba(240, 127, 114, .30); }
.k-btn.gold { background: var(--goldgrad); color: #2A2112; box-shadow: 0 10px 26px rgba(201, 162, 77, .38); }
.k-btn.small { padding: 6px 14px; font-size: 13.5px; }
.k-icon { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink); transition: background .2s; }
.k-icon:hover { background: var(--surface-2); }
.k-icon svg { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- header */
.k-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.5) blur(14px);
  -webkit-backdrop-filter: saturate(1.5) blur(14px); border-bottom: 1px solid var(--line-2); }
.k-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.k-brand img { width: 38px; height: 38px; border-radius: 12px; background: #fff; padding: 3px; box-shadow: var(--shadow-s); }
.k-brand b { display: block; font-size: 16px; line-height: 1.2; letter-spacing: -.2px; }
.k-brand span { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }
.k-spacer { flex: 1; }
.k-quota { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.k-quota .ring { --p: 100; width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(var(--teal-2) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; }
.k-quota .ring::after { content: ""; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); }
.k-quota .sm { display: none; }
@media (max-width: 640px) { .k-quota .sm { display: inline; } }
.k-quota.low .ring { background: conic-gradient(var(--coral) calc(var(--p) * 1%), var(--line) 0); }
.k-plan { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--teal-soft); color: var(--teal-ink); white-space: nowrap; }
.k-plan.gold { background: var(--goldgrad); color: #2A2112; }
.k-plan.doc { background: var(--brandgrad); color: #fff; }
.k-menu { position: relative; }
.k-avatar { width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; font-weight: 800; color: #fff;
  background: var(--brandgrad); box-shadow: var(--shadow-s); }
.k-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 6px; z-index: 30;
  animation: pop .16s ease-out; transform-origin: top left; }
.k-pop .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.k-pop .who b { display: block; }
.k-pop button, .k-pop a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: 10px;
  background: none; cursor: pointer; text-align: start; text-decoration: none; color: var(--ink); font-size: 14.5px; }
.k-pop button:hover, .k-pop a:hover { background: var(--surface-2); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- layout */
.k-app { display: flex; flex-direction: column; min-height: 100%; overflow-x: clip; }
html, body { overflow-x: hidden; }
.k-main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 18px 16px 200px; }
.k-drawer { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(340px, 88vw); z-index: 40; background: var(--surface);
  border-inline-end: 1px solid var(--line); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px;
  transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
.k-drawer.open { transform: none; visibility: visible; transition: transform .25s ease; }
.k-drawer h3 { margin: 4px 0; font-size: 15px; }
.k-scrim { position: fixed; inset: 0; background: rgba(10, 20, 24, .35); z-index: 35; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.k-convs { overflow-y: auto; overflow-x: hidden; display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); }
.k-conv { display: flex; align-items: center; gap: 6px; border-radius: 12px; padding: 8px 10px; cursor: pointer; border: 1px solid transparent; }
.k-conv:hover { background: var(--surface-2); }
.k-conv.active { background: var(--teal-soft); border-color: color-mix(in srgb, var(--teal-2) 30%, transparent); }
.k-conv span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.k-conv button { border: 0; background: none; color: var(--muted); cursor: pointer; opacity: 0; padding: 2px 6px; border-radius: 6px; }
.k-conv:hover button { opacity: 1; }

/* ---------------------------------------------------------------- welcome */
.k-hero { text-align: center; padding: 6vh 4px 8px; animation: rise .5s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.k-orb { width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 50%; position: relative; display: grid; place-items: center;
  background: var(--orbgrad); box-shadow: 0 20px 50px rgba(53, 145, 160, .35); animation: spin 14s linear infinite; }
.k-orb::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); }
.k-orb img { position: relative; width: 52px; height: 52px; animation: spin 14s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.k-hero h1 { font-size: clamp(22px, 4.6vw, 30px); margin: 0 0 6px; letter-spacing: -.4px; line-height: 1.5; }
.k-hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--coral-d), var(--teal-2)); -webkit-background-clip: text;
  background-clip: text; color: transparent; }
.k-hero p { margin: 0 auto; max-width: 560px; color: var(--muted); }
.k-trust { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin: 16px 0 22px; font-size: 13px; color: var(--muted); }
.k-trust span { display: inline-flex; align-items: center; gap: 6px; }
.k-trust i { width: 8px; height: 8px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 0 4px var(--teal-soft); }
.k-topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 12px; text-align: start; }
.k-topic { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; cursor: pointer;
  box-shadow: var(--shadow-s); transition: transform .18s ease, border-color .2s, box-shadow .2s; text-align: start; }
.k-topic:hover { transform: translateY(-2px); border-color: var(--aqua); box-shadow: var(--shadow); }
.k-topic .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 8px; font-size: 20px;
  background: var(--teal-soft); }
.k-topic:nth-child(2n) .ic { background: var(--coral-soft); }
.k-topic b { display: block; font-size: 15px; }
.k-topic span { font-size: 13px; color: var(--muted); }
.k-samples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.k-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer;
  font-size: 14px; color: var(--ink); transition: border-color .2s, color .2s, transform .15s; animation: rise .35s ease-out both; }
.k-chip:hover { border-color: var(--teal-2); color: var(--teal); transform: translateY(-1px); }

/* ---------------------------------------------------------------- messages */
.k-thread { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.k-msg { display: flex; gap: 10px; align-items: flex-start; animation: rise .3s ease-out both; min-width: 0; }
.k-msg.user { justify-content: flex-end; }
.k-msg.user.fa { justify-content: flex-start; }  /* Persian question: on the right of the right-to-left page */
.k-msg.user.en .k-bubble { border-radius: 20px 20px 20px 6px; }
.k-bubble { max-width: min(82%, 640px); padding: 11px 16px; border-radius: 20px 20px 6px 20px; background: var(--brandgrad); color: #fff;
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 10px 22px rgba(37, 108, 120, .18); unicode-bidi: plaintext; text-align: start; }
.k-bot { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: #fff; display: grid; place-items: center;
  box-shadow: var(--shadow-s); border: 1px solid var(--line); }
.k-bot img { width: 22px; height: 22px; }
.k-card { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px 22px 22px 22px;
  padding: 16px 18px; box-shadow: var(--shadow-s); }
.k-card .body { overflow-wrap: anywhere; }
.k-card .body p { margin: 0 0 10px; }
.k-card .body p:last-child { margin-bottom: 0; }
.k-card .body ul, .k-card .body ol { margin: 4px 0 10px; padding: 0; padding-inline-start: 22px; }
.k-card .body li { margin: 2px 0; }
.k-card .body li::marker { color: var(--teal-2); }
.k-card .body h4 { margin: 14px 0 4px; font-size: 15.5px; color: var(--teal); }
.k-card .body strong { color: var(--ink); }
.k-card .body p > strong:only-child { display: block; margin-top: 12px; color: var(--teal); font-size: 15.5px; }
.k-card .body code { background: var(--surface-2); padding: 0 5px; border-radius: 6px; font-size: 13px; }
.cite { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin: 0 2px; border: 0;
  border-radius: 999px; background: var(--teal-soft); color: var(--teal-ink); font: 800 11px/1 var(--font); cursor: pointer;
  vertical-align: 3px; transition: background .2s, transform .15s; }
.cite:hover { background: var(--teal-2); color: #fff; transform: translateY(-1px); }
.k-emergency { display: flex; gap: 10px; align-items: flex-start; background: var(--bad-soft); color: var(--bad); border-radius: var(--r-sm);
  padding: 10px 12px; margin-bottom: 12px; font-weight: 700; }

/* thinking: live progress log */
.k-live { display: grid; gap: 10px; }
.k-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; line-height: 1.8; }
.k-log li { position: relative; padding-inline-start: 20px; color: var(--muted); overflow-wrap: anywhere; animation: rise .25s ease-out both; }
.k-log li::before { content: ""; position: absolute; inset-inline-start: 4px; top: .72em; width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal-2); opacity: .55; }
.k-log li.now { color: var(--teal); font-weight: 700; }
.k-log li.now::before { background: var(--aqua); opacity: 1; animation: pulse 1.1s ease-in-out infinite; }
.k-log li.sub { padding-inline-start: 28px; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.k-log li.sub::before { display: none; }
.k-hint { margin: 0; min-height: 1.8em; font-size: 13px; color: var(--teal-ink); opacity: 0; transform: translateY(4px);
  transition: opacity .25s, transform .25s; padding-inline-start: 20px; }
.k-hint.in { opacity: .85; transform: none; }
.k-live-foot { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.k-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--aqua); animation: pulse 1.1s ease-in-out infinite; }
.k-timer { font-variant-numeric: tabular-nums; }
  padding: 3px 12px; font: inherit; cursor: pointer; transition: color .2s, border-color .2s; }
@media (prefers-reduced-motion: reduce) { .k-log li, .k-hint { animation: none; transition: none; } }
@keyframes pulse { 50% { transform: scale(1.6); opacity: .5; } }
.k-skel { height: 12px; border-radius: 999px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 40%, var(--surface-2) 80%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.k-skel.w2 { width: 86%; } .k-skel.w3 { width: 64%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* references (inside the answer, never in a side panel) */
.k-refs { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.k-refs summary { cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--teal); list-style: none; display: flex; align-items: center; gap: 6px; }
.k-refs summary::-webkit-details-marker { display: none; }
.k-refs summary::after { content: "⌄"; transition: transform .2s; }
.k-refs[open] summary::after { transform: rotate(180deg); }
.k-refs ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; counter-reset: ref; }
.k-ref { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 8px 10px; border-radius: var(--r-sm);
  transition: background .3s; scroll-margin-top: 90px; }
.k-ref.flash { background: var(--teal-soft); }
.k-ref .n { min-width: 22px; height: 22px; border-radius: 999px; background: var(--teal-soft); color: var(--teal-ink); font-weight: 800;
  font-size: 12px; display: grid; place-items: center; }
.k-ref .t { font-size: 13.5px; line-height: 1.8; }
.k-ref .t cite { font-style: normal; font-weight: 700; }
.k-ref .loc { display: block; color: var(--muted); font-size: 12.5px; }
.k-ref details { margin-top: 4px; }
.k-ref details summary { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.k-ref details summary::after { content: none; }
.k-ref .ex { white-space: pre-wrap; font-size: 12.5px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-top: 6px; max-height: 260px; overflow: auto; }
.k-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.k-actions button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 12.5px;
  cursor: pointer; color: var(--muted); }
.k-actions button:hover { color: var(--teal); border-color: var(--teal-2); }
.k-note { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.k-err { color: var(--bad); }

/* ---------------------------------------------------------------- composer */
.k-dock { position: fixed; bottom: 0; inset-inline: 0; z-index: 15; padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 62%, transparent); }
.k-compose { max-width: 860px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 26px; padding: 8px 8px 8px 8px; box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s; }
.k-compose:focus-within { border-color: var(--aqua); box-shadow: 0 0 0 4px var(--teal-soft), var(--shadow); }
.k-compose textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; padding: 9px 12px; min-height: 44px;
  max-height: 180px; line-height: 1.8; unicode-bidi: plaintext; overflow-y: hidden; }
.k-send { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: linear-gradient(135deg, #F9A79E, #F07F72); color: #fff; box-shadow: 0 8px 20px rgba(240, 127, 114, .35);
  transition: transform .15s, opacity .2s; }
.k-send:hover { transform: scale(1.05); }
.k-send:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.k-send svg { width: 20px; height: 20px; transform: scaleX(-1); }
.k-dockinfo { max-width: 860px; margin: 6px auto 0; display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

/* upsell / limit card */
.k-limit { width: 100%; margin: 4px 0 0; border-radius: var(--r-lg); padding: 18px 20px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 10px; animation: rise .35s ease-out both; }
.k-limit.club { background: linear-gradient(160deg, #FFFBF1, #FBF1DA); border-color: #EAD7A6; color: #2A2112; }
@media (prefers-color-scheme: dark) { .k-limit.club { background: linear-gradient(160deg, #2A2418, #1E1A12); border-color: #4A3D22; color: var(--ink); } }
.k-limit h3 { margin: 0; font-size: 17px; }
.k-limit ul { margin: 0; padding-inline-start: 20px; font-size: 14px; }
.k-limit .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- sign-in sheet */
.k-sheet { border: 0; padding: 0; overflow: visible; max-height: calc(100dvh - 24px); background: transparent; width: min(440px, calc(100% - 24px)); max-width: none; color: var(--ink); }
.k-sheet::backdrop { background: rgba(10, 20, 24, .45); backdrop-filter: blur(3px); }
.k-sheet .in { position: relative; background: var(--surface); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--line);
  animation: rise .25s ease-out both; }
.k-sheet h2 { margin: 0 0 4px; font-size: 19px; }
.k-sheet p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.k-field { display: grid; gap: 6px; margin: 10px 0; font-size: 13.5px; color: var(--muted); }
.k-field input { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface-2); color: var(--ink);
  font-size: 16px; transition: border-color .2s, box-shadow .2s; }
.k-field input:focus { outline: 0; border-color: var(--aqua); box-shadow: 0 0 0 4px var(--teal-soft); }
.k-field input.code { letter-spacing: 10px; text-align: center; font-size: 22px; font-weight: 800; }
.k-sheet .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 12px; }
.k-sheet .full { width: 100%; }
.k-msgline { min-height: 22px; font-size: 13.5px; }
.k-msgline.err { color: var(--bad); }
.k-msgline.ok { color: var(--ok); }
.k-linkbtn { border: 0; background: none; color: var(--teal); cursor: pointer; padding: 0; font-weight: 600; }
.k-linkbtn:disabled { color: var(--muted); cursor: default; }
.k-x { position: absolute; inset-inline-end: 14px; top: 12px; }

/* sign-in page */
.k-login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.k-login .in { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 26px 24px; box-shadow: var(--shadow); }
.k-login .k-brand { margin-bottom: 18px; }

.k-toast { position: fixed; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* ---------------------------------------------------------------- tables in answers */
.mdtable-wrap { overflow-x: auto; margin: 10px 0 12px; border: 1px solid var(--line); border-radius: 14px; max-width: 100%; }
.mdtable { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; line-height: 1.7; }
.mdtable th, .mdtable td { text-align: start; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line-2); min-width: 7em; max-width: 28em; }
.mdtable thead th { background: var(--teal-soft); color: var(--teal-ink); font-weight: 800; font-size: 13.5px; white-space: nowrap; position: sticky; top: 0; }
.mdtable tbody th { font-weight: 700; background: var(--surface); position: sticky; inset-inline-start: 0; }
.mdtable tbody tr:nth-child(even) > * { background: var(--surface-2); }
.mdtable tbody tr:last-child > * { border-bottom: 0; }
.mdtable .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 600px) {
  .mdtable-wrap { border: 0; overflow: visible; }
  .mdtable, .mdtable tbody, .mdtable tr, .mdtable th, .mdtable td { display: block; width: 100%; max-width: none; min-width: 0; }
  .mdtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .mdtable tbody tr { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; overflow: hidden; }
  .mdtable tbody th { position: static; background: var(--teal-soft) !important; color: var(--teal-ink); }
  .mdtable tbody td { white-space: normal; }
  .mdtable tbody td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-weight: 600; font-size: 12px; }
  .mdtable tbody tr:nth-child(even) td { background: var(--surface); }
}

/* ---------------------------------------------------------------- small screens */
@media (max-width: 640px) {
  .k-top { padding: 8px 12px; gap: 8px; }
  .k-brand b { font-size: 14px; white-space: nowrap; }
  .k-brand img { width: 34px; height: 34px; }
  .k-quota .lg { display: none; }
  .k-quota { padding: 3px 10px 3px 4px; }
  .k-topics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .k-topic { padding: 12px; }
  .k-topic span { display: none; }
  .k-trust { gap: 4px 12px; font-size: 12px; }
  .k-dockinfo { font-size: 11.5px; }
  .k-brand span { display: none; }
  .k-plan { display: none; }
  .k-main { padding: 12px 12px 190px; }
  .k-card { padding: 14px; }
  .k-bot { display: none; }
  .k-bubble { max-width: 92%; }
  .k-hero { padding-top: 3vh; }
}
.k-btn.full { width: 100%; }
.k-topic[aria-pressed="true"] { border-color: var(--aqua); box-shadow: 0 0 0 3px var(--teal-soft), var(--shadow-s); }

/* running question in the conversation list */
.k-conv.running span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-inline-end: 6px; border-radius: 50%;
  background: var(--aqua); vertical-align: 2px; animation: pulse 1.1s ease-in-out infinite; }
/* the answer while it is being written */
.k-live.drafting .k-log li:not(:last-child), .k-live.drafting .k-skel, .k-live.drafting .k-hint { display: none; }
.k-draft { border-top: 1px dashed var(--line); padding-top: 10px; }
.k-caret { display: inline-block; width: 2px; height: 1.1em; margin-inline-start: 2px; vertical-align: -3px; background: var(--teal-2);
  animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
/* send button turns into "stop" while a question is answered */
.k-send.stop { background: var(--surface); color: var(--bad); border: 2px solid var(--bad); box-shadow: none; }
.k-send.stop svg { transform: none; fill: currentColor; }
/* doctors: answer depth and sources */
.k-opts { max-width: 860px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.k-segs { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.k-seg { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.k-seg.on { background: var(--teal-soft); color: var(--teal-ink); font-weight: 700; }
.k-seg.src { border: 1px solid var(--line); background: var(--surface); }
.k-srcpop { position: fixed; inset-inline: 16px; max-width: 520px; margin-inline: auto; z-index: 40; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 12px; display: grid; gap: 8px; max-height: 60vh; }
.k-srchead { display: flex; justify-content: space-between; align-items: center; }
.k-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; }
.k-srcpop input[type=search] { border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font: inherit; font-size: 13.5px; }
.k-srclist { overflow-y: auto; display: grid; gap: 2px; }
.k-srcitem { display: flex; gap: 8px; align-items: flex-start; padding: 5px 6px; border-radius: 8px; font-size: 13.5px; cursor: pointer; }
.k-srcitem:hover { background: var(--surface-2); }
.k-srcitem.all { font-weight: 700; }

/* next step under an answer (offers.py): quiet, same voice as the answer, always with «no, thanks» */
.k-next { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--teal-soft); border-inline-start: 3px solid var(--aqua); }
.k-next .h { font-size: 12.5px; font-weight: 700; color: var(--teal); margin-bottom: 4px; }
.k-next .t { margin: 0 0 10px; line-height: 1.95; font-size: 14px; }
.k-next .b { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.k-next-go { border: 0; border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  background: var(--teal); color: #fff; text-decoration: none; }
.k-next-go:hover { background: var(--teal-2); }
.k-next-no { border: 0; background: none; color: var(--muted, #75695A); font: inherit; font-size: 13px; cursor: pointer; padding: 6px 4px; }
.k-next-no:hover { text-decoration: underline; }

/* figures of the books inside answers */
.k-fig { margin: 12px 0; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.k-fig img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 10px; background: #fff; }
.k-fig figcaption { margin-top: 6px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.k-fig figcaption .n { font-weight: 800; color: var(--teal-ink); }
.k-fig figcaption .src { color: var(--muted); }
