/* ============================================================================
   Kindred — components.css
   Buttons, chips, avatars, cards, toggles, fields, modals, sheets, toasts,
   skeletons, empty states, badges, tabs, progress dots, FAB, banners.
   ========================================================================== */

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--primary); --btn-fg: var(--text-on-brand); --btn-bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 10px var(--sp-5);
  font: inherit; font-weight: var(--fw-medium); font-size: var(--fs-base);
  color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-bd);
  border-radius: var(--r-pill); cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur) var(--ease);
  box-shadow: var(--shadow-sm);
  text-align: center; text-decoration: none; user-select: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); box-shadow: var(--shadow-xs); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { --btn-bg: linear-gradient(135deg, var(--c-coral-400), var(--c-coral-600)); }
.btn.secondary { --btn-bg: var(--secondary-soft); --btn-fg: var(--secondary); --btn-bd: transparent; box-shadow: none; }
.btn.ghost { --btn-bg: transparent; --btn-fg: var(--text-soft); --btn-bd: var(--border-strong); box-shadow: none; }
.btn.ghost:hover { --btn-bg: var(--surface-3); }
.btn.quiet { --btn-bg: transparent; --btn-fg: var(--text-soft); --btn-bd: transparent; box-shadow: none; padding-inline: var(--sp-3); }
.btn.quiet:hover { --btn-bg: var(--surface-3); text-decoration: none; }
.btn.danger { --btn-bg: var(--danger-soft); --btn-fg: var(--c-rose-600); --btn-bd: transparent; box-shadow: none; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px var(--sp-4); font-size: var(--fs-sm); }
.btn.lg { min-height: 52px; padding: 14px var(--sp-7); font-size: var(--fs-md); }
.btn .ico { font-size: 1.05em; line-height: 1; }
.btn.loading { color: transparent !important; position: relative; }
.btn.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45); border-top-color: #fff; animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); border-radius: var(--r-pill);
  background: transparent; border: 0; color: var(--text-soft); cursor: pointer;
  font-size: 1.15rem; position: relative; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 36px; height: 36px; font-size: 1rem; }

/* ------------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill); font-size: var(--fs-sm);
  background: var(--surface-3); color: var(--text-soft); border: 1px solid transparent;
  line-height: 1.35; white-space: nowrap; max-width: 100%;
}
.chip .chip-count { font-size: var(--fs-xs); color: var(--text-muted); }
button.chip, .chip.interactive { cursor: pointer; font: inherit; font-size: var(--fs-sm); min-height: 34px; transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur-fast) var(--ease); }
button.chip:hover, .chip.interactive:hover { transform: translateY(-1px); }
.chip[aria-pressed="true"], .chip.selected {
  background: var(--primary-soft); color: var(--primary-strong);
  border-color: color-mix(in srgb, var(--primary) 35%, transparent); font-weight: var(--fw-medium);
}
.chip.shared { background: var(--secondary-soft); color: var(--secondary); font-weight: var(--fw-medium); }
.chip.tone-accent { background: var(--accent-soft); color: var(--c-lav-600); }
.chip.tone-success { background: var(--success-soft); color: var(--c-sage-600); }
.chip.tone-warning { background: var(--warning-soft); color: var(--c-amber-600); }
.chip.tone-danger { background: var(--danger-soft); color: var(--c-rose-600); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chips-scroll { display: flex; gap: var(--sp-2); overflow-x: auto; padding: var(--sp-1) 2px var(--sp-2); scrollbar-width: none; }
.chips-scroll::-webkit-scrollbar { display: none; }

/* ----------------------------------------------------------------- avatars */
.avatar {
  --av: 40px; --av-bg: var(--c-coral-400); --av-fg: #fff;
  width: var(--av); height: var(--av); flex: 0 0 auto; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--av-bg); color: var(--av-fg); font-weight: var(--fw-bold);
  font-size: calc(var(--av) * 0.42); position: relative; user-select: none;
  box-shadow: inset 0 -6px 12px rgba(0,0,0,0.06);
}
.avatar .av-emoji { font-size: calc(var(--av) * 0.5); line-height: 1; }
.avatar.lg { --av: 56px; } .avatar.xl { --av: 84px; } .avatar.sm { --av: 30px; } .avatar.xs { --av: 24px; }
.avatar.ring { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--secondary); }
.avatar.online::after {
  content: ""; position: absolute; right: -1px; bottom: -1px;
  width: calc(var(--av) * 0.28); height: calc(var(--av) * 0.28); min-width: 10px; min-height: 10px;
  border-radius: 50%; background: var(--c-sage-500); border: 2px solid var(--surface);
}
.avatar.square { border-radius: var(--r-md); }
.avatar-picker { display: flex; gap: var(--sp-3); overflow-x: auto; padding: var(--sp-2) 2px; }
.avatar-picker .avatar { cursor: pointer; border: 3px solid transparent; transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.avatar-picker .avatar[aria-pressed="true"] { border-color: var(--primary); transform: scale(1.06); }
.avatar-palette { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: var(--text); }
.av-stack { display: flex; }
.av-stack .avatar { margin-left: -10px; border: 2px solid var(--surface); }
.av-stack .avatar:first-child { margin-left: 0; }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: var(--sp-5); box-shadow: var(--shadow-sm);
}
.card.tight { padding: var(--sp-4); }
.card.flush { padding: 0; overflow: hidden; }
/* A flush card removes its own padding so lists can run edge to edge. Its
   heading and any direct text must keep the card's inset, or they touch the
   border (this is what made section titles spill past the card on Today). */
