/* Built To Learn · Tools dashboard */

@font-face { font-family: "Oxanium"; src: url("/fonts/oxanium-medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Oxanium"; src: url("/fonts/oxanium-semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Oxanium"; src: url("/fonts/oxanium-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/plex-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

/* ---------- Tokens ---------- */

:root {
  /* Brand palette */
  --seal-red: #FF0C00;
  --deep-red: #701412;
  --gold: #E8B100;
  --putty: #E3ECE7;
  --green-black: #172A25;
  --gg-dark: #37514E;
  --gg-mid: #6C8582;
  --gg-light: #92A4A2;

  --font-display: "Oxanium", ui-sans-serif, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius-xl: 22px;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --shell: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
}

:root,
[data-theme="dark"] {
  --bg: #172A25;
  --bg-glow: rgba(146, 164, 162, .09);
  --surface: #1C322C;
  --surface-2: #213A34;
  --line: rgba(227, 236, 231, .08);
  --line-strong: rgba(227, 236, 231, .16);
  --text: #E3ECE7;
  --text-2: #A3B3B0;
  --text-3: #849A96;
  --eyebrow: var(--gold);
  --ring: var(--gold);
  --field: rgba(227, 236, 231, .045);
  --art: rgba(227, 236, 231, .035);
  --scrim: rgba(8, 16, 14, .62);
  --danger: #FF5A4F;
  --logo-bg: #F4F7F5;
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 1px 2px rgba(0, 0, 0, .2), 0 12px 32px -18px rgba(0, 0, 0, .55);
  --shadow-hover: inset 0 1px 0 rgba(255, 255, 255, .06), 0 2px 4px rgba(0, 0, 0, .2), 0 28px 56px -24px rgba(0, 0, 0, .7);
  --shadow-pop: 0 40px 90px -24px rgba(0, 0, 0, .7), 0 0 0 1px var(--line-strong);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #E3ECE7;
  --bg-glow: rgba(255, 255, 255, .55);
  --surface: #F3F7F5;
  --surface-2: #FFFFFF;
  --line: rgba(23, 42, 37, .09);
  --line-strong: rgba(23, 42, 37, .17);
  --text: #172A25;
  --text-2: #37514E;
  --text-3: #556C69;
  --eyebrow: var(--deep-red);
  --ring: var(--green-black);
  --field: rgba(255, 255, 255, .65);
  --art: rgba(23, 42, 37, .05);
  --scrim: rgba(23, 42, 37, .35);
  --danger: #C20A00;
  --logo-bg: #FFFFFF;
  --shadow: 0 1px 2px rgba(23, 42, 37, .05), 0 10px 28px -18px rgba(23, 42, 37, .28);
  --shadow-hover: 0 2px 4px rgba(23, 42, 37, .06), 0 26px 50px -24px rgba(23, 42, 37, .38);
  --shadow-pop: 0 40px 90px -24px rgba(23, 42, 37, .45), 0 0 0 1px var(--line);
  color-scheme: light;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 520px at 88% -8%, var(--bg-glow), transparent 65%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font: 500 11px/1 var(--font-body);
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  background: var(--field);
}

.i { width: 20px; height: 20px; stroke-width: 1.75; flex: none; }

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

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

/* Brand path graphic, faint, anchored bottom-right */
.backdrop {
  position: fixed;
  right: max(-6vw, -80px);
  bottom: -12vh;
  height: min(118vh, 1100px);
  aspect-ratio: 452 / 636;
  color: var(--art);
  pointer-events: none;
  z-index: 0;
}
.backdrop svg { width: 100%; height: 100%; fill: currentColor; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  transition: background-color .3s, box-shadow .3s, backdrop-filter .3s;
}
.topbar.is-scrolled {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  box-shadow: 0 1px 0 var(--line);
}
.topbar-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
}
.logo { height: 26px; width: auto; display: block; }
.logo-mark { fill: var(--seal-red); }
.logo-word { fill: currentColor; }
.brand-tag {
  font: 600 11px/1 var(--font-display);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: none;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: background-color .2s, border-color .2s, color .2s, transform .15s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-ghost { border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--field); border-color: color-mix(in srgb, var(--text) 30%, transparent); }
.btn-ghost[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary { background: var(--text); color: var(--bg); font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--text) 86%, var(--bg)); }
.btn-danger { color: var(--danger); padding-inline: 10px; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text-2);
  transition: background-color .2s, color .2s, transform .15s var(--ease);
}
.icon-btn:hover { background: var(--field); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

#theme-toggle .i-moon { display: none; }
[data-theme="light"] #theme-toggle .i-sun { display: none; }
[data-theme="light"] #theme-toggle .i-moon { display: block; }

/* ---------- Layout ---------- */

.shell {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(20px, 5vh, 56px) var(--gutter) 64px;
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 600 12px/1 var(--font-display);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--eyebrow);
  margin-bottom: 14px;
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

h1 {
  font: 600 clamp(30px, 1.6rem + 2.2vw, 46px)/1.05 var(--font-display);
  letter-spacing: -.01em;
}

/* ---------- Search ---------- */

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(360px, 100%);
  height: 48px;
  padding: 0 10px 0 14px;
  border-radius: var(--radius);
  background: var(--field);
  border: 1px solid var(--line-strong);
  color: var(--text-3);
  transition: border-color .2s, background-color .2s, box-shadow .2s;
}
.search:hover { border-color: color-mix(in srgb, var(--text) 26%, transparent); }
.search:focus-within {
  background: var(--surface-2);
  border-color: var(--ring);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ring) 18%, transparent);
  color: var(--text-2);
}
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: none;
  font-size: 15px;
  color: var(--text);
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search input:disabled { cursor: not-allowed; }
.search:has(input:disabled) { opacity: .5; }
.search:focus-within kbd { opacity: 0; }
.search kbd { transition: opacity .2s; }

