/* Theme tokens are injected into :root by the server (see THEME_* env vars)
   and can be overridden per-embed via ?primary=... query params. */
:root {
  --brand-tint: color-mix(in srgb, var(--brand) 10%, transparent);
  --brand-tint-strong: color-mix(in srgb, var(--brand) 18%, transparent);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: transparent; }
body.is-standalone { background: var(--surface); }

/* Site header + footer, matching klarbio.com. Hidden inside the embed iframe. */
.kb-site { display: none; }
body.is-standalone .kb-site { display: flex; }
.kb-site-header {
  max-width: 1216px; margin: 0 auto; padding: 22px 32px; align-items: center; justify-content: space-between; gap: 32px;
}
.kb-site-logo img { display: block; height: 55px; width: auto; }
.kb-site-nav { display: flex; gap: 24px; }
.kb-site-nav a { color: var(--text); font-weight: 600; font-size: 15px; text-decoration: none; }
.kb-site-nav a:hover { color: var(--brand); }
body.is-standalone .kb-site-main { padding: 16px 16px 64px; }
.kb-site-footer {
  flex-direction: column; background: linear-gradient(135deg, #1F1B24 0%, #282828 100%);
  color: rgba(255, 255, 255, .78); padding: 72px 32px 32px; line-height: 1.7;
}
.kb-site-footer-grid, .kb-site-footer-bottom { width: 100%; max-width: 1152px; margin: 0 auto; }
.kb-site-footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; }
.kb-site-footer img { display: block; height: 47px; width: auto; }
.kb-site-rule { display: block; width: 64px; height: 3px; background: var(--accent); margin: 20px 0; }
.kb-site-footer h2 {
  margin: 0 0 20px; color: var(--accent); font-family: var(--font); font-size: 12.8px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
}
.kb-site-footer p { margin: 0 0 16px; }
.kb-site-footer a { color: inherit; text-decoration: none; }
.kb-site-footer a:hover { color: #fff; }
.kb-site-footer-bottom {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 48px; padding-top: 28px; border-top: 1px solid rgba(255, 255, 255, .15); font-size: 14px;
}
body {
  font-family: var(--font);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.kb {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  max-width: 1000px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* host panel */
.kb-host { padding: 28px 24px; border-right: 1px solid var(--border); background: var(--surface); }
.kb-avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; margin-bottom: 12px; }
.kb-host-name { margin: 0 0 8px; color: var(--brand); font-family: var(--font-label); font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.kb-title { margin: 0 0 16px; font-family: var(--font-heading); font-weight: 400; font-size: 34px; line-height: 1.1; letter-spacing: -0.01em; }
.kb-meta { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; color: var(--text); font-weight: 500; }
.kb-meta li { display: flex; align-items: center; gap: 10px; }
.kb-meta svg { color: var(--accent);
   width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#whenMeta { color: var(--brand); }
.kb-desc { margin: 0; color: var(--muted); }

/* main */
.kb-main { padding: 28px 28px 24px; min-height: 460px; }
.kb-h2 { margin: 0 0 18px; font-family: var(--font-heading); font-weight: 400; font-size: 26px; line-height: 1.15; }
.kb-pick { display: flex; gap: 28px; align-items: flex-start; }
.kb-cal { flex: 1 1 auto; min-width: 0; max-width: 380px; }
.kb-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 600; }
.kb-icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--brand-tint);
  color: var(--brand); font-size: 20px; line-height: 1; cursor: pointer;
}
.kb-icon-btn:disabled { background: transparent; color: var(--border); cursor: default; }
.kb-dow, .kb-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.kb-dow { font-family: var(--font-label); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.kb-day {
  aspect-ratio: 1; max-width: 46px; width: 100%; justify-self: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  font-weight: 500; cursor: default; position: relative;
}
.kb-day.is-available { background: var(--brand-tint); color: var(--brand); font-weight: 700; cursor: pointer; }
.kb-day.is-available:hover { background: var(--brand-tint-strong); }
.kb-day.is-selected { background: var(--brand); color: var(--brand-text); }
.kb-day.is-today::after {
  content: ""; position: absolute; left: 50%; bottom: 6px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--accent);
}
.kb-day:disabled { opacity: .55; }
.kb-tz { display: grid; gap: 4px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.kb-tz select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); max-width: 100%; }

