/* Brainbean SSO · V2 ("Vault" direction). No framework, no build step. */

:root {
  --bg: #f6f6f4;
  --surface: #fff;
  --line: #e6e5e0;
  --line-soft: #f1f0ec;
  --line-input: #dcdbd5;
  --text: #17181a;
  --muted: #6b6b66;
  --muted-2: #8a8a84;
  --label: #5d5d58;
  --faint: #b5b4ae;
  --hover: #f4f4f1;
  --selected: #f1f0ec;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-ink: #312e81;
  --accent-soft: #eef0ff;
  --accent-soft-2: #e0e7ff;
  --danger: #b42318;
  --danger-line: #f3c5c0;
  --danger-soft: #fef3f2;
  --ok: #15803d;
  --ok-soft: #ecf8f0;
  --warn: #8a5a00;
  --warn-soft: #fff7e6;

  --accent-fg: #4338ca;       /* accent used as text */
  --raised: #fff;             /* sheets */
  --field: #fff;
  --field-hover: #c9c8c1;
  --placeholder: #a9a8a2;
  --ring: rgb(67 56 202 / .12);
  --error-line: #e5484d;
  --error-ring: rgb(229 72 77 / .14);
  --ok-line: #bfe5cc;
  --danger-fill: #b42318;
  --danger-fill-hover: #912018;
  --ink: #17181a;             /* "dark" buttons; flips to light in dark mode */
  --ink-hover: #2c2d30;
  --on-ink: #fff;
  --toast: #17181a;
  --veil: rgb(23 24 26 / .028);
  --veil-2: rgb(23 24 26 / .045);
  --scrim: rgb(15 16 18 / .45);
  --tile-bg: .95 .04;         /* oklch lightness + chroma; hue comes from --h */
  --tile-fg: .42 .13;
  --grid-line: rgb(23 24 26 / .05);
  --grid-dot: rgb(23 24 26 / .07);
  --hub-line: rgb(67 56 202 / .2);
  --hub-ring: rgb(67 56 202 / .22);
  --hub-ring-soft: rgb(67 56 202 / .1);
  --grad-a: #4338ca;
  --grad-b: #7c3aed;
  --grad-c: #6366f1;
  color-scheme: light;

  --font: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);

  --pad: 32px;
  --topbar-h: 64px;
}

/* Dark theme. The inline script in partials/head sets data-theme from the saved
   choice (Light / Dark / System) before first paint. */
:root[data-theme="dark"] {
  --bg: #101113;
  --surface: #17181b;
  --line: #2a2b2f;
  --line-soft: #212226;
  --line-input: #36373c;
  --text: #ececea;
  --muted: #a2a19b;
  --muted-2: #86857f;
  --label: #b3b2ac;
  --faint: #5d5c58;
  --hover: #1e1f23;
  --selected: #25262b;
  --accent: #5b54f0;
  --accent-hover: #6b65f5;
  --accent-ink: #c7c4ff;
  --accent-soft: rgb(99 102 241 / .16);
  --accent-soft-2: rgb(99 102 241 / .26);
  --danger: #f97066;
  --danger-line: #5a2a26;
  --danger-soft: rgb(240 68 56 / .12);
  --ok: #4ade80;
  --ok-soft: rgb(34 197 94 / .14);
  --warn: #fbbf24;
  --warn-soft: rgb(245 158 11 / .14);

  --accent-fg: #a5a1ff;
  --raised: #1c1d21;
  --field: #1b1c20;
  --field-hover: #4a4b51;
  --placeholder: #6b6a65;
  --ring: rgb(99 102 241 / .32);
  --error-line: #f97066;
  --error-ring: rgb(249 112 102 / .2);
  --ok-line: rgb(34 197 94 / .35);
  --danger-fill: #d92d20;
  --danger-fill-hover: #e8473a;
  --ink: #ececea;
  --ink-hover: #fff;
  --on-ink: #17181a;
  --toast: #2a2b30;
  --veil: rgb(255 255 255 / .035);
  --veil-2: rgb(255 255 255 / .06);
  --scrim: rgb(0 0 0 / .62);
  --tile-bg: .3 .06;
  --tile-fg: .86 .11;
  --grid-line: rgb(255 255 255 / .05);
  --grid-dot: rgb(255 255 255 / .08);
  --hub-line: rgb(129 140 248 / .28);
  --hub-ring: rgb(129 140 248 / .3);
  --hub-ring-soft: rgb(129 140 248 / .14);
  --grad-a: #a5a1ff;
  --grad-b: #c4b5fd;
  --grad-c: #818cf8;
  color-scheme: dark;
}

