/* KB Web's fonts (the site's own font files): Source Sans 3 for text,
   Josefin Sans for subheadings, Ephemera for titles, IBM Plex Mono for labels and buttons */
@font-face { font-family: 'Ephemera Egyptian'; src: url('/Assets/EphemeraEgyptian-CondensedMedium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Palm Canyon Drive'; src: url('/Assets/PalmCanyonDrive-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

/* KB Studio's tokens: dark by default, light via <html data-theme="light"> */
:root {
  --kb-fg: #f5f0e8;
  --kb-accent: #16b7e1;
  --kb-accent-hover: #4dcbeb;
  --kb-on-accent: #04121e;
  --kb-cream: #faf0bd;
  --kb-navy: #012e48;
  --kb-ground: #061826;
  --kb-surface: #0a1c2b;
  --kb-stage: #0d1f2d;
  --kb-scrim: rgba(2, 10, 18, 0.6);
  --kb-danger: #e0665f;
  --kb-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --f-display: 'Ephemera Egyptian', Georgia, serif;
  --f-heading: 'Josefin Sans', sans-serif;
  --f-body: 'Source Sans 3', sans-serif;
  --f-label: 'IBM Plex Mono', monospace;
  /* Size per kind of text (1 = standard), set in the edit mode */
  --s-display: 1; --s-heading: 1; --s-body: 1; --s-label: 1;
  --line: color-mix(in srgb, var(--kb-fg) 12%, transparent);
  --muted: color-mix(in srgb, var(--kb-fg) 62%, transparent);
  color-scheme: dark;
}
:root[data-theme='light'] {
  --kb-fg: #012e48;
  --kb-accent: #0a87ae;
  --kb-accent-hover: #08779a;
  --kb-on-accent: #ffffff;
  --kb-cream: #9c7a00;
  --kb-navy: #e9eef2;
  --kb-ground: #f7f5ef;
  --kb-surface: #ffffff;
  --kb-stage: #ece9e1;
  --kb-scrim: rgba(1, 46, 72, 0.25);
  --kb-danger: #b8352d;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  color: var(--kb-fg); font-family: var(--f-body); font-weight: 400; font-size: calc(16px * var(--s-body)); line-height: 1.4; -webkit-font-smoothing: antialiased;
  background-color: var(--kb-stage);
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-weight: 400; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--kb-accent); outline-offset: 2px; }
.kb-btn { font-family: var(--f-label); font-size: calc(12px * var(--s-label)); font-weight: 500; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; white-space: nowrap; }
.kb-btn-danger { --kb-btn-ring: color-mix(in srgb, var(--kb-danger) 55%, transparent); --kb-btn-fill: color-mix(in srgb, var(--kb-danger) 14%, transparent); color: var(--kb-danger); }
.kb-btn-danger-solid { --kb-btn-base: var(--kb-danger); --kb-btn-ring: transparent; --kb-btn-fill: var(--kb-danger); color: #fff; }

/* ── Local-build strip ─────────────────────────────────────────── */
.dev {
  display: flex; align-items: center; justify-content: center; gap: 8px 14px; flex-wrap: wrap;
  padding: 6px 16px; font-size: calc(13px * var(--s-body)); background: var(--kb-cream); color: #012e48;
}
:root:not([data-theme='light']) .dev { color: #061826; }
:root[data-theme='light'] .dev { background: #faf0bd; }
.dev label { display: flex; align-items: center; gap: 6px; }
.dev select { height: 26px; padding: 0 6px; font-size: calc(13px * var(--s-body)); color: #012e48; background: rgb(255 255 255 / 0.55); border: 1px solid rgb(1 46 72 / 0.3); border-radius: 5px; color-scheme: light; }

/* ── Header ────────────────────────────────────────────────────── */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 24px; min-height: 64px; padding: 8px clamp(16px, 3vw, 32px);
  background: var(--kb-ground); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand-mark {
  display: block; height: 30px; aspect-ratio: 28.9 / 28.4; background: var(--kb-fg);
  -webkit-mask: url(/kbadmin/kb-mark.svg) center / contain no-repeat; mask: url(/kbadmin/kb-mark.svg) center / contain no-repeat;
}
.brand-word { font: 400 29px/1 'Palm Canyon Drive', cursive; padding-top: 3px; }
.nav { display: flex; gap: 20px; }
.nav a { font-family: var(--f-label); font-size: calc(12px * var(--s-label)); letter-spacing: .12em; text-transform: uppercase; text-decoration: none; padding: 4px 0; color: var(--muted); border-bottom: 2px solid transparent; transition: color .15s; }
.nav a:hover { color: var(--kb-fg); }
.nav a[aria-current='page'] { color: var(--kb-fg); border-bottom-color: var(--kb-accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); transition: color .15s, background .15s; }
.icon-btn:hover { color: var(--kb-fg); background: color-mix(in srgb, var(--kb-fg) 8%, transparent); }
.who { display: flex; align-items: center; gap: 8px; font-size: calc(15px * var(--s-body)); }
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: calc(15px * var(--s-body)); line-height: 1;
  background: color-mix(in srgb, var(--kb-fg) 10%, transparent);
}

.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: clamp(24px, 4vw, 48px) clamp(16px, 3vw, 32px) 64px; flex: 1; display: flex; flex-direction: column; }

/* ── Portal ────────────────────────────────────────────────────── */
.hello { font-family: var(--f-display); font-weight: 500; text-transform: uppercase; font-size: calc(clamp(40px, 5vw, 60px) * var(--s-display) * var(--e, 1)); line-height: 1; margin-bottom: 24px; }
.tiles { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; isolation: isolate;
  min-height: clamp(340px, 58vh, 560px); padding: 24px; border-radius: 12px; text-decoration: none;
  color: #fff; background: #012e48;
}
.tile img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--kb-ease); }
.tile::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgb(1 20 32 / 0) 45%, rgb(1 20 32 / 0.78) 100%); }
.tile-studio::after { display: none; }
.tile img.tile-art { position: absolute; inset: 8% auto auto 50%; z-index: -2; width: 72%; height: auto; object-fit: contain; transform: translateX(-50%); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .tile:hover img { transform: scale(1.035); }
  .tile:hover img.tile-art { transform: translateX(-50%) scale(1.035); }
  .tile:hover .tile-go { transform: translateX(4px); }
}
.tile-name { display: flex; align-items: center; gap: 8px; font-family: var(--f-display); font-weight: 500; text-transform: uppercase; font-size: calc(40px * var(--s-display) * var(--e, 1)); line-height: 1; }
.tile-mark { display: block; flex: none; height: calc(35px * var(--mark, 1)); aspect-ratio: 28.9 / 28.4; background: #fff; -webkit-mask: url(/kbadmin/kb-mark.svg) center / contain no-repeat; mask: url(/kbadmin/kb-mark.svg) center / contain no-repeat; }
.tile-about { margin-top: 8px; font-size: calc(17px * var(--s-body) * var(--e, 1)); line-height: 1.3; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: calc(14px * var(--s-body)); }
.tile-role { font-family: var(--f-label); font-size: calc(11px * var(--s-label) * var(--e, 1)); letter-spacing: .12em; text-transform: uppercase; opacity: .9; }
.tile-go { display: flex; align-items: center; gap: 6px; font-family: var(--f-label); font-size: calc(12px * var(--s-label) * var(--e, 1)); letter-spacing: .12em; text-transform: uppercase; transition: transform .25s var(--kb-ease); }

.manage {
  display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; margin-top: 12px; padding: 16px 24px; border-radius: 12px;
  background: var(--kb-surface); border: 1px solid var(--line);
}
.manage h2 { font-family: var(--f-heading); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: calc(17px * var(--s-heading) * var(--e, 1)); }
.manage p { color: var(--muted); font-size: calc(15px * var(--s-body) * var(--e, 1)); }
/* Centre on the letters themselves, not the line box: each font has its own spacing above and below (works with any font chosen in the edit mode) */
.manage h2, .manage p { text-box: trim-both cap alphabetic; }
.manage .kb-btn { margin-left: auto; }

.empty { max-width: 460px; margin: auto; text-align: center; padding: 40px 0; }
.empty h1 { font-family: var(--f-display); font-weight: 500; text-transform: uppercase; font-size: calc(44px * var(--s-display)); line-height: 1; margin-bottom: 12px; }
.empty p { color: var(--muted); font-size: calc(17px * var(--s-body)); }

/* ── Edit mode (portal administrators) ─────────────────────────── */
.hello-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; margin-bottom: 24px; }
.hello-row .hello { margin-bottom: 0; min-width: 0; overflow-wrap: anywhere; }
.editbar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; padding: 12px 16px; border-radius: 12px;
  background: #012e48; color: #f5f0e8; --kb-fg: #f5f0e8; --kb-accent: #16b7e1; --kb-accent-hover: #4dcbeb; --kb-on-accent: #04121e;
  --line: rgb(245 240 232 / 0.2); --muted: rgb(245 240 232 / 0.72);
}
.editbar-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editbar-top > span { flex: 1 1 200px; font-size: calc(15px * var(--s-body)); }
.editbar-fonts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.editbar .pick option { color: #012e48; background: #fff; }
.ed {
  cursor: text; border-radius: 3px; outline: none; min-width: 1ch; display: inline-block;
  box-shadow: 0 1px 0 0 currentColor; background: color-mix(in srgb, currentColor 8%, transparent); padding-inline: 3px; margin-inline: -3px;
  transition: background .15s;
}
.ed:hover { background: color-mix(in srgb, currentColor 16%, transparent); }
.ed:focus { background: color-mix(in srgb, currentColor 20%, transparent); box-shadow: 0 2px 0 0 var(--kb-accent); }
.ed:empty::before { content: attr(data-empty); opacity: .6; }
.tile[data-editing='true'] { --kb-accent: #16b7e1; cursor: default; }
.tile[data-editing='true'] img:not(.tile-art) { transform: none !important; }
.tile[data-editing='true'] img.tile-art { transform: translateX(-50%) !important; }
.tile-tools { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border-radius: 5px; cursor: pointer; white-space: nowrap;
  font-family: var(--f-label); font-size: calc(11px * var(--s-label)); letter-spacing: .08em; text-transform: uppercase; color: #012e48; background: #f5f0e8; transition: background .15s;
}
.chip:hover { background: #fff; }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.chip:has(input:focus-visible) { outline: 2px solid #16b7e1; outline-offset: 2px; }
.chip input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.size { display: flex; align-items: center; gap: 8px; }
.size input { flex: 1; min-width: 0; margin: 0; accent-color: var(--kb-accent); }
.size output { flex: none; width: 44px; text-align: right; font-size: 13px; }
.tile-mark-pick { display: block; flex: none; }
[data-sel] { cursor: pointer; }
[data-selected='true'] { outline: 2px solid #16b7e1; outline-offset: 3px; border-radius: 3px; }
.selbar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); font-size: calc(15px * var(--s-body)); }
.selbar b { font-weight: 600; }
.selbar .size { flex: 1 1 180px; }
.selbar .pick { width: 190px; }
.tile-link { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-family: var(--f-label); font-size: calc(11px * var(--s-label)); letter-spacing: .08em; text-transform: uppercase; }
.tile-link input {
  flex: 1; min-width: 0; height: 30px; padding: 0 8px; border-radius: 5px; font-family: var(--f-body); font-size: calc(14px * var(--s-body)); letter-spacing: 0; text-transform: none;
  color: #012e48; background: rgb(245 240 232 / 0.94); border: 0;
}
.tile-link input::placeholder { color: rgb(1 46 72 / 0.6); }

/* ── Brukere ───────────────────────────────────────────────────── */
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 20px; }
.head h1 { font-family: var(--f-display); font-weight: 500; text-transform: uppercase; font-size: calc(clamp(40px, 5vw, 60px) * var(--s-display)); line-height: 1; }
.head .kb-btn { margin-left: auto; }
.tools { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 2px; flex-wrap: wrap; }
.filters button { height: 32px; padding: 0 12px; font-family: var(--f-label); font-size: calc(11px * var(--s-label)); letter-spacing: .1em; text-transform: uppercase; border-radius: 5px; color: var(--muted); transition: color .15s, background .15s; }
.filters button:hover { color: var(--kb-fg); }
.filters button[aria-pressed='true'] { color: var(--kb-fg); background: color-mix(in srgb, var(--kb-fg) 10%, transparent); }
.filters small { font-family: var(--f-label); font-size: calc(11px * var(--s-label)); opacity: .7; margin-left: 4px; }
.field, .pick {
  height: 36px; padding: 0 10px; font-size: calc(15px * var(--s-body)); border-radius: 5px;
  background: color-mix(in srgb, var(--kb-fg) 5%, transparent); border: 1px solid color-mix(in srgb, var(--kb-fg) 18%, transparent);
  transition: border-color .15s;
}
.field:focus, .pick:focus { outline: none; border-color: var(--kb-accent); }
.search { margin-left: auto; width: min(260px, 100%); }
.pick {
  appearance: none; -webkit-appearance: none; width: 100%; padding-right: 26px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%237f94a3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.pick:hover { border-color: color-mix(in srgb, var(--kb-fg) 40%, transparent); }
.pick[data-none='true'] { color: var(--muted); }
.pick option { color: #012e48; background: #fff; }
:root:not([data-theme='light']) .pick option { color: #f5f0e8; background: #0a1c2b; }

.card { background: var(--kb-surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.grid { display: grid; grid-template-columns: minmax(200px, 1.5fr) repeat(3, minmax(130px, 1fr)) 96px 34px; align-items: center; column-gap: 12px; padding: 0 16px; }
.grid-head { height: 40px; font-family: var(--f-label); font-size: calc(11px * var(--s-label)); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.row { min-height: 64px; padding-block: 10px; border-bottom: 1px solid var(--line); transition: background .15s; }
.row:last-child { border-bottom: 0; }
.row[data-off='true'] .who-cell, .row[data-off='true'] .locked, .row[data-off='true'] .pick { opacity: .55; }
.who-cell { display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; }
.who-cell > span:last-child { min-width: 0; }
.who-name { display: block; font-size: calc(17px * var(--s-body)); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-cell:hover .who-name { color: var(--kb-accent); }
.who-sub { display: block; font-size: calc(14px * var(--s-body)); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.locked { font-size: calc(15px * var(--s-body)); padding-left: 11px; }
.locked-none { color: color-mix(in srgb, var(--kb-fg) 40%, transparent); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; font-family: var(--f-label); font-size: calc(10px * var(--s-label)); letter-spacing: .08em; text-transform: uppercase; line-height: 1; white-space: nowrap; }
.tag-active { color: color-mix(in srgb, var(--kb-fg) 80%, transparent); background: color-mix(in srgb, var(--kb-fg) 8%, transparent); }
.tag-invited { color: #012e48; background: #faf0bd; }
.tag-disabled { color: var(--kb-danger); background: color-mix(in srgb, var(--kb-danger) 12%, transparent); }
.cell-label { display: none; }
.none-found { padding: 40px 16px; text-align: center; color: var(--muted); }

/* Phones and small tablets: one card per person */
@media (max-width: 899px) {
  .top { column-gap: 14px; }
  .editbar { position: static; }
  /* A phone can't show the bar and the tile at once: what's selected is edited from the bottom of the screen */
  .selbar:not(:empty) { position: fixed; z-index: 30; inset: auto 0 0 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #012e48; }
  .selbar[data-idle='true'] { position: static; padding: 12px 0 0; background: none; }
  .who-text { display: none; }
  .search { margin-left: 0; width: 100%; }
  .grid-head { display: none; }
  .grid { grid-template-columns: minmax(0, 1fr) auto 34px; row-gap: 10px; padding-block: 14px; }
  .cell { grid-column: 1 / -1; display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 8px; }
  .cell-label { display: block; font-family: var(--f-label); font-size: calc(11px * var(--s-label)); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .locked { padding-left: 0; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .tile { min-height: 230px; padding: 20px; }
  .tile img.tile-art { display: none; }
  .tile::after { background: linear-gradient(180deg, rgb(1 20 32 / 0.1) 0%, rgb(1 20 32 / 0.82) 72%); }
  .manage .kb-btn { margin-left: 0; }
}

/* ── Sheet (a person, a new person) ────────────────────────────── */
dialog.sheet {
  position: fixed; inset: 0 0 0 auto; width: min(460px, 100vw); max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--kb-surface); color: var(--kb-fg); border-left: 1px solid var(--line);
}
dialog.sheet:focus { outline: none; }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .28s var(--kb-ease); }
dialog.sheet::backdrop { background: var(--kb-scrim); animation: fade-in .2s ease; }
@keyframes sheet-in { from { transform: translateX(32px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.sheet[open], dialog.sheet::backdrop { animation: none; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-family: var(--f-display); font-weight: 500; text-transform: uppercase; font-size: calc(32px * var(--s-display)); line-height: 1; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 24px; }
.sheet-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sec { display: flex; flex-direction: column; gap: 14px; }
.sec h3 { font-family: var(--f-heading); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: calc(15px * var(--s-heading)); }
.lab { display: flex; flex-direction: column; gap: 5px; font-family: var(--f-label); font-size: calc(11px * var(--s-label)); letter-spacing: .12em; text-transform: uppercase; }
.lab > * { font-family: var(--f-body); letter-spacing: 0; text-transform: none; }
.hint { font-size: calc(14px * var(--s-body)); line-height: 1.3; color: var(--muted); }
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.kinds .kb-btn { width: 100%; }
.switch-row { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; }
.switch-row > span:first-child { flex: 1; min-width: 0; font-size: calc(15px * var(--s-body)); display: flex; flex-direction: column; gap: 2px; }
.switch { flex: none; position: relative; width: 38px; height: 22px; border-radius: 11px; background: color-mix(in srgb, var(--kb-fg) 22%, transparent); transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--kb-ease); }
[aria-checked='true'] .switch { background: var(--kb-accent); }
[aria-checked='true'] .switch::after { transform: translateX(16px); }
.switch-row:disabled { cursor: not-allowed; }
.switch-row:disabled .switch { opacity: .5; }
.check { display: flex; align-items: center; gap: 10px; font-size: calc(15px * var(--s-body)); cursor: pointer; min-height: 28px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--kb-accent); flex: none; }
.facts { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 6px 12px; font-size: calc(15px * var(--s-body)); }
.facts dt { color: var(--muted); font-family: var(--f-label); font-size: calc(11px * var(--s-label)); letter-spacing: .08em; text-transform: uppercase; padding-top: 3px; }
.facts dd { overflow-wrap: anywhere; }
.err { font-size: calc(14px * var(--s-body)); color: var(--kb-danger); }
.later { display: flex; flex-wrap: wrap; gap: 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100;
  padding: 8px 16px; border-radius: 5px; font-size: calc(15px * var(--s-body)); white-space: nowrap;
  background: var(--kb-fg); color: var(--kb-ground); transition: opacity .2s; pointer-events: none;
}
.toast[data-show='false'] { opacity: 0; }
.toast[data-error='true'] { background: var(--kb-danger); color: #fff; }

/* Button (same as KB Studio) */
@property --kb-btn-r { syntax: '<percentage>'; inherits: true; initial-value: 0%; }
@property --kb-btn-x { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --kb-btn-y { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
.kb-btn {
  --kb-btn-base: transparent;
  --kb-btn-ring: color-mix(in srgb, var(--kb-fg) 32%, transparent);
  --kb-btn-fill: color-mix(in srgb, var(--kb-fg) 14%, transparent);
  --kb-btn-radius: 5px;
  --kb-btn-ease-hover: cubic-bezier(0.34, 2.27, 0.64, 1);
  --kb-btn-ease-click: cubic-bezier(0.4, 0, 0.2, 1);
  --kb-btn-ease-fill: cubic-bezier(0.32, 0.72, 0, 1);
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--kb-btn-radius);
  line-height: 1;
  color: var(--kb-fg);
  background: transparent; outline: none;
  user-select: none; -webkit-tap-highlight-color: transparent;
  transition: color 0.25s ease-out,
    --kb-btn-r 0.45s var(--kb-btn-ease-fill),
    --kb-btn-x 0.45s var(--kb-btn-ease-fill), --kb-btn-y 0.45s var(--kb-btn-ease-fill);
  cursor: pointer;
}
/* Background layer: base colour + ring + the growing circle, clipped by its own radius */
.kb-btn::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  border-radius: var(--kb-btn-radius);
  background:
    radial-gradient(circle farthest-corner at var(--kb-btn-x) var(--kb-btn-y), var(--kb-btn-fill) var(--kb-btn-r), transparent var(--kb-btn-r)),
    var(--kb-btn-base);
  box-shadow: inset 0 0 0 1px var(--kb-btn-ring);
  transition: scale 0.4s var(--kb-btn-ease-hover), transform 0.15s var(--kb-btn-ease-click), box-shadow 0.25s ease-out;
}
/* Keyboard focus ring */
.kb-btn::after {
  content: ''; position: absolute; inset: -2px; pointer-events: none;
  border-radius: calc(var(--kb-btn-radius) + 2px);
  transition: box-shadow 0.3s var(--kb-btn-ease-fill), scale 0.4s var(--kb-btn-ease-hover);
}
.kb-btn:focus-visible::after { box-shadow: 0 0 0 2px var(--kb-accent); scale: 1.065 1.095; }
.kb-btn:focus-visible { --kb-btn-r: 100%; }
.kb-btn:not(:disabled):active::before { transform: scale(0.955, 0.925); }
.kb-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.kb-btn:not(:disabled):hover { --kb-btn-ring: color-mix(in srgb, var(--kb-fg) 55%, transparent); }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .kb-btn:not(:disabled):hover {
    --kb-btn-r: 100%;
    transition: color 0.25s ease-out,
      --kb-btn-r 1.25s var(--kb-btn-ease-fill),
      --kb-btn-x 0.5s ease-out, --kb-btn-y 0.5s ease-out;
  }
  .kb-btn:not(:disabled):is(:hover, :focus-visible)::before {
    scale: 1.065 1.095;
    transition: scale 0.425s 0.05s var(--kb-btn-ease-hover), transform 0.15s var(--kb-btn-ease-click), box-shadow 0.25s ease-out;
  }
  /* Entering: jump the circle to the pointer before it starts growing */
  .kb-btn[data-fx-snap] { transition: color 0.25s ease-out, --kb-btn-r 1.25s var(--kb-btn-ease-fill) !important; }
}
/* Touch / reduced motion: plain colour change, no circle */
@media not ((hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference)) {
  .kb-btn:not(:disabled):hover { --kb-btn-r: 100%; --kb-btn-x: 50%; --kb-btn-y: 50%; transition: color 0.25s ease-out, --kb-btn-r 0.2s ease-out; }
}
.kb-btn-primary, .kb-btn[data-active='true'] {
  --kb-btn-base: var(--kb-accent); --kb-btn-ring: transparent; --kb-btn-fill: var(--kb-accent-hover);
  color: var(--kb-on-accent);
}
.kb-btn-primary:not(:disabled):hover, .kb-btn[data-active='true']:not(:disabled):hover { --kb-btn-ring: transparent; }
