/* Shared by the site and the admin panel. System fonts only: nothing to download. */

:root {
  color-scheme: dark;
  --bg: #0d0e12;
  --surface: #15171d;
  --surface-2: #1c1f27;
  --surface-3: #262a34;
  --line: #2a2e38;
  --text: #eceef3;
  --muted: #9aa1ae;
  --faint: #6d7482;
  --accent: #ff5b3a;
  --accent-hover: #ff7152;
  --accent-soft: rgb(255 91 58 / 15%);
  --on-accent: #fff;
  --ok: #3ccf87;
  --ok-soft: rgb(60 207 135 / 14%);
  --warn: #f4b740;
  --warn-soft: rgb(244 183 64 / 14%);
  --danger: #ff5566;
  --danger-soft: rgb(255 85 102 / 14%);
  --skeleton: #1f222a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgb(0 0 0 / 45%);
  --topbar-h: 60px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --surface-3: #e3e6ec;
    --line: #e0e3e9;
    --text: #14161b;
    --muted: #5b6372;
    --faint: #8a91a0;
    --accent: #e8472a;
    --accent-hover: #d63d21;
    --accent-soft: rgb(232 71 42 / 11%);
    --ok: #13985a;
    --ok-soft: rgb(19 152 90 / 12%);
    --warn: #b7791f;
    --warn-soft: rgb(183 121 31 / 12%);
    --danger: #d92f45;
    --danger-soft: rgb(217 47 69 / 10%);
    --skeleton: #e6e8ed;
    --shadow: 0 10px 40px rgb(20 22 27 / 14%);
  }
}

@media (min-width: 720px) {
  :root { --gutter: 24px; --topbar-h: 64px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.fill { fill: currentColor; stroke: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  font-weight: 750;
  font-size: 18px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
}
.brand-mark .icon { width: 16px; height: 16px; margin-left: 2px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.block { display: flex; width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; }
.btn .icon { width: 18px; height: 18px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  transition: background-color .15s;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- form fields ---------- */

.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px; /* 16px stops iOS from zooming in on focus */
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.5; }
.input::placeholder { color: var(--faint); }

.field { display: grid; gap: 7px; margin-top: 18px; }
.field > label { font-size: 14px; font-weight: 650; }
.field-hint { color: var(--faint); font-size: 12.5px; }
.form-error { margin-top: 12px; color: var(--danger); font-size: 14px; font-weight: 600; }
.form-error:empty { display: none; }
.muted { color: var(--muted); }

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 48px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--faint);
}
.pw-toggle .icon { width: 19px; height: 19px; }

/* ---------- avatars ---------- */

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  font-weight: 750;
  text-transform: uppercase;
  line-height: 1;
}
.av-0 { background: #e2553d; } .av-1 { background: #d9822b; } .av-2 { background: #2f9e6e; } .av-3 { background: #2d7ff9; }
.av-4 { background: #7c5cf0; } .av-5 { background: #c2468e; } .av-6 { background: #13908f; } .av-7 { background: #5c6b7f; }
.avatar.anon { background: var(--surface-3); color: var(--muted); }
.avatar.anon .icon { width: 18px; height: 18px; }

/* ---------- modal dialog ---------- */

dialog.modal {
  width: min(420px, calc(100% - 32px));
  max-width: 100%;
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgb(8 9 12 / 60%); }
dialog.modal[open] { animation: modal-in .2s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@media (max-width: 599px) {
  dialog.modal {
    width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
  }
}
.modal-body { position: relative; padding: 26px 22px calc(22px + env(safe-area-inset-bottom)); }
.modal-close { position: absolute; top: 10px; right: 10px; color: var(--muted); }

/* ---------- chips & badges ---------- */

.chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--faint); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .hash { color: var(--faint); font-weight: 500; }
.chip.active .hash { color: inherit; opacity: .6; }

.serial {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgb(0 0 0 / 74%);
  color: #fff;
  font: 700 12px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 550;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- skeleton ---------- */

.skeleton { background: var(--skeleton); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}