.card.flush > .card-head { padding: var(--sp-4) var(--sp-4) var(--sp-2); margin: 0; flex-wrap: wrap; }
.card.flush > .card-head > div:first-child { min-width: 0; flex: 1 1 200px; }
.card.flush > :not(.card-head):not(.chatlist):not(.chat-list):not(.thought-list):not(.card-list):not(.flush-list) { margin-left: var(--sp-4); margin-right: var(--sp-4); }
.card.flush > .card-head > .btn { flex: 0 0 auto; }
.card.quiet { box-shadow: none; background: var(--surface-2); }
.card.tinted { background: linear-gradient(160deg, var(--primary-soft), var(--surface) 70%); }
.card.hoverable { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card.hoverable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.card-title { font-weight: var(--fw-bold); margin: 0; font-size: var(--fs-md); }
.card-sub { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
.card-note { color: var(--text-soft); font-size: var(--fs-sm); margin-top: var(--sp-2); }
.card-actions { display: flex; gap: var(--sp-2); align-items: center; margin-top: var(--sp-4); flex-wrap: wrap; }
.card-list { display: flex; flex-direction: column; gap: var(--sp-3); }

/* tinted soft panels used for guidance / wellbeing */
.panel-soft { border-radius: var(--r-lg); padding: var(--sp-4); background: var(--surface-2); border: 1px dashed var(--border-strong); }
.panel-warm { background: linear-gradient(150deg, var(--primary-soft), var(--surface) 58%, var(--secondary-soft)); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-5); }
[data-theme="dark"] .panel-warm { background: linear-gradient(150deg, var(--primary-soft), var(--surface) 58%, var(--secondary-soft)); }
[data-theme="calm"] .panel-warm { background: var(--surface-2); }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; min-width: 20px; height: 20px; padding: 0 7px;
  border-radius: var(--r-pill); background: var(--primary); color: #fff;
  font-size: 11.5px; font-weight: var(--fw-bold); line-height: 1; justify-content: center;
}
.badge.soft { background: var(--surface-3); color: var(--text-soft); }
.badge.verified { background: var(--secondary); }
.badge.heart { background: var(--primary-soft); color: var(--primary-strong); }
.badge.flame { background: var(--warning-soft); color: var(--c-amber-600); }
.role-tag { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: var(--fw-bold); padding: 3px 8px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--c-lav-600); }

/* ----------------------------------------------------------------- toggles */
.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; min-height: var(--tap); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 50px; height: 30px; border-radius: var(--r-pill); background: var(--border-strong);
  position: relative; flex: 0 0 auto; transition: background var(--dur) var(--ease);
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease);
}
.switch input:checked + .track { background: linear-gradient(135deg, var(--c-sage-500), var(--secondary)); }
.switch input:checked + .track .thumb { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: var(--focus-ring); }
.switch input:disabled + .track { opacity: 0.5; }
.switch .switch-label { font-weight: var(--fw-medium); }
.switch.lg .track { width: 60px; height: 34px; } .switch.lg .thumb { width: 28px; height: 28px; } .switch.lg input:checked + .track .thumb { transform: translateX(26px); }

.setting-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); min-height: 56px; }
.setting-row:last-child { border-bottom: 0; }
/* The label column must be allowed to shrink and wrap on word boundaries, and
   the control must not shrink at all — without both, a select squeezed the
   label down to one character per line. */
.setting-row .setting-text { min-width: 0; flex: 1 1 auto; overflow-wrap: break-word; }
.setting-row .setting-label { line-height: 1.35; }
.setting-row > .select, .setting-row > .switch, .setting-row > .btn, .setting-row > .toggle { flex: 0 0 auto; max-width: 46%; }
.setting-row > .select { min-width: 150px; }
@media (max-width: 420px) {
  /* On a narrow phone a side-by-side control gets too tight; stack instead. */
  .setting-row { flex-wrap: wrap; }
  .setting-row .setting-text { flex: 1 1 100%; }
  .setting-row > .select { max-width: 100%; width: 100%; min-width: 0; }
}
.setting-row .setting-label { font-weight: var(--fw-medium); }
.setting-row .setting-help { color: var(--text-muted); font-size: var(--fs-sm); margin: 2px 0 0; }