/* ---------- Edit bar ---------- */

.editbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: -8px 0 24px;
  padding: 12px 12px 12px 18px;
  border-radius: var(--radius);
  border: 1px dashed color-mix(in srgb, var(--gold) 55%, transparent);
  background: color-mix(in srgb, var(--gold) 7%, transparent);
  animation: drop-in .35s var(--ease);
}
.editbar[hidden] { display: none; }
.editbar-lead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0; }
.editbar-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-2); }
.editbar.is-everyone {
  border-color: color-mix(in srgb, var(--seal-red) 60%, transparent);
  background: color-mix(in srgb, var(--seal-red) 7%, transparent);
}
.editbar-text strong { color: var(--text); font-weight: 600; font-size: 14px; }
.editbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Grid & tiles ---------- */

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 16px;
}

.cell { position: relative; min-width: 0; }
.grid.is-entering .cell { animation: rise .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }

.tile {
  --tile: var(--gg-dark);
  --tile-fg: var(--putty);
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100%;
  min-height: 196px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .25s, background-color .25s;
}
/* Cursor-following glow in the tile's own colour */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(340px circle at var(--mx, 30%) var(--my, 0%), color-mix(in srgb, var(--tile) 16%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity .35s;
}
.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--tile) 38%, var(--line-strong));
}
.tile:hover::before,
.tile:focus-visible::before { opacity: 1; }
.tile:active { transform: translateY(-1px) scale(.985); transition-duration: .12s; }
.tile:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }

.tile-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: 15px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 55%),
    var(--tile);
  color: var(--tile-fg);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .08),
    inset 0 1px 0 rgba(255, 255, 255, .2),
    0 8px 18px -10px color-mix(in srgb, var(--tile) 80%, transparent);
  transition: transform .5s var(--ease);
}
[data-theme="light"] .tile-icon { box-shadow: inset 0 0 0 1px rgba(23, 42, 37, .08), inset 0 1px 0 rgba(255, 255, 255, .3), 0 8px 18px -10px color-mix(in srgb, var(--tile) 80%, transparent); }
.tile-icon .i { width: 26px; height: 26px; stroke-width: 1.8; }
.tile:hover .tile-icon { transform: translateY(-1px) scale(1.06) rotate(-4deg); }

.tile-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile-name {
  font: 600 19px/1.2 var(--font-display);
  letter-spacing: .005em;
  overflow-wrap: anywhere;
}
.tile-desc {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-3);
}
.tile-host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-arrow {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  opacity: 0;
  transform: translate(-6px, 6px);
  transition: opacity .3s, transform .4s var(--ease), color .2s;
}
.tile:hover .tile-arrow,
.tile:focus-visible .tile-arrow,
.cell.is-first .tile-arrow { opacity: 1; transform: none; color: var(--text); }

.tile-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  font: 500 11px/1 var(--font-body);
  letter-spacing: .02em;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
}

/* Top search hit */
.cell.is-first .tile { border-color: color-mix(in srgb, var(--tile) 50%, var(--line-strong)); }
.cell.is-first .tile::before { opacity: 1; }
.enter-hint { display: none; }
.cell.is-first .enter-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}

/* Just-added flash */
.cell.is-new .tile { animation: pulse 1.4s var(--ease); }

