/* Serene Scan shared components. Uses only tokens from tokens.css. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--canvas);
  color: var(--text-body);
  font: 400 var(--fs-base)/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { color: var(--text-head); line-height: 1.2; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { flex: none; display: block; }

/* ---------- type motifs ---------- */
.eyebrow {
  font: 700 var(--fs-xs)/1.2 var(--font-display);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--accent-ink);
}
.rule-title { position: relative; padding-bottom: 10px; }
.rule-title::after {
  content: ''; position: absolute; left: 0; bottom: 0; width: 32px; height: 3px; border-radius: 2px; background: var(--accent-bright);
}

/* ---------- focus ---------- */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }

/* ---------- buttons ---------- */
button, .btn {
  font: 600 var(--fs-sm)/1.2 var(--font-body);
  color: var(--text-head);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0 var(--s-3);
  min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
button:hover:not(:disabled), .btn:hover { background: var(--quiet); border-color: var(--accent); color: var(--text-head); }
button:active:not(:disabled), .btn:active { background: var(--quiet-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
button.primary:active:not(:disabled), .btn.primary:active { background: var(--accent-press); border-color: var(--accent-press); }
button.danger, .btn.danger { color: var(--bad); border-color: var(--bad-dot); background: transparent; }
button.danger:hover:not(:disabled) { background: var(--bad-bg); border-color: var(--bad-dot); color: var(--bad); }
button.danger.solid { background: var(--bad-dot); border-color: var(--bad-dot); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-body); }
button.ghost:hover:not(:disabled) { background: var(--quiet); border-color: transparent; }
button.icon-btn { width: 36px; padding: 0; }
button.sm, .btn.sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-xs); }
button.lg, .btn.lg { min-height: 48px; padding: 0 var(--s-6); font-size: var(--fs-md); border-radius: var(--radius-lg); }

/* ---------- form controls ---------- */
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  font: 400 var(--fs-base)/1.3 var(--font-body);
  color: var(--text-head);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0 var(--s-3);
  min-height: 38px;
  width: 100%;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
input::placeholder { color: var(--text-muted); opacity: .85; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2377777A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
label.field { display: grid; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-head); }
label.field .hint { font-weight: 400; color: var(--text-muted); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

/* ---------- cards + chips ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font: 600 var(--fs-xs)/1.5 var(--font-body); background: var(--quiet); color: var(--text-body);
  border: 1px solid transparent; white-space: nowrap;
}
.chip .dot, .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex: none; display: inline-block; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.ok .dot { background: var(--ok-dot); }
.chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.warn .dot { background: var(--warn-dot); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.bad .dot { background: var(--bad-dot); }
.chip.info { background: var(--info-bg); color: var(--info); } .chip.info .dot { background: var(--info-dot); }
.chip.quiet { background: transparent; border-color: var(--border); color: var(--text-muted); }

/* ---------- brand lockup ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; border-radius: var(--radius); }
.brand img { width: 34px; height: auto; display: block; }
.brand-text { display: grid; gap: 3px; line-height: 1; }
.brand-text b { font: 700 var(--fs-sm)/1 var(--font-display); letter-spacing: var(--track-wordmark); color: var(--accent-ink); text-transform: uppercase; }
.brand-text b i { font-style: normal; color: var(--text-muted); font-weight: 600; }
.brand-text small { font: 600 var(--fs-2xs)/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }

/* ---------- progress + bars ---------- */
.bar { height: 8px; background: var(--quiet-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width var(--t-slow) var(--ease); }

/* ---------- dialogs ---------- */
dialog {
  color: var(--text-body); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised); padding: 0; max-width: calc(100vw - 32px);
}
dialog::backdrop { background: var(--scrim); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.dlg-head h2 { font: 700 var(--fs-md)/1.2 var(--font-display); letter-spacing: .02em; }
.dlg-body { padding: var(--s-5); }
.dlg-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: 0 var(--s-5) var(--s-5); }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: 18px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 9px 14px; border-radius: 999px; font: 600 var(--fs-sm)/1.3 var(--font-body);
  background: var(--text-head); color: var(--canvas); box-shadow: var(--shadow-raised);
  opacity: 0; transform: translateY(8px); transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast .dot { background: var(--teal-200); }
.toast.ok .dot { background: #6FD39A; }
.toast.warn .dot { background: #F0C050; }
.toast.bad .dot { background: #F27B6B; }

/* ---------- page states (empty / loading / error) ---------- */
.state { display: grid; justify-items: center; text-align: center; gap: var(--s-3); padding: var(--s-10) var(--s-5); color: var(--text-muted); }
.state h2 { font: 700 var(--fs-lg)/1.25 var(--font-display); color: var(--text-head); }
.state p { max-width: 44ch; }
.state .state-ico { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.state.error .state-ico { background: var(--bad-bg); color: var(--bad); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--quiet-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: var(--quiet); animation: breathe 1.4s ease-in-out infinite; border-radius: var(--radius); }
@keyframes breathe { 50% { opacity: .5; } }

/* ---------- theme toggle ---------- */
.theme-toggle { width: 36px; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* small status dots on quiet chips */
.dot.t-ok { background: var(--ok-dot); } .dot.t-warn { background: var(--warn-dot); } .dot.t-bad { background: var(--bad-dot); } .dot.t-info { background: var(--info-dot); }

/* ---------- app bar ---------- */
.appbar {
  height: var(--appbar-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(var(--s-6), calc((100% - 1160px) / 2 + var(--s-6))); background: var(--surface); border-bottom: 1px solid var(--border);
}

/* share panel (also used inside the monitor's Share dialog) */
.share { display: grid; gap: var(--s-5); }
.share-top { display: grid; grid-template-columns: 1fr auto; gap: var(--s-6); align-items: center; }
.share-code { display: grid; gap: var(--s-2); }
.code-big { font: 800 56px/1 var(--font-display); letter-spacing: .08em; color: var(--text-head); white-space: nowrap; }
.share-qr { margin: 0; display: grid; gap: 6px; justify-items: center; text-align: center; }
.share-qr img { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; width: 168px; height: 168px; display: block; }
.share-link { display: grid; grid-template-columns: 1fr auto; gap: var(--s-2); }
.share-link input { font-family: var(--font-mono); font-size: var(--fs-sm); }
.share-warn { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); }
.share-script { border-top: 1px solid var(--border); padding-top: var(--s-4); display: grid; gap: var(--s-2); }
.share-script-head { display: flex; justify-content: space-between; align-items: center; }
.share-script ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--text-body); font-size: var(--fs-sm); }
.share-script li::marker { color: var(--accent-ink); font-weight: 700; }
.share-open { width: 100%; }


.viewport > .toasts { position: absolute; top: 12px; bottom: auto; z-index: 8; }

/* ---------- sign-in, sign-out, retention ---------- */
.who { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-muted); }
.who[hidden] { display: none; }
.retention { display: grid; gap: var(--s-3); border-top: 1px solid var(--border); padding-top: var(--s-4); }
.retention .row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; justify-content: space-between; }
.retention label { display: inline-flex; gap: 8px; align-items: center; color: var(--text-body); font-size: var(--fs-sm); }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
button.danger:hover:not(:disabled) { background: var(--bad-bg); }
.expiry { font-size: var(--fs-xs); color: var(--text-muted); }
.bar-right { display: flex; align-items: center; gap: var(--s-3); }