/* ------------------------------------------------------------------ fields */
.field { display: block; margin-bottom: var(--sp-4); }
.field > .field-label { display: block; font-weight: var(--fw-medium); margin-bottom: 6px; }
.field .help { color: var(--text-muted); font-size: var(--fs-sm); margin: 6px 0 0; }
.input, .textarea, .select {
  width: 100%; min-height: var(--tap); padding: 11px var(--sp-4); font: inherit; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: var(--r-lg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: var(--focus-ring); outline: none; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 110px; resize: vertical; line-height: var(--lh-body); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: var(--sp-7); }
.field-error { color: var(--c-rose-600); font-size: var(--fs-sm); margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.input-group { display: flex; gap: var(--sp-2); align-items: stretch; }
.input-group .input { flex: 1; }
.char-count { font-size: var(--fs-xs); color: var(--text-muted); text-align: right; margin-top: 4px; }
.char-count.warn { color: var(--c-amber-600); font-weight: var(--fw-medium); }
.char-count.over { color: var(--c-rose-600); font-weight: var(--fw-bold); }
.check { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-2) 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); flex: 0 0 auto; }
.check .check-text { font-size: var(--fs-sm); color: var(--text-soft); }
fieldset { border: 0; padding: 0; margin: 0 0 var(--sp-5); }
legend { font-weight: var(--fw-bold); margin-bottom: var(--sp-2); }

/* ------------------------------------------------------------------ modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150; background: rgba(52, 36, 30, 0.42);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4); animation: fadeIn var(--dur) var(--ease); overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--surface); border-radius: var(--r-2xl); box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: min(88dvh, 900px); display: flex; flex-direction: column;
  animation: popIn var(--dur-slow) var(--ease-out); border: 1px solid var(--border);
}
.modal.wide { width: min(860px, 100%); }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(0.98) } to { opacity: 1; transform: none } }
.modal-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-2); }
.modal-head h2, .modal-head h3 { margin: 0; flex: 1; font-size: var(--fs-lg); }
.modal-body { padding: var(--sp-2) var(--sp-5) var(--sp-5); overflow-y: auto; }
.modal-foot { display: flex; gap: var(--sp-2); justify-content: flex-end; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot.stack-mobile { flex-direction: column-reverse; }
.modal-foot.stack-mobile .btn { width: 100%; }
@media (min-width: 700px) { .modal-foot.stack-mobile { flex-direction: row; } .modal-foot.stack-mobile .btn { width: auto; } }

.sheet-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(52,36,30,0.42); animation: fadeIn var(--dur) var(--ease); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 151;
  background: var(--surface); border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  box-shadow: var(--shadow-lg); padding: var(--sp-4) var(--sp-5) calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
  max-height: 88dvh; overflow-y: auto; animation: sheetUp var(--dur-slow) var(--ease-out);
}
@keyframes sheetUp { from { transform: translateY(100%) } to { transform: none } }
.sheet::before { content: ""; display: block; width: 42px; height: 4px; border-radius: 999px; background: var(--border-strong); margin: 0 auto var(--sp-4); }
.sheet h3 { margin-bottom: var(--sp-2); }
@media (min-width: 900px) { .sheet { left: 50%; transform: translateX(-50%); right: auto; width: min(520px, 100%); border-radius: var(--r-2xl); bottom: var(--sp-5); animation: popIn var(--dur-slow) var(--ease-out); } }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list button, .menu-list a {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; text-align: left;
  min-height: var(--tap); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  background: transparent; border: 0; font: inherit; color: var(--text); cursor: pointer;
}
.menu-list button:hover, .menu-list a:hover { background: var(--surface-3); text-decoration: none; }
.menu-list .danger-text { color: var(--c-rose-600); }
.menu-list .ico { width: 22px; text-align: center; font-size: 1.05rem; }

/* ------------------------------------------------------------------ toasts */
.toast-region {
  position: fixed; z-index: 200; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 76px);
  display: flex; flex-direction: column-reverse; gap: var(--sp-2); width: min(440px, 92vw); pointer-events: none;
}
@media (min-width: 900px) { .toast-region { bottom: var(--sp-6); left: auto; right: var(--sp-6); transform: none; } }
.toast {
  pointer-events: auto; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--secondary); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: var(--sp-3) var(--sp-4); display: flex; gap: var(--sp-3); align-items: flex-start;
  animation: toastIn var(--dur-slow) var(--ease-out);
}
.toast.tone-warm { border-left-color: var(--primary); }
.toast.tone-caution { border-left-color: var(--warning); }
.toast.tone-soft { border-left-color: var(--border-strong); }
.toast.leaving { animation: toastOut var(--dur) var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) } }
.toast .toast-text { font-size: var(--fs-sm); flex: 1; }
.toast .toast-title { font-weight: var(--fw-medium); }