/* Add tile */
.tile-add {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  background: transparent;
  border: 1.5px dashed var(--line-strong);
  box-shadow: none;
  color: var(--text-2);
  font: inherit;
  width: 100%;
}
.tile-add::before { display: none; }
.tile-add:hover {
  transform: none;
  box-shadow: none;
  border-color: color-mix(in srgb, var(--text) 40%, transparent);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  color: var(--text);
}
.tile-add .add-ring {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 15px;
  border: 1.5px dashed currentColor;
  transition: transform .5s var(--ease), background-color .25s, color .25s, border-color .25s;
}
.tile-add:hover .add-ring { transform: rotate(90deg); background: var(--text); color: var(--bg); border-color: var(--text); }
.tile-add .add-ring .i { width: 24px; height: 24px; stroke-width: 2; }
.tile-add .add-text { display: flex; flex-direction: column; gap: 4px; }
.tile-add .add-title { font: 600 16px/1.2 var(--font-display); color: var(--text); }
.tile-add .add-sub { font-size: 12.5px; color: var(--text-3); }

/* ---------- Edit mode ---------- */

.cell-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  gap: 6px;
  animation: pop-in .3s var(--ease) both;
}
.tool-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-2);
  box-shadow: 0 4px 12px -6px rgba(0, 0, 0, .4);
  transition: color .2s, background-color .2s, transform .15s var(--ease);
}
.tool-btn:hover { color: var(--text); background: color-mix(in srgb, var(--surface-2) 80%, var(--text)); }
.tool-btn:active { transform: scale(.92); }
.tool-btn .i { width: 17px; height: 17px; }
.tool-btn.grip { cursor: grab; touch-action: none; }

.is-editing .tile-badge { display: none; }
.is-editing .cell[data-id] .tile { cursor: grab; user-select: none; -webkit-user-select: none; }
.is-editing .cell[data-id] .tile:hover { transform: none; }
.is-editing .tile-arrow { display: none; }
.cell.is-hidden .tile { opacity: .42; filter: saturate(.3); border-style: dashed; }
.cell.is-hidden .tile-meta::after { content: "Hidden"; font-weight: 500; color: var(--text-2); }

.cell.is-placeholder .tile {
  opacity: .28;
  border-style: dashed;
  box-shadow: none;
}
.cell.is-placeholder .cell-tools { visibility: hidden; }
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  margin: 0;
  pointer-events: none;
  list-style: none;
  transition: none;
}
.drag-ghost .tile {
  box-shadow: var(--shadow-pop);
  transform: rotate(2deg) scale(1.03);
  transition: transform .2s var(--ease);
  border-color: color-mix(in srgb, var(--tile) 50%, var(--line-strong));
}
.drag-ghost .cell-tools { display: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* ---------- Empty state ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 72px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  animation: rise .4s var(--ease);
}
.empty[hidden] { display: none; }
.empty-title { font: 600 20px/1.3 var(--font-display); overflow-wrap: anywhere; }
.empty-sub { color: var(--text-2); margin-bottom: 12px; }

/* ---------- Footer ---------- */

.foot { position: relative; z-index: 1; }
.foot-inner {
  width: calc(100% - 2 * var(--gutter));
  max-width: calc(var(--shell) - 2 * var(--gutter));
  margin: 0 auto;
  padding: 20px 0 calc(24px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-3);
  border-top: 1px solid var(--line);
}
.foot kbd { font-size: 10.5px; padding: 3px 5px; }

/* ---------- Dialog ---------- */

.sheet {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.sheet[open] { display: flex; animation: sheet-in .38s var(--ease); }
.sheet::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in .3s ease;
}
.sheet form { display: flex; flex-direction: column; width: 100%; min-height: 0; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 10px 24px;
}
.sheet-head h2 { font: 600 20px/1.2 var(--font-display); }

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 24px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background:
    radial-gradient(220px circle at 0% 0%, color-mix(in srgb, var(--tile) 18%, transparent), transparent 70%),
    var(--bg);
  border: 1px solid var(--line);
  transition: background .3s;
}
.preview .tile-icon { width: 48px; height: 48px; border-radius: 13px; }
.preview .tile-icon .i { width: 24px; height: 24px; }
.preview-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.preview-name { font: 600 17px/1.2 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-host { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.field { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  padding: 0;
}
.field legend { margin-bottom: 7px; }
.optional { font-weight: 400; color: var(--text-3); margin-left: 4px; }
.field input[type="text"] {
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--field);
  font-size: 15px;
  outline: 0;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.field input[type="text"]::placeholder { color: var(--text-3); }
.field input[type="text"]:focus {
  border-color: var(--ring);
  background: var(--surface-2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ring) 18%, transparent);
}
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { font-size: 12.5px; color: var(--danger); min-height: 0; }
.field-error:empty { display: none; }

.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
}
.choice { position: relative; display: block; }
.choice input { position: absolute; inset: 0; z-index: 1; opacity: 0; margin: 0; cursor: pointer; }
.choice span {
  pointer-events: none;
  display: grid;
  place-items: center;
  height: 42px;
  border-radius: 11px;
  border: 1px solid var(--line);
  color: var(--text-2);
  transition: background-color .15s, color .15s, border-color .15s, transform .15s var(--ease);
}
.choice:hover span { border-color: var(--line-strong); color: var(--text); }
.choice input:checked + span { background: var(--text); color: var(--bg); border-color: var(--text); }
.choice input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 2px; }
.choice input:active + span { transform: scale(.92); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sw);
  border: 0;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.swatch input:checked + span {
  background: var(--sw);
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 0 0 3px var(--surface), 0 0 0 5px var(--text);
}

