/* Reset, typography, primitives (buttons, inputs, chips, tags, avatars, skeletons, toasts). */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--t1);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow: hidden; overscroll-behavior: none;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; }
a { color: var(--accent-text); }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.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; }

/* Focus ring: accent text colour so it is visible on light and dark */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: inherit; }
input:focus-visible, textarea:focus-visible { outline-offset: 0; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--t3); background-clip: content-box; border: 3px solid transparent; }

/* Icons */
.i { display: block; width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i.s14 { width: 14px; height: 14px; } .i.s16 { width: 16px; height: 16px; } .i.s18 { width: 18px; height: 18px; }
.i.s22 { width: 22px; height: 22px; } .i.s24 { width: 24px; height: 24px; } .i.s32 { width: 32px; height: 32px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--r-pill);
  font-weight: 600; font-size: 14px; white-space: nowrap; user-select: none;
  transition: background-color 140ms ease-out, transform 100ms var(--ease), border-color 140ms, opacity 140ms;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 86%, var(--bg)); }
:root[data-theme="dark"] .btn.primary:hover:not(:disabled) { background-image: linear-gradient(180deg, #f5feff 21%, #a6dfff 168%); box-shadow: 0 4px 16px rgba(102, 206, 255, .25); }
.btn.ghost { border: 1px solid var(--line); background: var(--hover); color: var(--t1); }
.btn.ghost:hover:not(:disabled) { background: var(--hover-strong); }
.btn.danger { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); background: transparent; }
.btn.danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn.danger-fill { background: var(--danger); color: #fff; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn .spin { width: 16px; height: 16px; }

.ibtn {
  position: relative; width: 40px; height: 40px; border-radius: var(--r-pill);
  display: inline-grid; place-items: center; color: var(--t2); flex: none;
  transition: background-color 140ms ease-out, color 140ms, transform 100ms var(--ease);
}
.ibtn::after { content: ""; position: absolute; inset: -2px; } /* 44px hit area */
.ibtn:hover:not(:disabled) { background: var(--hover-strong); color: var(--t1); }
.ibtn:active:not(:disabled) { transform: scale(.94); }
.ibtn:disabled { opacity: .45; }
.ibtn.bordered { border: 1px solid var(--line); background: transparent; }

/* Spinner */
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Fields */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--t2); }
.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-12);
  border: 1px solid var(--field-line); background: var(--input); color: var(--t1);
  transition: border-color 140ms; font-size: 15px;
}
.input::placeholder { color: var(--t3); }
.input:hover { border-color: color-mix(in srgb, var(--t3) 50%, var(--line)); }
.input:focus { border-color: var(--field-line); box-shadow: none; outline: 2px solid var(--ring); outline-offset: 2px; }
.input.invalid { border-color: var(--danger); }
.hint { font-size: 12.5px; color: var(--t3); min-height: 18px; display: flex; align-items: center; gap: 6px; }
.hint.ok { color: var(--accent-text); } .hint.bad { color: var(--danger); }

select.input { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d889c' stroke-width='2' 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 12px center; }

/* Chips and tags */
.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 8px; border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--tag-bg); color: var(--tag-text); font-size: 12px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; flex: none;
}
.tag.code { padding: 0 6px; }
.seg { justify-self: start; display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: transparent; border: 1px solid var(--line); }
.seg > button { height: 28px; padding: 0 12px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600; color: var(--t2); transition: background-color 160ms, color 160ms; }
.seg > button:hover { color: var(--t1); }
.seg > button[aria-checked="true"], .seg > button[aria-selected="true"], .seg > button.on { background: var(--own); color: #fff; }

/* Switch */
.switch { position: relative; width: 40px; height: 24px; border-radius: 12px; background: var(--hover-strong); border: 1px solid var(--line); flex: none; transition: background-color 160ms, border-color 160ms; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--t3); transition: transform 180ms var(--ease), background-color 160ms; }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--accent-ink); }