/* --------------------------------------------------------------- skeletons */
.skeleton-card { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-avatar { width: 44px; height: 44px; border-radius: 50%; }
.sk-line { height: 12px; border-radius: 8px; }
.sk-line.w40 { width: 40% } .sk-line.w60 { width: 60% } .sk-line.w80 { width: 80% } .sk-line.w100 { width: 100% }
.sk-bubble { height: 42px; border-radius: var(--r-lg); margin-bottom: var(--sp-3); }

/* ------------------------------------------------------- empty / error view */
.empty {
  text-align: center; padding: var(--sp-8) var(--sp-4); display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-3); color: var(--text-soft);
}
.empty .empty-art { width: min(200px, 60vw); height: auto; margin-bottom: var(--sp-2); }
.empty h3 { margin: 0; }
.empty p { max-width: 42ch; margin: 0; }
.error-card { border-left: 4px solid var(--warning); }
.error-card .card-title { color: var(--c-amber-600); }

/* ------------------------------------------------------ progress & stepping */
.dots { display: flex; gap: 8px; align-items: center; justify-content: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); transition: all var(--dur) var(--ease); }
.dot.active { background: var(--primary); width: 26px; border-radius: 999px; }
.dot.done { background: var(--secondary); }
.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--c-coral-400), var(--c-teal-500)); transition: width var(--dur-slow) var(--ease); }
.ring { --pct: 0; --size: 56px; width: var(--size); height: var(--size); position: relative; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.ring .ring-bg { stroke: var(--surface-3); }
.ring .ring-fg { stroke: var(--secondary); stroke-dasharray: 151; stroke-dashoffset: calc(151 - (151 * var(--pct)) / 100); transition: stroke-dashoffset var(--dur-slow) var(--ease); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: var(--fw-bold); }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 0; font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  color: var(--text-muted); padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) - 2px); min-height: var(--tap);
  cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--primary-strong); border-bottom-color: var(--primary); }
.segmented { display: inline-flex; background: var(--surface-3); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  color: var(--text-soft); padding: 7px var(--sp-4); border-radius: var(--r-pill); cursor: pointer; min-height: 36px;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* -------------------------------------------------------------------- FAB */
.fab {
  position: fixed; z-index: 55; right: var(--sp-4);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--sp-4));
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 54px; padding: 0 var(--sp-5);
  border-radius: var(--r-pill); border: 0; cursor: pointer; font: inherit; font-weight: var(--fw-medium);
  color: #fff; background: linear-gradient(135deg, var(--c-coral-400), var(--c-coral-600));
  box-shadow: var(--shadow-lg); transition: transform var(--dur) var(--ease);
}
.fab:hover { transform: translateY(-2px) scale(1.02); }
@media (min-width: 900px) { .fab { bottom: var(--sp-6); right: var(--sp-7); } }

/* ---------------------------------------------------------------- banners */
.banner { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); font-size: var(--fs-sm); }
.banner.info { background: var(--secondary-soft); color: var(--text); }
.banner.warm { background: var(--primary-soft); color: var(--text); }
.banner.caution { background: var(--warning-soft); color: var(--text); }
.banner.critical { background: var(--danger-soft); color: var(--text); }
.banner .banner-ico { font-size: 1.15rem; line-height: 1.3; }
.banner strong { display: block; }
.banner .btn { margin-top: var(--sp-2); }

/* ------------------------------------------------------- misc small pieces */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); }
.stat .stat-num { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.1; }
.stat .stat-label { color: var(--text-muted); font-size: var(--fs-sm); }
.kv { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 7px 0; font-size: var(--fs-sm); border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: 0; }
.kv .kv-k { color: var(--text-muted); }
.quote { font-size: var(--fs-lg); line-height: 1.45; font-style: italic; color: var(--text-soft); }
.pill-note { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); padding: 4px 10px; border-radius: var(--r-pill); }
.dot-sep::before { content: "·"; margin: 0 6px; color: var(--text-muted); }
.meta-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-muted); }
.hr-soft { height: 1px; background: var(--border); border: 0; margin: var(--sp-4) 0; }
.tooltip-host { position: relative; }
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--c-ink-800); color: #fff; font-size: var(--fs-xs); padding: 5px 9px; border-radius: 8px;
  white-space: nowrap; z-index: 90; box-shadow: var(--shadow-md); pointer-events: none;
}

/* Tab rows scroll sideways instead of clipping their last tab on a phone. */
.tabs { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > * { flex: 0 0 auto; }