.sheet-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom)) 16px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, var(--bg));
}
.spacer { flex: 1; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 12px 12px 12px 18px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .5);
  transform: translate(-50%, 0);
  animation: toast-in .4s var(--ease);
}
.toast[hidden] { display: none; }
.toast.is-leaving { animation: toast-out .25s ease forwards; }
.toast button {
  border: 0;
  border-radius: 9px;
  padding: 6px 10px;
  background: color-mix(in srgb, var(--bg) 12%, transparent);
  color: inherit;
  font-weight: 600;
  font-size: 13px;
}
.toast button:hover { background: color-mix(in srgb, var(--bg) 22%, transparent); }
.toast button[hidden] { display: none; }

/* ---------- Motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 10px) scale(.97); } }
@keyframes pulse {
  0% { box-shadow: var(--shadow), 0 0 0 0 color-mix(in srgb, var(--tile) 55%, transparent); }
  100% { box-shadow: var(--shadow), 0 0 0 18px transparent; }
}

/* Circular reveal when switching theme */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Responsive ---------- */

@media (hover: none) {
  .foot-hint, .search kbd, .cell.is-first .enter-hint { display: none; }
}

@media (max-width: 720px) {
  .intro { flex-direction: column; align-items: stretch; gap: 20px; margin-bottom: 24px; }
  .search { width: 100%; }
  .btn-label { display: none; }
  #customize-toggle { width: 40px; padding: 0; }
  .editbar { padding: 14px; }
  .editbar-actions { width: 100%; }
  .editbar-actions .btn { flex: 1; }
}

/* Phones: compact, home-screen-like two-up grid */
@media (max-width: 560px) {
  .topbar-inner { height: 64px; }
  .logo { height: 22px; }
  .brand { gap: 10px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { min-height: 0; padding: 16px; gap: 14px; border-radius: 18px; }
  .tile-icon { width: 48px; height: 48px; border-radius: 13px; }
  .tile-icon .i { width: 24px; height: 24px; }
  .tile-name { font-size: 16.5px; }
  .tile-desc { display: none; }
  .tile-meta { padding-top: 0; border-top: 0; margin-top: -8px; }
  .tile-arrow { display: none; }
  .tile-badge { top: 14px; right: 14px; font-size: 10px; padding: 4px 6px; }
  .tile-add { min-height: 140px; }
  .tile-add .add-sub { display: none; }
  .cell-tools { top: 8px; right: 8px; gap: 4px; }
  .backdrop { right: -30vw; opacity: .7; }

  .sheet {
    width: 100vw;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  .sheet[open] { animation: sheet-up .4s var(--ease); }
  .sheet-body { padding-inline: 18px; }
  .sheet-head { padding-left: 18px; }
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- Account ---------- */

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font: 600 15px/1 var(--font-display);
  transition: border-color .2s, transform .15s var(--ease);
}
.avatar:hover { border-color: color-mix(in srgb, var(--text) 40%, transparent); }
.avatar:active { transform: scale(.94); }
.avatar.is-admin { border-color: transparent; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--seal-red); }

.menu {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 240px;
  max-width: calc(100vw - 16px);
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.menu:popover-open { animation: drop-in .25s var(--ease); }
.menu-label { font-size: 12px; color: var(--text-3); }
.menu-email { margin-top: 2px; font-weight: 500; overflow-wrap: anywhere; }
.menu-role {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font: 600 10.5px/1.4 var(--font-display);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #fff;
  background: var(--seal-red);
}
.menu-item {
  display: block;
  margin: 12px -6px -6px;
  padding: 10px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.menu-item:hover { background: var(--field); }

/* ---------- Section tabs ---------- */

.sections-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tabs {
  position: relative;
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--field);
  border: 1px solid var(--line);
  transition: opacity .2s;
}
.tabs-ink {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: var(--ink-w, 0);
  transform: translateX(var(--ink-x, 0));
  border-radius: 999px;
  background: var(--text);
  transition: transform .45s var(--ease), width .45s var(--ease);
}
.tab {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  font: 600 14px/1 var(--font-display);
  letter-spacing: .02em;
  transition: color .3s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--bg); }
.tab-count {
  min-width: 20px;
  padding: 3px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 16%, transparent);
  font: 600 11px/1 var(--font-body);
  text-align: center;
}
.tab-count:empty { display: none; }
.sections-hint { font-size: 13px; color: var(--text-3); }
.is-searching .tabs { opacity: .45; }