/* Avatars: flat solid circles, neutral / muted tints */
.av {
  --s: 46px; width: var(--s); height: var(--s); border-radius: 50%; flex: none; position: relative;
  display: grid; place-items: center; font-weight: 600; font-size: calc(var(--s) * .36); letter-spacing: .01em;
  background: var(--av0); color: var(--av-ink); box-shadow: inset 0 0 0 1px var(--line); user-select: none;
}
.av.c0 { background: var(--av0); } .av.c1 { background: var(--av1); } .av.c2 { background: var(--av2); }
.av.c3 { background: var(--av3); } .av.c4 { background: var(--av4); } .av.c5 { background: var(--av5); }
.av.me { background: var(--own); color: #fff; box-shadow: none; }
.av.saved { background: var(--accent-bg); color: var(--accent-text); }
.av.s28 { --s: 28px; } .av.s32 { --s: 32px; } .av.s36 { --s: 36px; } .av.s40 { --s: 40px; } .av.s52 { --s: 52px; } .av.s72 { --s: 72px; } .av.s96 { --s: 96px; }
.dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--t3); border: 2.5px solid var(--ring-bg, var(--panel)); box-sizing: content-box; margin: -2px; transition: background-color 300ms, transform 200ms var(--ease); }
.dot.on { background: var(--online); }

/* Skeleton / shimmer */
.skel { position: relative; overflow: hidden; background: var(--hover-strong); border-radius: 8px; height: 12px; }
.shimmer { position: relative; overflow: hidden; }
.shimmer::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0, color-mix(in srgb, var(--t1) 10%, transparent) 50%, transparent 100%); transform: translateX(-100%); animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Toasts */
#toasts { position: fixed; left: 0; right: 0; bottom: 96px; display: grid; justify-items: center; gap: 8px; pointer-events: none; z-index: 400; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: min(520px, 100%);
  padding: 10px 14px; border-radius: var(--r-14); background: var(--popover); color: var(--t1);
  box-shadow: var(--shadow-pop); font-size: 13.5px; line-height: 20px;
  animation: toast-in 180ms var(--ease) both;
}
.toast.error { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.toast.error > .i { color: var(--danger); }
.toast.out { animation: toast-out 150ms cubic-bezier(.4, 0, 1, 1) both; }
.toast .t-act { color: var(--accent-text); font-weight: 600; white-space: nowrap; border-radius: 6px; }
@media (min-width: 900px) and (pointer: fine) { .toast .t-act { padding-bottom: 1px; } }   /* optical: the label sits level with the message text */
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* Generic keyframes */
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }

/* Reduced motion: JS mirrors the OS setting onto html[data-motion="reduce"] (also usable as a manual override).
   Movement is removed; short opacity fades stay, only on the elements that animate. Component files add their own overrides. */
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  transition-property: opacity, background-color, color, border-color, visibility !important; transition-duration: .12s !important; transition-delay: 0s !important;
  scroll-behavior: auto !important;
}
html[data-motion="reduce"] .toast, html[data-motion="reduce"] .msg.enter-mine, html[data-motion="reduce"] .msg.enter-in, html[data-motion="reduce"] .tx.reveal,
html[data-motion="reduce"] .rchip.bump, html[data-motion="reduce"] .conn-banner, html[data-motion="reduce"] dialog.dlg[open],
html[data-motion="reduce"] .auth-card, html[data-motion="reduce"] .search-results, html[data-motion="reduce"] .call-banner, html[data-motion="reduce"] .vp-play .i {
  animation-name: fade-in !important; animation-duration: .12s !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
}
html[data-motion="reduce"] .shimmer::after, html[data-motion="reduce"] .spin, html[data-motion="reduce"] .dots i, html[data-motion="reduce"] .rec-dot { animation: none !important; }
html[data-motion="reduce"] .spin { border-right-color: currentColor; opacity: .6; }
html[data-motion="reduce"] .shimmer { opacity: .6; }
html[data-motion="reduce"] .dots i, html[data-motion="reduce"] .rec-dot { opacity: .8; }

/* Theme switch: View Transition cross-fade of the whole page (theme.js) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 220ms; animation-timing-function: ease; }
/* (legacy, unused) colour transition only while the toggle is applied */
html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, fill 200ms ease, stroke 200ms ease !important;
}

/* Country flags (js/flags.js): 7:5 rounded rectangles (20x14, 14x10, 28x20: whole pixels, the 24x18 artwork is stretched ~7%) with a hairline ring so the white stripe shows on light and dark surfaces */
.flag { position: relative; display: inline-block; flex: none; width: 20px; height: 14px; border-radius: 3px; overflow: hidden; vertical-align: -2px; }
.flag > svg { display: block; width: 100%; height: 100%; }
.flag::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--flag-ring); pointer-events: none; }
.flag.sm { width: 14px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.flag.lg { width: 28px; height: 20px; border-radius: 4px; }
.flag[hidden] { display: none; }
.tag.lang { gap: 5px; }