@media (max-width: 1099.98px) { :root { --pad: 24px; } }
@media (max-width: 639.98px) { :root { --pad: 16px; --topbar-h: 56px; } }

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-fg); text-decoration: none; transition: color .18s; }
a:hover { color: var(--accent-ink); }
h1, h2, h3, p { margin: 0; }
code { font-family: var(--mono); }
.mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- app shell ---------- */

body.v2 { height: 100vh; height: 100dvh; overflow: hidden; }
.shell { height: 100%; display: flex; flex-direction: column; }
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

.topbar {
  height: var(--topbar-h);
  flex: none;
  position: relative;
  z-index: 5;
  padding: 0 var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  view-transition-name: v2-topbar;
}
.topbar__left { height: 100%; display: flex; align-items: center; gap: 36px; min-width: 0; }
.topbar__right { display: flex; align-items: center; gap: 14px; }
.topbar__title { display: none; font-size: 16px; font-weight: 600; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; font-weight: 600; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand__mark {
  width: 28px; height: 28px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 700;
  transition: transform .3s var(--ease-spring);
}
.brand:hover .brand__mark { transform: rotate(-8deg) scale(1.06); }

.tabs { height: 100%; display: flex; gap: 4px; font-size: 14px; }
.tabs__link {
  position: relative;
  display: flex; align-items: center;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 500;
}
.tabs__link:hover, .tabs__link[aria-current="page"] { color: var(--text); }
.tabs__indicator {
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  view-transition-name: v2-tab-indicator;
}

.topbar__avatar { border-radius: 50%; box-shadow: 0 0 0 2px transparent; transition: box-shadow .2s, transform .3s var(--ease-spring); }
.topbar__avatar:hover { transform: scale(1.06); }
.topbar__avatar[aria-current="page"] { box-shadow: 0 0 0 2px var(--accent); }

@media (max-width: 1099.98px) { .topbar__left { gap: 20px; } }
@media (max-width: 639.98px) {
  .topbar__left { gap: 10px; }
  .brand__mark { width: 26px; height: 26px; font-size: 12px; }
  .brand__name, .tabs, .topbar__avatar { display: none; }
  .topbar__title { display: block; }
}

.tabbar { display: none; }
@media (max-width: 639.98px) {
  .tabbar {
    flex: none;
    display: grid;
    grid-template-columns: repeat(var(--cols, 3), 1fr);
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
    view-transition-name: v2-tabbar;
  }
}
.tabbar__link {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted-2);
  font-size: 11px; font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.tabbar__link:hover { color: var(--text); }
.tabbar__link[aria-current="page"] { color: var(--accent-fg); }
.tabbar__link svg { transition: transform .3s var(--ease-spring); }
.tabbar__link:active svg { transform: scale(.86); }
.tabbar__indicator {
  position: absolute; top: -1px; left: 30%; right: 30%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--accent);
  view-transition-name: v2-tabbar-indicator;
}

/* ---------- avatar & tiles ---------- */

.avatar {
  position: relative;
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid; place-items: center;
  background: var(--accent-soft-2); color: var(--accent-fg);
  font-size: 12px; font-weight: 600;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fade-in .3s var(--ease-out); }
.avatar--xl { width: 64px; height: 64px; font-size: 22px; }

