/* Lattice: a whiteboard, its markers, and the hand that holds them. */
:root {
  /* the board */
  --board: #f8fafb;
  --board-2: #eef1f4;
  --board-3: #e2e7ec;
  --ghost: rgba(23, 25, 30, 0.035);

  /* marker inks */
  --ink: #17191e;
  --ink-2: #3c4149;
  --ink-3: #5c636d;
  --blue: #1f4fd6;
  --red: #df3a2e;
  --green: #138a4f;
  --orange: #ea7a14;
  --violet: #7444d0;
  --yellow: #f2cf00;

  /* paper stocks */
  --sun: #ffe36e;
  --rose: #ffb9d3;
  --sky: #acdcff;
  --mint: #bdeec9;
  --lilac: #dccbff;

  /* roles */
  --action: var(--ink);
  --action-ink: #ffffff;
  --live: var(--green);
  --focus: var(--blue);
  --select: var(--blue);
  --danger: var(--red);

  --font-hand: "Shantell Sans", "Comic Neue", "Segoe Print", system-ui, sans-serif;
  --font-ui: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --float: 0 1px 2px rgba(23, 25, 30, 0.06), 0 6px 20px -4px rgba(23, 25, 30, 0.14);
  --float-lg: 0 2px 6px rgba(23, 25, 30, 0.06), 0 24px 60px -12px rgba(23, 25, 30, 0.28);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  background: var(--board);
  color: var(--ink);
  font: 400 17px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
}
::selection { background: rgba(242, 207, 0, 0.55); color: var(--ink); }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
img { max-width: 100%; }
.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; }
.data { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: 0.8125rem; }
.hand { font-family: var(--font-hand); font-variation-settings: "INFM" 40, "BNCE" 10; }
html { scrollbar-color: var(--board-3) transparent; }

/* ---------------------------------------------------------------- buttons */
.btn {
  --bg: var(--board-2);
  --fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 0; border-radius: 999px;
  background: var(--bg); color: var(--fg);
  font: 600 0.9375rem/1 var(--font-ui); letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 160ms ease, box-shadow 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary, .btn.dark { --bg: var(--ink); --fg: #fff; }
.btn.ghost { --bg: transparent; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 0.875rem; }
.btn.wide { width: 100%; }
.btn.busy { pointer-events: none; }
.btn.busy span::after { content: "…"; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: color-mix(in oklab, var(--bg), var(--ink) 7%); }
  .btn.primary:hover, .btn.dark:hover { background: #2c3038; }
  .btn.ghost:hover { background: var(--board-2); }
}

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink-2);
  transition: background-color 140ms ease, color 140ms ease, transform 120ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.icon-btn:disabled { opacity: 0.35; pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover:not([aria-pressed="true"]) { background: var(--board-2); color: var(--ink); } }

.link-btn { border: 0; background: none; padding: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }

/* ---------------------------------------------------------------- fingerprint */
.fingerprint {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px 0 9px;
  border-radius: 999px; background: var(--ink); color: #fff;
}
.fingerprint .swatches { display: inline-flex; gap: 3px; }
.fingerprint .swatches i { width: 8px; height: 8px; border-radius: 50%; display: block; box-shadow: 0 0 0 1.5px rgba(255,255,255,.9); }
.fingerprint.flash { animation: fp 520ms var(--ease-out); }
@keyframes fp { 30% { transform: scale(1.06); } }

/* ---------------------------------------------------------------- account */
.account { position: relative; }
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0; overflow: hidden;
  background: var(--ink); color: #fff; font: 700 0.8125rem/1 var(--font-ui);
  display: grid; place-items: center; transition: transform 140ms var(--ease-out);
}
.avatar-btn:active { transform: scale(0.94); }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80; min-width: 240px; padding: 6px;
  background: #fff; border-radius: 16px; box-shadow: var(--float-lg);
  transform-origin: top right; animation: pop 180ms var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.menu-who { margin: 0; padding: 10px 12px 12px; display: grid; gap: 1px; }
.menu-who strong { font-weight: 650; }
.menu-who span { color: var(--ink-3); font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; text-decoration: none; font-weight: 550; font-size: 0.9375rem;
}
.menu-item svg { width: 18px; height: 18px; color: var(--ink-3); }
@media (hover: hover) { .menu-item:hover { background: var(--board-2); } }

/* ---------------------------------------------------------------- dialog */
.dlg {
  width: min(420px, calc(100vw - 32px)); padding: 30px 28px 24px; border: 0; border-radius: 24px;
  background: #fff; color: var(--ink); box-shadow: var(--float-lg);
}
.dlg[open] { animation: dlg-in 260ms var(--ease-out); }
.dlg::backdrop { background: rgba(23, 25, 30, 0.32); animation: fade 200ms ease; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
@keyframes fade { from { opacity: 0; } }
.dlg-x { position: absolute; top: 12px; right: 12px; margin: 0; }
.dlg-title { margin: 0 0 8px; font: 700 1.75rem/1.1 var(--font-hand); font-variation-settings: "INFM" 30, "BNCE" 0; letter-spacing: -0.02em; }
.dlg-lede { margin: 0 0 22px; color: var(--ink-3); font-size: 0.9375rem; line-height: 1.5; max-width: 34ch; }
.dlg-or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--ink-3); font-size: 0.8125rem; }
.dlg-or::before, .dlg-or::after { content: ""; flex: 1; height: 1px; background: var(--board-3); }
.dlg-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
.field input {
  height: 46px; padding: 0 14px; border-radius: 12px; border: 0; background: var(--board-2);
  font-size: 1rem; font-weight: 450; color: var(--ink); transition: box-shadow 140ms ease, background-color 140ms ease;
}
.field input:focus { outline: none; background: #fff; box-shadow: 0 0 0 2px var(--focus); }
.field input::placeholder { color: var(--ink-3); }
.dlg-err { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fdecea; color: #9b1c12; font-size: 0.875rem; font-weight: 550; }
.dlg-switch { margin: 4px 0 0; text-align: center; font-size: 0.875rem; color: var(--ink-3); }
.dlg-switch .link-btn { color: var(--ink); }

/* ---------------------------------------------------------------- toasts */
.toasts {
  position: fixed; z-index: 200; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
  width: min(380px, calc(100vw - 32px)); margin: 0; padding: 0; list-style: none; transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  --i: 0;
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px;
  background: var(--ink); color: #fff; border-radius: 14px; box-shadow: var(--float-lg);
  font-size: 0.9375rem; font-weight: 500; line-height: 1.35;
  transform: translateY(calc(var(--i) * -10px)) scale(calc(1 - var(--i) * 0.05));
  opacity: calc(1 - var(--i) * 0.28);
  transition: transform 300ms var(--ease-out), opacity 300ms var(--ease-out);
  animation: toast-in 320ms var(--ease-out);
  pointer-events: auto;
}
.toast.error { background: #9b1c12; }
.toast.out { opacity: 0; transform: translateY(12px) scale(0.98); transition-duration: 180ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.toast-text { flex: 1; }
.toast-action { border: 0; background: rgba(255,255,255,.14); color: #fff; padding: 6px 10px; border-radius: 8px; font-weight: 650; font-size: 0.875rem; }

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