/* Shared components for the production web apps. Look ported from src/web/style.css and src/web/coach/coach.css;
   colours only from tokens.css. Layout rules (STYLE_GUIDE): minmax(0, Nfr) tracks, labels with values, breakpoints
   reflow and never hide controls, targets >= 32 px (coach/admin) and >= 44 px (client). */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
.ic { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.ic .d { fill: currentColor; fill-opacity: 0.2; }
.ic .f { fill: currentColor; stroke: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Buttons */
.btn { min-height: 40px; padding: 0 16px; border-radius: 12px; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none; color: inherit; transition: filter var(--t-fast), transform var(--t-fast); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary-fill); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface-2); border: 1px solid var(--line); }
.btn.danger { background: color-mix(in srgb, var(--rose) 12%, transparent); color: var(--rose-ink); border: 1px solid color-mix(in srgb, var(--rose) 30%, transparent); }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.linkbtn { color: var(--primary); font-weight: 600; min-height: 32px; padding: 0 4px; }

/* Segmented control */
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.seg button { min-height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--dim); white-space: nowrap; }
.seg button.on { background: var(--elev); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), inset 0 0 0 1px color-mix(in srgb, var(--primary) 45%, transparent); }

/* Forms: every control has a visible label */
.flabel { display: block; font-size: 13px; font-weight: 600; color: var(--dim); margin: 12px 0 6px; }
.field-input { width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: 14px; }
textarea.field-input { resize: vertical; min-height: 72px; }
.field-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--tint); }
.field-input[aria-invalid="true"] { border-color: var(--rose); }
.ferr { color: var(--rose-ink); font-size: 13px; font-weight: 600; margin-top: 6px; }
.ferr:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary-fill); flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch:last-child { border-bottom: 0; }
.switch .sw-txt { min-width: 0; }
.switch .sw-txt b { display: block; font-size: 15px; font-weight: 600; }
.switch .sw-txt small { color: var(--dim); font-size: 12px; }
.switch input { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); position: relative; flex: none; cursor: pointer; transition: background var(--t-fast); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--elev); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform var(--t-fast); }
.switch input:checked { background: var(--primary-fill); }
.switch input:checked::after { transform: translateX(20px); }

/* Panels, cards, pills */
.panel { padding: 18px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 16px; min-width: 0; }
.panel > h2, .panel > h3 { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel > h2 small, .panel > h3 small { font-size: 12px; color: var(--dim); font-weight: 500; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--dim); }
.pill.ok { color: var(--teal-ink); background: color-mix(in srgb, var(--teal) 12%, transparent); }
.pill.warn { color: var(--honey-ink); background: color-mix(in srgb, var(--honey) 14%, transparent); }
.pill.bad { color: var(--rose-ink); background: color-mix(in srgb, var(--rose) 12%, transparent); }
.pill.accent { color: var(--primary-ink); background: var(--tint); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { color: var(--dim); font-size: 14px; text-align: center; padding: 22px 16px; border: 1px dashed var(--line); border-radius: 16px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--tint); color: var(--text); font-size: 14px; margin-bottom: 14px; }
.notice .ic { color: var(--primary); margin-top: 1px; }
.notice.warn { background: color-mix(in srgb, var(--honey) 14%, transparent); }
.notice.warn .ic { color: var(--honey); }
.notice.bad { background: color-mix(in srgb, var(--rose) 10%, transparent); }
.av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; color: var(--primary-ink); background: var(--tint); }
.av.sm { width: 28px; height: 28px; font-size: 11px; }
.av.lg { width: 56px; height: 56px; font-size: 20px; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--dim); }
.kv dd { font-weight: 600; text-align: right; font-family: var(--num); }

/* Account bar (header): name, mode switch, sign out */
.acct { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.acct-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; min-width: 0; }
.acct-name .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

/* Chat */
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; padding: 4px 2px 8px; }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 16px; font-size: 14px; background: var(--surface-2); align-self: flex-start; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.mine { align-self: flex-end; background: var(--primary-fill); color: var(--on-primary); }
.bubble small { display: block; font-size: 11px; opacity: 0.75; margin-top: 3px; }
.bubble .re { display: block; font-size: 11px; font-weight: 700; opacity: 0.8; margin-bottom: 2px; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; align-items: end; }

/* Dialog + toasts */
.dialog { margin: auto; border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: min(440px, calc(100vw - 32px)); background: var(--elev); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(5, 8, 15, 0.5); }
.dialog h2 { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.dialog p { font-size: 14px; }
.dlg-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 20px; right: 20px; left: auto; z-index: 70; display: grid; gap: 8px; pointer-events: none; max-width: calc(100vw - 40px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--elev); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 14px; font-weight: 600; animation: tin 300ms var(--ease-out); }
.toast .ic { color: var(--teal); }
.toast.bad .ic { color: var(--rose); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Spinner + landing (index.html, dev login) */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--primary); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.landing { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 10% -10%, var(--tint), transparent 60%), var(--bg); }
.landing-card { width: min(440px, 100%); padding: 28px; border-radius: 24px; background: var(--elev); border: 1px solid var(--line); box-shadow: var(--shadow); }
.landing-card .mark { width: 52px; height: 52px; border-radius: 15px; display: block; margin-bottom: 16px; }
.landing-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 6px; }
.landing-card p { margin-bottom: 18px; }
.landing-card .btn { width: 100%; min-height: 48px; font-size: 16px; }
.landing-card .fine { font-size: 12px; margin-top: 14px; }
/* REL-14 legal links (shared/legal.js): wrap, never overflow; each link keeps a 32 px target */
.legal { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 14px; font-size: 13px; }
.legal a { display: inline-flex; align-items: center; min-height: 32px; }
.legal .dim { font-size: 12px; flex-basis: 100%; }
/* Admin moderation queue (admin.js reports page) */
.quote { margin: 6px 0 2px; padding: 6px 10px; border-left: 3px solid var(--line); max-width: 360px; overflow-wrap: anywhere; font-size: 13px; }
.dim.over { color: var(--bad); font-weight: 600; }
.personas { list-style: none; display: grid; gap: 8px; }
.persona { display: grid; gap: 2px; padding: 12px 14px; min-height: 52px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.persona:hover { border-color: var(--primary); }
.persona span { font-size: 13px; color: var(--dim); }