.kb-slots { width: 200px; flex: none; }
.kb-slots-day { margin: 0 0 12px; font-weight: 600; }
.kb-slot-list { display: grid; gap: 8px; max-height: 360px; overflow-y: auto; padding-right: 4px; }
.kb-slot {
  display: flex; gap: 8px; padding: 0; border: 0; background: none;
}
.kb-slot button {
  flex: 1; padding: 11px 8px; border-radius: var(--btn-radius); border: 1px solid var(--brand);
  background: var(--bg); color: var(--brand); font-weight: 700; cursor: pointer; transition: background .15s;
}
.kb-slot button:hover { background: var(--brand-tint); }
.kb-slot.is-selected .kb-slot-time { background: var(--text); border-color: var(--text); color: #fff; }
.kb-slot .kb-slot-next { background: var(--brand); color: var(--brand-text); }
.kb-slot .kb-slot-next:hover { background: var(--brand-hover); border-color: var(--brand-hover); }

.kb-status { color: var(--muted); margin: 16px 0 0; min-height: 1.4em; }

/* form */
.kb-back { border: 0; background: none; color: var(--brand); font-weight: 600; padding: 0; margin-bottom: 14px; cursor: pointer; }
#form { display: grid; gap: 16px; max-width: 460px; }
.kb-field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.kb-field b { color: var(--accent); }
.kb-field small { color: var(--muted); font-weight: 400; }
.kb-field input, .kb-field textarea {
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-weight: 400;
}
.kb-field textarea { resize: vertical; }
.kb-field input:focus, .kb-field textarea:focus, .kb-tz select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.kb-field input[aria-invalid="true"] { border-color: #B3261E; }
.kb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.kb-error { color: #B3261E; margin: 0; min-height: 1.2em; font-size: 14px; }
.kb-primary {
  justify-self: start; padding: 14px 26px; border: 0; border-radius: var(--btn-radius);
  background: var(--brand); color: var(--brand-text); font-weight: 700; cursor: pointer;
}
.kb-primary:hover { background: var(--brand-hover); }
.kb-primary:disabled { opacity: .6; cursor: progress; }
.kb-secondary {
  padding: 13px 22px; border: 1px solid var(--brand); border-radius: var(--btn-radius);
  background: var(--bg); color: var(--brand); font-weight: 700; cursor: pointer;
}
.kb-secondary:hover { background: var(--brand-tint); }
.kb-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 16px; }
.kb-stack { display: grid; gap: 12px; max-width: 460px; }
.kb-muted { color: var(--muted); margin: 0 0 6px; }
#stepConfirm .kb-done-when { margin: 0 0 18px; }
.kb-done a { color: var(--brand); font-weight: 600; }
.kb-done.is-cancelled .kb-check { background: var(--muted); }
.kb-done.is-cancelled .kb-done-when { color: var(--muted); text-decoration: line-through; }
button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* done */
.kb-done { text-align: center; max-width: 420px; margin: 40px auto 0; }
.kb-check { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; }
.kb-check svg { width: 28px; height: 28px; fill: none; stroke: var(--brand-text); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.kb-done-when { font-weight: 700; color: var(--brand); }
.kb-done .kb-h2 { font-size: 32px; }

/* skeleton while loading */
.is-loading .kb-day { animation: kb-pulse 1.2s ease-in-out infinite; }
@keyframes kb-pulse { 50% { opacity: .35; } }

@media (max-width: 760px) {
  .kb-site-header { padding: 16px; }
  .kb-site-logo img { height: 42px; }
  .kb-site-nav { display: none; }
  body.is-standalone .kb-site-main { padding: 0 0 40px; }
  .kb-site-footer { padding: 48px 16px 24px; }
  .kb-site-footer-grid { grid-template-columns: 1fr; gap: 8px; }
  .kb { grid-template-columns: 1fr; border-radius: 0; border-left: 0; border-right: 0; }
  .kb-host { border-right: 0; border-bottom: 1px solid var(--border); padding: 20px 16px; }
  .kb-title { font-size: 20px; margin-bottom: 10px; }
  .kb-main { padding: 20px 16px; min-height: 0; }
  .kb-pick { flex-direction: column; gap: 20px; }
  .kb-cal { max-width: none; width: 100%; }
  .kb-slots { width: 100%; }
  .kb-slot-list { max-height: none; }
}