.tile {
  --h: 270;
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  background: oklch(var(--tile-bg) var(--h));
  color: oklch(var(--tile-fg) var(--h));
  font-size: 13px; font-weight: 600;
}
@supports not (color: oklch(0 0 0)) {
  .tile { background: hsl(var(--h) 70% 95%); color: hsl(var(--h) 55% 38%); }
}
.tile--round { border-radius: 50%; font-size: 12px; }
.tile--xl { width: 72px; height: 72px; border-radius: 18px; font-size: 24px; }
.tile--xl.tile--round { border-radius: 50%; }
@media (max-width: 639.98px) { .tile--xl { width: 56px; height: 56px; } }

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

.btn {
  --h: 38px;
  --spin: #fff;
  position: relative;
  height: var(--h);
  padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  font-size: 14px; font-weight: 500; line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .18s, border-color .18s, color .18s, box-shadow .2s, transform .25s var(--ease-spring), opacity .18s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:disabled:active { transform: none; }
.btn svg { flex: none; }

.btn--primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn--primary:hover { background: var(--accent-hover); color: #fff; box-shadow: 0 8px 20px -8px rgb(67 56 202 / .6); }
.btn--dark { background: var(--ink); color: var(--on-ink); }
.btn--dark:hover { background: var(--ink-hover); color: var(--on-ink); }
.btn--danger { background: var(--danger-fill); color: #fff; font-weight: 600; }
.btn--danger:hover { background: var(--danger-fill-hover); color: #fff; }
.btn--outline { --spin: var(--accent-fg); background: var(--surface); border-color: var(--line-input); color: var(--text); }
.btn--outline:hover { background: var(--hover); color: var(--text); }
.btn--danger-outline { --spin: var(--danger); background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn--danger-outline:hover { background: var(--danger-soft); color: var(--danger); }
.btn--soft { --spin: var(--accent-fg); background: var(--accent-soft); color: var(--accent-fg); }
.btn--soft:hover { background: var(--accent-soft-2); color: var(--accent-fg); }
.btn--ghost { --spin: var(--accent-fg); background: var(--surface); border-color: var(--line); border-radius: 8px; color: var(--text); }
.btn--ghost:hover { background: var(--hover); color: var(--text); }
.btn--text-danger { --spin: var(--danger); background: none; color: var(--danger); }
.btn--text-danger:hover { background: var(--danger-soft); color: var(--danger); }

.btn--lg { --h: 48px; padding: 0 26px; font-size: 15px; }
.btn--sm { --h: 36px; font-size: 13px; }
.btn--xs { --h: 30px; padding: 0 12px; font-size: 13px; }
.btn--chip { --h: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }

.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy svg { opacity: 0; }
.btn.is-busy::after {
  content: "";
  position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--spin);
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn.is-done { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }
.btn.is-done svg { animation: pop .35s var(--ease-spring); }

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

.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 500; color: var(--label); }
.field__top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field__error { display: none; font-size: 12.5px; font-weight: 500; color: var(--danger); }
.field.has-error .field__error { display: block; animation: rise-sm .25s var(--ease-out); }

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-input);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
  font-size: 15px; font-weight: 400;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .18s, box-shadow .2s;
}
.input::placeholder { color: var(--placeholder); }
.input:hover { border-color: var(--field-hover); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.input--lg { height: 46px; }
.input--code { font-family: var(--mono); font-size: 20px; letter-spacing: .4em; text-align: center; padding-left: calc(14px + .4em); }
select.input {
  padding-right: 38px;
  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='%238a8a84' 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;
}
.field.has-error .input { border-color: var(--error-line); animation: shake .32s; }
.field.has-error .input:focus { box-shadow: 0 0 0 4px var(--error-ring); }

.input-wrap { position: relative; display: flex; }
.input-wrap .input { padding-right: 70px; }
.input-wrap__toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  height: 32px; padding: 0 10px;
  border: 0; border-radius: 8px;
  background: none; color: var(--accent-fg);
  font-size: 13px; font-weight: 500;
  transition: background-color .18s;
}
.input-wrap__toggle:hover { background: var(--accent-soft); }

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--label); cursor: pointer; width: fit-content; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.alert { padding: 10px 12px; border: 1px solid var(--danger-line); border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; font-weight: 500; animation: rise-sm .3s var(--ease-out); }
.alert--ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.notice button { padding: 0; border: 0; background: none; color: inherit; font-weight: 500; text-decoration: underline; }

/* ---------- list / detail split ---------- */

.split { flex: 1; min-height: 0; display: grid; grid-template-columns: 400px minmax(0, 1fr); }
.split__list { min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.split__detail { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 56px 64px; }
@media (max-width: 1099.98px) {
  .split { grid-template-columns: 300px minmax(0, 1fr); }
  .split__detail { padding: 36px 32px; }
}
@media (max-width: 639.98px) {
  .split { position: relative; overflow: hidden; grid-template-columns: minmax(0, 1fr); }
  .split__list, .split__detail { grid-area: 1 / 1; }
  .split__list { border-right: 0; transition: transform .42s var(--ease-out), opacity .3s; }
  .split__detail {
    padding: 20px 16px 32px;
    background: var(--bg);
    visibility: hidden;
    transform: translateX(100%);
    transition: transform .42s var(--ease-out), visibility 0s linear .42s;
    box-shadow: -12px 0 32px -16px rgb(0 0 0 / .18);
  }
  .split[data-view="detail"] .split__detail { visibility: visible; transform: none; transition: transform .42s var(--ease-out); }
  .split[data-view="detail"] .split__list { transform: translateX(-28%); opacity: 0; pointer-events: none; }
}

.list-head {
  position: sticky; top: 0; z-index: 2;
  padding: 20px 20px 12px;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface);
}
.list-head__label { font-size: 13px; font-weight: 500; color: var(--muted-2); }
.list-head__actions { display: flex; gap: 8px; }
.list-head__label [data-count] { display: inline-block; }
.list-head__label [data-count].is-bump { animation: pop .4s var(--ease-spring); }

.list { position: relative; isolation: isolate; padding: 0 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.list__indicator {
  position: absolute; top: 0; left: 10px; right: 10px; z-index: -1;
  height: 58px;
  border-radius: 10px;
  background: var(--selected);
  opacity: 0;
  transition: transform .34s var(--ease-out), opacity .2s;
  pointer-events: none;
}
.list__indicator.is-on { opacity: 1; }
@media (max-width: 639.98px) { .list__indicator { display: none; } }

.item {
  position: relative;
  width: 100%; height: 58px; flex: none;
  padding: 0 12px;
  display: flex; align-items: center; gap: 12px;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .18s;
  animation: item-in .45s var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 14) * 26ms);
}
.item:hover { background: var(--veil); }
.item[aria-current="true"]:hover { background: transparent; }
@media (max-width: 639.98px) { .item:active { background: var(--hover); } }
.item.is-static { animation: none; }
.item.is-leaving { animation: item-out .28s var(--ease-out) forwards; pointer-events: none; }
.item__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item__title, .item__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__title { font-size: 14px; font-weight: 500; }
.item__sub { font-size: 12px; color: var(--muted-2); }
.item__end { flex: none; color: var(--faint); display: grid; transition: transform .25s var(--ease-out), color .2s; }
.item:hover .item__end, .item[aria-current="true"] .item__end { color: var(--muted-2); transform: translateX(2px); }
.item__id { flex: none; font-family: var(--mono); font-size: 12px; color: var(--faint); }

