/*
 * Partner Hub — the one stylesheet every app uses.
 *
 * Source: shared/styles/hub.css in the embedding-examples repository. Each app keeps a copy
 * (tools/sync.ts writes them), so an app copied out of the repository still has its design.
 *
 * Plain CSS: custom properties, nesting, light-dark() and container queries. The theme follows the
 * system unless <html data-theme="light|dark"> says otherwise.
 */

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light dark;

  --font-sans: var(--font-inter, 'Inter'), ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: var(--font-bricolage, 'Bricolage Grotesque'), var(--font-sans);
  --font-mono: var(--font-jetbrains, 'JetBrains Mono'), ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --bg: light-dark(#f4f5f2, #0c0e11);
  --bg-grid: light-dark(rgb(20 23 26 / 0.07), rgb(238 240 243 / 0.06));
  --surface: light-dark(#ffffff, #14171c);
  --surface-2: light-dark(#f0f1ed, #1a1e24);
  --surface-3: light-dark(#e4e6e0, #232830);
  --border: light-dark(#e1e3dd, #252a32);
  --border-strong: light-dark(#c8cbc3, #363c46);
  --text: light-dark(#14171a, #eef0f3);
  --text-muted: light-dark(#575d65, #a3aab5);
  --text-faint: light-dark(#8a9099, #6b727d);

  /* The roaster's mark: a crema bean on cobalt enamel. */
  --ink: #14171a;
  --crema: #f2dcc2;
  --brand: light-dark(#1f35a6, #3550d4);
  --accent: light-dark(#2944d6, #8ea2ff);
  --accent-strong: light-dark(#1c31a6, #b4c1ff);
  --accent-soft: light-dark(#e7ebfd, #1a2148);
  --accent-text: light-dark(#ffffff, #0a0f2e);
  --focus: light-dark(#2944d6, #a9b8ff);

  --kind-cafe: light-dark(#9a5a00, #f0b45a);
  --kind-office: light-dark(#2944d6, #8ea2ff);
  --kind-grocer: light-dark(#2e7a4a, #7fcf9a);

  --ok: light-dark(#2e7a4a, #6fcf97);
  --warn: light-dark(#9a5a00, #f2b45a);
  --info: light-dark(#2944d6, #8ea2ff);

  /* Code is set on a dark panel in both themes. */
  --code-bg: light-dark(#11141a, #090b0e);
  --code-border: light-dark(#11141a, #252a32);
  --code-rule: rgb(255 255 255 / 0.08);
  --code-text: #dde2ea;
  --code-muted: #7b8494;
  --code-mark: rgb(142 162 255 / 0.13);
  --code-key: #9fb1ff;
  --code-string: #a3e2b8;
  --code-number: #ffc27a;
  --code-literal: #e2a8ff;
  --code-keyword: #ff9ac1;
  --code-function: #7fd6ee;
  --code-punctuation: #9aa3b2;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px light-dark(rgb(16 24 40 / 0.06), rgb(0 0 0 / 0.4));
  --shadow: 0 1px 2px light-dark(rgb(16 24 40 / 0.05), rgb(0 0 0 / 0.35)),
    0 6px 20px -8px light-dark(rgb(16 24 40 / 0.12), rgb(0 0 0 / 0.5));
  --shadow-lg: 0 20px 48px -20px light-dark(rgb(16 24 40 / 0.26), rgb(0 0 0 / 0.7));

  --gutter: clamp(16px, 4vw, 40px);
  --content: 1440px;
  --topbar: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar) + 16px);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(var(--bg-grid) 1px, transparent 1.5px) 0 0 / 22px 22px,
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 15px/1.55 var(--font-sans);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ol,
ul,
dl,
dd,
figure,
fieldset,
pre {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

fieldset {
  border: 0;
  padding: 0;
  min-width: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;

  &:hover {
    color: var(--accent-strong);
  }
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

svg {
  flex-shrink: 0;
}

code,
pre,
kbd {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #ffffff;
  transition: top 0.2s var(--ease);

  &:focus {
    top: 12px;
  }
}

.container {
  width: 100%;
  max-width: var(--content);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main {
  flex: 1;
}

/* ---------------------------------------------------------------- brand */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;

  &:hover {
    color: var(--text);
  }

  & svg {
    width: 32px;
    height: 32px;
    color: var(--brand);
  }
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.brand-product {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);

  & .container {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar);
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

@media (width < 640px) {
  .brand-name,
  .brand-product,
  .menu-trigger .menu-label {
    display: none;
  }

  .topbar-actions {
    gap: 4px;
  }

  .portal-title > .avatar {
    display: none;
  }
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding-inline: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition:
    background-color 0.15s var(--ease),
    border-color 0.15s var(--ease),
    transform 0.15s var(--ease);

  &:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
  }

  &:active {
    transform: translateY(1px);
  }

  & svg {
    width: 18px;
    height: 18px;
  }
}

.button-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);

  &:hover {
    border-color: transparent;
    background: var(--accent-strong);
    color: var(--accent-text);
  }
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;

  &:hover {
    border-color: transparent;
    background: var(--surface-2);
  }
}

.button-icon {
  width: 38px;
  padding: 0;
}

.button-small {
  height: 30px;
  padding-inline: 10px;
  border-radius: 8px;
  font-size: 13px;
}

/* ---------------------------------------------------------------- menus (details/summary) */

.menu {
  position: relative;

  & > summary {
    list-style: none;

    &::-webkit-details-marker {
      display: none;
    }
  }

  &[open] > summary {
    background: var(--surface-2);
  }
}

.menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  max-width: 280px;
  transition: background-color 0.15s var(--ease);

  &:hover {
    background: var(--surface-2);
  }

  & .chevron {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform 0.2s var(--ease);
  }

  .menu[open] > & .chevron {
    transform: rotate(180deg);
  }
}

.menu-trigger-compact {
  padding-inline: 10px;
  text-transform: uppercase;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;

  & svg:first-child {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
  }
}

.menu-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
  min-width: 260px;
  max-width: min(340px, calc(100vw - 2 * var(--gutter)));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: menu-in 0.16s var(--ease);
}

.menu-heading {
  padding: 8px 10px 6px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  text-decoration: none;

  &:hover {
    background: var(--surface-2);
    color: var(--text);
  }

  &[aria-current='true'],
  &[aria-current='page'] {
    background: var(--accent-soft);

    &::after {
      content: '';
      width: 16px;
      height: 16px;
      margin-left: auto;
      background: var(--accent);
      mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")
        center / contain no-repeat;
    }
  }

  & small {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
  }
}

.menu-item-text {
  min-width: 0;
  line-height: 1.3;
}

.menu-separator {
  height: 1px;
  margin: 6px 4px;
  background: var(--border);
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

/* ---------------------------------------------------------------- avatar, chips */

.avatar {
  --kind: var(--kind-cafe);
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--kind) 16%, var(--surface));
  color: var(--kind);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;

  &[data-kind='office'] {
    --kind: var(--kind-office);
  }

  &[data-kind='grocer'] {
    --kind: var(--kind-grocer);
  }
}

.avatar-large {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  font-size: 15px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding-inline: 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.flag {
  font-size: 14px;
  line-height: 1;
}

/* ---------------------------------------------------------------- sign-in page */

.signin {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
  padding-block: clamp(24px, 5vw, 64px);
}

.signin-hero {
  position: sticky;
  top: calc(var(--topbar) + 24px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: min(640px, calc(100dvh - var(--topbar) - 64px));
  padding: clamp(28px, 4vw, 52px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(640px 360px at 0% 0%, rgb(76 106 255 / 0.5), transparent 65%),
    radial-gradient(560px 420px at 110% 120%, rgb(41 68 214 / 0.55), transparent 60%),
    linear-gradient(160deg, #141c44, #090c1c 70%);
  color: #eef1ff;
  box-shadow: var(--shadow-lg);
  isolation: isolate;

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.18;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23f2dcc2' stroke-width='1.4' stroke-linecap='round'%3E%3Cg transform='rotate(-30 30 30)'%3E%3Cellipse cx='30' cy='30' rx='7' ry='10'/%3E%3Cpath d='M30 20.5c-2.5 3-2.5 6.2 0 9.5s2.5 6.5 0 9.5'/%3E%3C/g%3E%3Cg transform='rotate(25 90 88)'%3E%3Cellipse cx='90' cy='88' rx='7' ry='10'/%3E%3Cpath d='M90 78.5c-2.5 3-2.5 6.2 0 9.5s2.5 6.5 0 9.5'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    mask-image: linear-gradient(200deg, black, transparent 75%);
  }

  & h1 {
    max-width: 14ch;
    font-family: var(--font-display);
    font-size: clamp(34px, 4.6vw, 60px);
    font-weight: 650;
    line-height: 1.02;
    letter-spacing: -0.025em;
    text-wrap: balance;
  }

  & p {
    max-width: 46ch;
    color: rgb(238 241 255 / 0.78);
    font-size: 16px;
    text-wrap: pretty;
  }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;

  .signin-hero & {
    color: #a9b8ff;
  }

  &::before {
    content: '';
    width: 18px;
    height: 1.5px;
    background: currentColor;
  }
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid rgb(238 241 255 / 0.14);

  & div {
    display: flex;
    flex-direction: column;
  }

  & dt {
    order: 2;
    color: rgb(238 241 255 / 0.6);
    font-size: 13px;
  }

  & dd {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 650;
    line-height: 1.1;
  }
}

.demo-note {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 8px 14px 8px 8px;
  border: 1px solid rgb(238 241 255 / 0.16);
  border-radius: 999px;
  background: rgb(238 241 255 / 0.07);
  color: rgb(238 241 255 / 0.9);
  font-size: 13px;

  & strong {
    font-weight: 600;
    color: #fff;
  }
}

.stack-badge {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #eef1ff;
  color: #090c1c;

  & svg {
    width: 15px;
    height: 15px;
  }
}

.signin-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 8px;

  & h2 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 650;
    letter-spacing: -0.015em;
  }
}

.hint {
  display: flex;
  gap: 10px;
  max-width: 60ch;
  color: var(--text-muted);
  font-size: 14px;

  & svg {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    color: var(--text-faint);
  }
}

.partner-list {
  display: grid;
  gap: 10px;
}

.partner-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    transform 0.18s var(--ease);

  &:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateY(-1px);

    & .partner-go {
      color: var(--accent);
      transform: translateX(2px);
    }
  }

  &[aria-current='true'] {
    border-color: var(--accent);
    box-shadow:
      0 0 0 3px var(--accent-soft),
      var(--shadow-sm);
  }
}

.partner-name {
  display: block;
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.partner-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 13px;
}

.partner-meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-faint);
}

.partner-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.partner-go {
  width: 20px;
  height: 20px;
  color: var(--text-faint);
  transition:
    transform 0.18s var(--ease),
    color 0.18s var(--ease);
}

.badge-current {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding-inline: 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11.5px;
  font-weight: 600;

  &::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
  }
}

@media (width < 960px) {
  .signin {
    grid-template-columns: minmax(0, 1fr);
  }

  .signin-hero {
    position: relative;
    top: 0;
    min-height: 0;
  }
}

@media (width < 520px) {
  .partner-card {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 12px 14px;
  }

  .partner-side .chip {
    display: none;
  }

  .partner-side {
    position: absolute;
    top: 12px;
    right: 12px;
  }

  .partner-go {
    display: none;
  }
}

/* ---------------------------------------------------------------- portal header */

.portal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 32px;
  padding-block: clamp(20px, 3.5vw, 40px) 20px;
}

.portal-title {
  display: flex;
  flex: 1 1 380px;
  align-items: center;
  gap: 16px;
  min-width: 0;

  & h1 {
    font-family: var(--font-display);
    font-size: clamp(24px, 2.6vw, 34px);
    font-weight: 650;
    line-height: 1.1;
    letter-spacing: -0.025em;
    text-wrap: balance;
  }

  & p {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 14.5px;
  }
}

.portal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;

  & > legend,
  & > .control-label {
    padding: 0;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}

.segmented {
  display: inline-flex;
  padding: 3px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  scrollbar-width: none;

  & label {
    position: relative;
    display: block;
  }

  & input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
  }

  & span {
    display: block;
    padding: 6px 12px;
    border-radius: 9px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    transition:
      background-color 0.15s var(--ease),
      color 0.15s var(--ease),
      box-shadow 0.15s var(--ease);
  }

  & label:hover span {
    color: var(--text);
  }

  & input:checked + span {
    background: var(--surface);
    color: var(--text);
    box-shadow:
      0 1px 2px rgb(0 0 0 / 0.08),
      0 0 0 1px var(--border);
  }

  & input:focus-visible + span {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
  }

  & input:disabled + span {
    opacity: 0.55;
  }
}

.segmented-custom span {
  font-style: italic;
}

@media (width < 720px) {
  .controls,
  .control,
  .segmented {
    width: 100%;
  }

  .segmented label {
    flex: 1;
    text-align: center;
  }
}

/* ---------------------------------------------------------------- notice */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--info) 30%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--info) 9%, var(--surface));
  font-size: 14px;

  & svg {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    color: var(--info);
  }
}

/* ---------------------------------------------------------------- workspace */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  align-items: start;
  gap: 24px;
  padding-bottom: 48px;
}

@media (width < 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- embed */

.embed-card {
  position: relative;
  min-height: 620px;
  overflow: hidden;

  &[data-state='ready'] {
    min-height: 0;
  }
}

.embed-host {
  & iframe {
    display: block;
    width: 100%;
    min-height: 620px;
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    opacity: 0;
    transition: opacity 0.4s var(--ease);

    [data-state='ready'] & {
      min-height: 0;
      opacity: 1;
    }
  }
}

.embed-skeleton {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: 120px 280px 1fr;
  gap: 16px;
  padding: 20px;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);

  .embed-card:is([data-state='ready'], [data-state='error']) & {
    opacity: 0;
  }

  & span {
    border-radius: var(--radius);
    background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%) 0 0 / 300% 100%;
    animation: shimmer 1.6s linear infinite;
  }

  & span:nth-child(4) {
    grid-column: span 3;
  }

  & span:nth-child(5) {
    grid-column: span 3;
  }

  & p {
    position: absolute;
    left: 50%;
    top: 50%;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 13.5px;
    box-shadow: var(--shadow);
    transform: translate(-50%, -50%);
  }
}

@keyframes shimmer {
  to {
    background-position: -300% 0;
  }
}

.embed-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  background: var(--surface);
  color: var(--text-muted);
  text-align: center;

  & svg {
    width: 32px;
    height: 32px;
    color: var(--warn);
  }

  & code {
    max-width: 60ch;
    color: var(--text-faint);
    overflow-wrap: anywhere;
  }
}

@media (width < 720px) {
  .embed-skeleton {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(3, 90px) 220px;

    & span:nth-child(n + 4) {
      grid-column: auto;
    }

    & span:nth-child(5) {
      display: none;
    }
  }
}

/* ---------------------------------------------------------------- inspector */

.inspector {
  position: sticky;
  top: calc(var(--topbar) + 16px);
  container: inspector / inline-size;
  max-height: calc(100dvh - var(--topbar) - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  & > summary {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 20px 14px;
    list-style: none;
    cursor: default;
    pointer-events: none;

    &::-webkit-details-marker {
      display: none;
    }

    & h2 {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 15px;
      font-weight: 650;
    }

    & p {
      margin-top: 2px;
      color: var(--text-muted);
      font-size: 13px;
    }

    & .chevron {
      display: none;
      width: 18px;
      height: 18px;
      margin-left: auto;
      color: var(--text-muted);
      transition: transform 0.2s var(--ease);
    }
  }

  &[open] > summary .chevron {
    transform: rotate(180deg);
  }
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px transparent;
  }

  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@media (width < 1180px) {
  .inspector {
    position: static;
    max-height: none;

    & > summary {
      cursor: pointer;
      pointer-events: auto;

      & .chevron {
        display: block;
      }
    }
  }
}

.tabs {
  display: flex;
  gap: 2px;
  margin-inline: 20px;
  border-bottom: 1px solid var(--border);

  & button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px 11px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 550;

    &:hover {
      color: var(--text);
    }

    &[aria-selected='true'] {
      color: var(--text);

      &::after {
        content: '';
        position: absolute;
        inset: auto 8px -1px;
        height: 2px;
        border-radius: 2px;
        background: var(--accent);
      }
    }
  }
}

.tab-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 18px 20px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;

  &[hidden] {
    display: none;
  }
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;

  & small {
    color: var(--text-faint);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
  }
}

.explain {
  color: var(--text-muted);
  font-size: 13px;
}

/* the renewal ring */

.renewal {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.ring {
  --progress: 1;
  position: relative;
  width: 92px;
  height: 92px;

  & svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
  }

  & circle {
    fill: none;
    stroke-width: 7;
  }

  & .ring-track {
    stroke: var(--surface-3);
  }

  & .ring-value {
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: calc(100 - var(--progress) * 100);
    transition: stroke-dashoffset 1s linear;
  }

  &[data-renewing] .ring-value {
    stroke: var(--ok);
    transition: none;
  }
}

.ring-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;

  & strong {
    font-size: 19px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
  }

  & small {
    max-width: 62px;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.15;
    text-wrap: balance;
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;

  & dt {
    color: var(--text-muted);
    font-size: 12px;
  }

  & dd {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  & div:last-child:nth-child(odd) {
    grid-column: span 2;
  }
}

.renew-button {
  grid-column: 1 / -1;
  justify-self: start;
}

/* code, JSON */

.code-block {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  color-scheme: dark;
}

.code-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--code-rule);
  color: var(--code-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;

  & span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.code-lang {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--code-rule);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.code,
.json {
  margin: 0;
  padding: 12px 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.65;
  tab-size: 2;
  counter-reset: line var(--first-line, 0);
}

.json {
  padding: 12px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-indent: 0;
}

.code .line {
  display: block;
  padding-right: 14px;
  white-space: pre;

  &::before {
    counter-increment: line;
    content: counter(line);
    display: inline-block;
    width: 3.2em;
    margin-right: 12px;
    padding-right: 10px;
    border-right: 1px solid var(--code-rule);
    color: var(--code-muted);
    text-align: right;
    user-select: none;
  }
}

.j-key {
  color: var(--code-key);
}

.j-string {
  color: var(--code-string);
}

.j-number {
  color: var(--code-number);
}

.j-literal {
  color: var(--code-literal);
}

.j-line {
  display: block;
}

.j-mark {
  margin-inline: -14px;
  padding-inline: 12px 14px;
  border-left: 2px solid var(--code-key);
  background: var(--code-mark);
}

/* events */

.events-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.events {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  gap: 4px 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 13px;
  animation: event-in 0.3s var(--ease);

  & time {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
  }

  & strong {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
  }

  & code {
    grid-column: 1 / -1;
    display: block;
    color: var(--text-muted);
    font-size: 11.5px;
    overflow-wrap: anywhere;
  }
}

.direction {
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;

  &[data-direction='in'] {
    background: color-mix(in srgb, var(--info) 14%, transparent);
    color: var(--info);
  }

  &[data-direction='out'] {
    background: var(--accent-soft);
    color: var(--accent-strong);
  }

  &[data-direction='token'] {
    background: color-mix(in srgb, var(--ok) 14%, transparent);
    color: var(--ok);
  }
}

.empty {
  padding: 28px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: center;
}

@keyframes event-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ---------------------------------------------------------------- footer */

.footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13.5px;

  & .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding-block: 22px;
  }

  & nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
  }

  & a {
    color: var(--text-muted);

    &:hover,
    &[aria-current='page'] {
      color: var(--text);
    }
  }
}

.footer-stacks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;

  & span {
    color: var(--text-faint);
  }
}

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

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