.panel-title { display: none; }
.is-searching .panel-title {
  display: block;
  margin: 0 0 12px;
  font: 600 12px/1 var(--font-display);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-3);
}
.is-searching .panel + .panel { margin-top: 28px; }

/* ---------- Compact tiles (External) ---------- */

.grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 10px;
}
.tile-compact {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  min-height: 0;
  padding: 12px 14px 12px 12px;
  border-radius: 16px;
}
.tile-compact .tile-icon { width: 44px; height: 44px; border-radius: 12px; }
.tile-compact .tile-icon .i { width: 22px; height: 22px; }
.tile-compact .tile-body { flex: 1; gap: 2px; }
.tile-compact .tile-name { display: flex; align-items: center; gap: 8px; font-size: 15.5px; }
.tile-compact .tile-sub {
  font-size: 12.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-compact .tile-badge { position: static; padding: 3px 6px; font-size: 10px; }
.tile-compact .tile-arrow,
.tile-compact .enter-hint { flex: none; }
.tile-compact:hover .tile-icon { transform: scale(1.06); }

.is-editing .tile-compact { padding-right: 92px; }
.is-editing .grid-compact { grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr)); }
.grid-compact .cell-tools { top: 50%; right: 10px; transform: translateY(-50%); animation: none; }

.tile-add.tile-compact { justify-content: flex-start; text-align: left; min-height: 70px; }
.tile-add.tile-compact .add-ring { width: 44px; height: 44px; border-radius: 12px; }
.tile-add.tile-compact .add-ring .i { width: 20px; height: 20px; }
.tile-add.tile-compact .add-title { font-size: 15px; }
.tile-add.tile-compact .add-text { gap: 2px; }

/* Site logos sit on a light square so any brand mark reads */
.tile-icon.is-logo {
  background: var(--logo-bg);
  box-shadow: inset 0 0 0 1px rgba(23, 42, 37, .08), 0 6px 16px -10px rgba(0, 0, 0, .5);
}
.tile-icon.is-logo img { width: 62%; height: 62%; object-fit: contain; border-radius: 4px; }

.is-everyone .tile-add { border-color: color-mix(in srgb, var(--seal-red) 55%, transparent); }

/* ---------- Segmented controls ---------- */

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--line-strong);
}
.segmented[hidden] { display: none; }
.segmented button,
.segmented label span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color .2s, color .2s;
}
.segmented button:hover,
.segmented label:hover span { color: var(--text); }
.segmented button[aria-checked="true"],
.segmented input:checked + span { background: var(--text); color: var(--bg); }
.segmented label { position: relative; flex: 1; display: flex; }
.segmented label span { flex: 1; pointer-events: none; }
.segmented input { position: absolute; inset: 0; z-index: 1; opacity: 0; margin: 0; cursor: pointer; }
.segmented input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 1px; }
.segmented-form { display: flex; width: 100%; }
.segmented-form label span { height: 36px; font-size: 14px; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

.choice-logo span { font: 600 10.5px/1 var(--font-display); letter-spacing: .06em; text-transform: uppercase; }

@media (max-width: 720px) {
  .sections-bar { margin-bottom: 14px; }
  .sections-hint { flex-basis: 100%; }
  .editbar-lead { width: 100%; }
}
@media (max-width: 560px) {
  .avatar { width: 34px; height: 34px; font-size: 14px; }
  .topbar-actions { gap: 4px; }
  .grid-compact { grid-template-columns: 1fr; }
  .tile-compact { padding: 12px; }
  .tile-compact .tile-name { font-size: 15px; }
  .tile-add.tile-compact { min-height: 0; }
  .tile-add.tile-compact .add-sub { display: block; }
}
@media (max-width: 400px) {
  .brand-tag { display: none; }
}