/* A row with its own Log in button (Systems). The inner button selects the row; the link
   launches straight away. The arrow only shows on phones, where the row opens the detail. */
.item--launch { cursor: pointer; }
.item__main {
  flex: 1; min-width: 0; align-self: stretch;
  padding: 0;
  display: flex; align-items: center; gap: 12px;
  border: 0; border-radius: 8px;
  background: none;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.item__main:focus-visible { outline: none; }
.item--launch:has(.item__main:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.item__login { flex: none; gap: 5px; }
.item__login svg { width: 14px; height: 14px; }
.item__login::before { content: ""; position: absolute; inset: -8px -4px; } /* 46px tap target */
@media (min-width: 640px) { .item--launch .item__end { display: none; } }
@media (max-width: 639.98px) { .item--launch:has(.item__login:active) { background: transparent; } }

.list-empty { padding: 28px 20px; font-size: 14px; color: var(--muted-2); text-align: center; }

/* ---------- detail ---------- */

.detail { display: flex; flex-direction: column; gap: 28px; }
.detail.is-entering > * { animation: rise .42s var(--ease-out) both; }
.detail.is-entering > :nth-child(2) { animation-delay: 30ms; }
.detail.is-entering > :nth-child(3) { animation-delay: 70ms; }
.detail.is-entering > :nth-child(4) { animation-delay: 110ms; }

.back {
  display: none;
  align-self: flex-start;
  height: 24px; padding: 0 4px 0 0;
  align-items: center; gap: 2px;
  border: 0; background: none;
  color: var(--accent-fg);
  font-size: 14px; font-weight: 500;
}
@media (max-width: 639.98px) { .back { display: inline-flex; } }

.hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.hero__text { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 4px; }
.hero__title { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 32px; font-weight: 600; letter-spacing: -.025em; line-height: 1.15; }
.hero__sub { font-size: 14px; color: var(--muted-2); }
.hero__form { display: contents; }
@media (max-width: 1099.98px) { .hero__title { font-size: 26px; } }
@media (max-width: 639.98px) { .hero__title { font-size: 24px; } .hero__cta { flex: 1 1 100%; } }

.badge { padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-fg); font-size: 12px; font-weight: 500; letter-spacing: 0; white-space: nowrap; }
.badge--muted { padding: 4px 10px; background: var(--line-soft); color: var(--label); }
.badge--ok { padding: 4px 10px; background: var(--ok-soft); color: var(--ok); }
.badge--warn { padding: 4px 10px; background: var(--warn-soft); color: var(--warn); }

.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.row { padding: 20px 22px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.row + .row { border-top: 1px solid var(--line-soft); }
.row__main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row__label { font-size: 12px; font-weight: 500; color: var(--muted-2); }
.row__value { font-size: 16px; word-break: break-all; }
.row__value--sm { font-size: 15px; }
.row__actions { display: flex; gap: 8px; }
.is-swapping { animation: unblur .35s var(--ease-out); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.empty { max-width: 420px; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.empty__art { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-fg); }
.empty__title { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.empty__text { font-size: 14px; color: var(--muted); line-height: 1.55; }

/* ---------- sheets (dialogs; bottom sheets on mobile) ---------- */

dialog.sheet {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  margin: 0; padding: 24px;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgb(15 16 18 / 0);
  color: var(--text);
  transition: background-color .26s var(--ease-out);
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet::backdrop { background: transparent; }
dialog.sheet.is-open { background: var(--scrim); }

.sheet__panel {
  width: 100%; max-width: 480px;
  margin: auto;
  display: flex; flex-direction: column;
  background: var(--raised);
  border-radius: 18px;
  box-shadow: 0 30px 60px -20px rgb(0 0 0 / .35);
  opacity: 0;
  transform: translateY(14px) scale(.97);
  transition: transform .34s var(--ease-out), opacity .24s var(--ease-out);
}
dialog.sheet.is-open .sheet__panel { opacity: 1; transform: none; }
.sheet__panel--wide { max-width: 560px; }
.sheet__grab { display: none; }
.sheet__head { padding: 24px 24px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet__title { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.sheet__sub { margin-top: 4px; font-size: 14px; line-height: 1.45; color: var(--muted-2); }
.sheet__x {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--line-soft); color: var(--label);
  transition: background-color .18s, transform .3s var(--ease-spring);
}
.sheet__x:hover { background: var(--line); transform: rotate(90deg); }
.sheet__body { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.sheet__foot { padding: 0 24px 24px; display: flex; justify-content: flex-end; gap: 10px; }
.sheet__foot .btn { --h: 44px; padding: 0 20px; }
.sheet__error { margin: 0 24px 16px; }
.step-in > * { animation: rise .36s var(--ease-out) both; }

@media (max-width: 639.98px) {
  dialog.sheet { padding: 0; align-items: flex-end; }
  .sheet__panel, .sheet__panel--wide {
    max-width: none;
    max-height: 92dvh;
    margin: 0;
    overflow: auto;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    opacity: 1;
    transform: translateY(100%);
    transition: transform .4s var(--ease-out);
  }
  .sheet__grab { display: flex; justify-content: center; padding: 10px 0 2px; touch-action: none; cursor: grab; }
  .sheet__grab::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: var(--line-input); }
  .sheet__foot .btn { flex: 1 1 100%; padding: 0 12px; }
}

/* two-factor bits */
/* Stays white in dark mode so authenticator apps can scan it. */
.qr { align-self: center; padding: 14px; line-height: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.qr svg { display: block; width: 176px; height: 176px; }
.qr:empty { width: 206px; height: 206px; background: var(--line-soft); animation: pulse 1.2s ease-in-out infinite; }
.setup-key { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.setup-key code { font-size: 14px; letter-spacing: .06em; word-break: break-all; color: var(--text); }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; padding: 16px; border-radius: 12px; background: var(--bg); font-family: var(--mono); font-size: 14px; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  width: max-content; max-width: calc(100% - 32px);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toasts[popover] { inset: auto auto 24px 50%; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; height: auto; }
.toasts[popover]:not(:popover-open) { display: none; }
@media (max-width: 639.98px) { .toasts[popover] { bottom: calc(76px + env(safe-area-inset-bottom)); } }
@media (max-width: 639.98px) { .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); } }
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--toast); color: #fff;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 14px 30px -12px rgb(0 0 0 / .45);
  opacity: 0;
  transform: translateY(12px) scale(.96);
  transition: opacity .24s var(--ease-out), transform .38s var(--ease-spring);
}
.toast.is-in { opacity: 1; transform: none; }
.toast--error { background: var(--danger); }
.toast svg { color: #86efac; }

/* ---------- login ---------- */

body.v2-login { min-height: 100vh; min-height: 100dvh; }
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.login__aside {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 48px 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--accent); color: #fff;
}
.login__orb { position: absolute; z-index: -1; border-radius: 50%; filter: blur(70px); opacity: .6; will-change: transform; }
.login__orb--a { top: -140px; right: -90px; width: 440px; height: 440px; background: #6366f1; animation: orb-a 18s ease-in-out infinite alternate; }
.login__orb--b { bottom: -120px; left: -80px; width: 380px; height: 380px; background: #2e2a85; animation: orb-b 23s ease-in-out infinite alternate; }
.login__orb--c { top: 40%; left: 35%; width: 240px; height: 240px; background: #818cf8; opacity: .35; animation: orb-c 27s ease-in-out infinite alternate; }
.login__brand { align-self: flex-start; display: flex; align-items: center; gap: 10px; color: #fff; font-size: 17px; font-weight: 600; }
.login__brand:hover { color: #fff; }
.login__brand .brand__mark { width: 32px; height: 32px; background: #fff; color: var(--accent); font-size: 15px; }
.login__pitch { max-width: 460px; display: flex; flex-direction: column; gap: 16px; }
.login__headline { font-size: 44px; font-weight: 600; letter-spacing: -.03em; line-height: 1.08; text-wrap: pretty; }
.login__lede { font-size: 16px; line-height: 1.5; color: #e0e7ff; }
.login__foot { font-size: 13px; color: #c7d2fe; }
.login__main { padding: var(--pad); display: flex; align-items: center; justify-content: center; overflow: auto; }
.login__form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 28px; }
.login__intro { display: flex; flex-direction: column; gap: 18px; }
.login__mark { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 19px; font-weight: 700; }
.login__title { font-size: 28px; font-weight: 600; letter-spacing: -.025em; }
.login__sub { margin-top: 6px; font-size: 15px; color: var(--muted); }
.login__fields { display: flex; flex-direction: column; gap: 18px; }
@media (min-width: 1100px) { .login__mark { display: none; } }
@media (max-width: 1099.98px) {
  .login { grid-template-columns: 1fr; }
  .login__aside { display: none; }
}

/* ---------- profile ---------- */

.profile { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.profile__inner { max-width: 960px; margin: 0 auto; padding: 48px 32px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.profile__nav { position: sticky; top: 28px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.profile__heading { margin-bottom: 16px; font-size: 28px; font-weight: 600; letter-spacing: -.025em; }
.pnav-list { position: relative; isolation: isolate; display: flex; flex-direction: column; gap: 2px; }
.pnav { padding: 9px 12px; border: 1px solid transparent; border-radius: 8px; color: var(--label); font-size: 14px; transition: color .2s; }
.pnav:hover { color: var(--text); }
.pnav.is-active { color: var(--text); font-weight: 500; }
.pnav__indicator {
  position: absolute; top: 0; left: 0; right: 0; z-index: -1;
  height: 39px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface);
  transition: transform .34s var(--ease-out);
}
.pnav--logout { margin-top: 16px; align-self: flex-start; border: 0; background: none; color: var(--danger); transition: background-color .18s; }
.pnav--logout:hover { background: var(--danger-soft); color: var(--danger); }
.profile__main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.profile__title { font-size: 28px; font-weight: 600; letter-spacing: -.025em; }
.profile__main > .card, .profile__title { animation: rise .5s var(--ease-out) both; }
.profile__main > :nth-child(3) { animation-delay: 50ms; }
.profile__main > :nth-child(4) { animation-delay: 100ms; }
.profile__main > :nth-child(5) { animation-delay: 150ms; }
.profile__logout { display: none; }
@media (min-width: 1100px) { .profile__title { display: none; } }
@media (max-width: 1099.98px) {
  .profile__inner { padding: 32px 24px; grid-template-columns: minmax(0, 1fr); }
  .profile__nav { display: none; }
  .profile__logout { display: flex; --h: 44px; }
}
@media (max-width: 639.98px) {
  .profile__inner { padding: 16px 16px 32px; }
  .profile__title { display: none; }
}

.section-anchor { scroll-margin-top: 24px; }
.card__head { padding: 22px 22px 0; display: flex; flex-direction: column; gap: 4px; }
.card__title { font-size: 17px; font-weight: 600; }
.card__sub { font-size: 14px; line-height: 1.5; color: var(--muted-2); }
.card__body { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.card__foot { padding: 14px 22px; display: flex; justify-content: flex-end; align-items: center; gap: 12px; border-top: 1px solid var(--line-soft); }
.card__hint { margin-right: auto; font-size: 13px; color: var(--muted-2); animation: rise-sm .3s var(--ease-out); }
.card--pad { padding: 22px; gap: 14px; }
.card__line { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card__text { font-size: 14px; line-height: 1.55; color: var(--muted); text-wrap: pretty; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 639.98px) { .grid-2 { grid-template-columns: 1fr; } }
.photo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

.sessions { padding: 0 22px; display: flex; flex-direction: column; }
.session { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); animation: item-in .4s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 10) * 30ms); }
.session__icon { width: 36px; height: 36px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--bg); color: var(--label); }
.session__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.session__device { font-size: 14px; font-weight: 500; }
.session__ip { font-family: var(--mono); font-size: 12px; color: var(--muted-2); }
.session__when { font-size: 12px; font-weight: 500; color: var(--muted-2); white-space: nowrap; }
.session__when.is-current { color: var(--ok); }
.sessions__foot { padding: 16px 22px; }

/* Appearance picker. The previews show each theme, so their colors are fixed on purpose. */
.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-opt { position: relative; display: flex; flex-direction: column; gap: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.theme-opt__input { position: absolute; opacity: 0; pointer-events: none; }
.theme-opt__preview {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color .2s, box-shadow .25s, transform .35s var(--ease-spring);
}
.theme-opt:hover .theme-opt__preview { transform: translateY(-2px); }
.theme-opt:active .theme-opt__preview { transform: scale(.97); }
.theme-opt__input:checked + .theme-opt__preview { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.theme-opt__input:focus-visible + .theme-opt__preview { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-opt__label { display: flex; align-items: center; gap: 8px; color: var(--label); font-size: 14px; font-weight: 500; }
.theme-opt__input:checked ~ .theme-opt__label { color: var(--text); }
.theme-opt__radio { width: 16px; height: 16px; flex: none; display: grid; place-items: center; border: 1.5px solid var(--line-input); border-radius: 50%; transition: border-color .2s; }
.theme-opt__radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform .35s var(--ease-spring); }
.theme-opt__input:checked ~ .theme-opt__label .theme-opt__radio { border-color: var(--accent); }
.theme-opt__input:checked ~ .theme-opt__label .theme-opt__radio::after { transform: scale(1); }
.theme-hint { font-size: 13px; color: var(--muted-2); animation: rise-sm .3s var(--ease-out); }

.tp {
  --tp-bg: #f6f6f4; --tp-surface: #fff; --tp-line: #e6e5e0; --tp-text: #dedcd6; --tp-accent: #4338ca;
  position: absolute; inset: 0;
  display: grid; grid-template-columns: 34% 1fr; grid-template-rows: 20% 1fr;
  background: var(--tp-bg);
}
.tp--dark { --tp-bg: #101113; --tp-surface: #17181b; --tp-line: #2a2b2f; --tp-text: #34353a; --tp-accent: #5b54f0; }
.tp--half { clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.tp__bar { grid-column: 1 / -1; display: flex; align-items: center; padding-left: 8%; background: var(--tp-surface); border-bottom: 1px solid var(--tp-line); }
.tp__bar::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tp-accent); }
.tp__side { padding: 12% 12%; display: flex; flex-direction: column; gap: 9%; background: var(--tp-surface); border-right: 1px solid var(--tp-line); }
.tp__side i { height: 5px; border-radius: 3px; background: var(--tp-text); }
.tp__side i:first-child { background: var(--tp-accent); opacity: .45; }
.tp__main { padding: 10%; display: flex; flex-direction: column; gap: 8%; }
.tp__main b { width: 45%; height: 7px; border-radius: 3px; background: var(--tp-accent); }
.tp__main i { flex: 1; border: 1px solid var(--tp-line); border-radius: 5px; background: var(--tp-surface); }
@media (max-width: 639.98px) { .themes { gap: 8px; } .theme-opt__label { font-size: 13px; gap: 6px; } }

/* ---------- motion ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes rise-sm { from { opacity: 0; transform: translateY(-3px); } }
@keyframes item-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes item-out { to { opacity: 0; transform: translateX(-16px); height: 0; margin-top: -2px; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: none; } }
@keyframes unblur { from { opacity: .2; filter: blur(5px); } }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@keyframes pulse { 50% { opacity: .5; } }
@keyframes orb-a { to { transform: translate(-90px, 130px) scale(1.15); } }
@keyframes orb-b { to { transform: translate(110px, -70px) scale(1.1); } }
@keyframes orb-c { to { transform: translate(-60px, -90px) scale(.85); } }

.rise { animation: rise .7s var(--ease-out) both; animation-delay: calc(var(--d, 0) * 80ms); }

/* Page-to-page motion (cross-document view transitions; ignored where unsupported). */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .16s ease-in both; }
::view-transition-new(root) { animation: vt-in .32s var(--ease-out) both; }
/* The "B" mark glides between landing, login and app. Only one is rendered per page. */
.wnav .brand__mark, .topbar .brand__mark, .login__brand .brand__mark, .login__mark { view-transition-name: v2-brand; }
::view-transition-group(v2-brand) { animation-duration: .5s; animation-timing-function: var(--ease-out); }
::view-transition-group(v2-tab-indicator),
::view-transition-group(v2-tabbar-indicator) { animation-duration: .38s; animation-timing-function: var(--ease-out); }
/* Theme switch: the new theme sweeps in as a circle from the chosen option (same-document transition). */
html.is-theming * { view-transition-name: none !important; }
html.is-theming::view-transition-old(root),
html.is-theming::view-transition-new(root) { mix-blend-mode: normal; }
html.is-theming::view-transition-old(root) { animation: none; }
html.is-theming::view-transition-new(root) { animation: theme-reveal .6s var(--ease-out); }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--reveal-x, 50%) var(--reveal-y, 0)); }
  to { clip-path: circle(var(--reveal-r, 150%) at var(--reveal-x, 50%) var(--reveal-y, 0)); }
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

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