/* Zebbingo Experiment — shared demo shell.
 * Dark first, light via prefers-color-scheme. System fonts only, no assets. */

:root {
  color-scheme: dark;
  --bg: #0e1013;
  --panel: #161a20;
  --panel-2: #1c2129;
  --border: #262c36;
  --border-strong: #363e4b;
  --text: #e7eaef;
  --text-dim: #9aa3b1;
  --text-faint: #6d7684;
  --accent: #7aa2f7;
  --accent-dim: #232d40;
  --live: #3fb950;
  --warning: #d29922;
  --code-bg: #0b0e12;
  --frame-bg: #ffffff;
  --radius: 8px;
  --sidebar-w: 268px;
  --drawer-w: 380px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-2: #eef1f5;
    --border: #e1e5ea;
    --border-strong: #c8cfd8;
    --text: #1b1f26;
    --text-dim: #576070;
    --text-faint: #858d9b;
    --accent: #2f5fd0;
    --accent-dim: #e3ebfb;
    --live: #1a7f37;
    --warning: #96690a;
    --code-bg: #f2f4f7;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); font-size: 13px; }

/* ── layout: sidebar | stage | (drawer) ─────────────────────────────────── */

.layout {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.layout.is-drawer-open {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--drawer-w);
}

/* ── sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.sidebar-search {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.search {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
}

.search::placeholder { color: var(--text-faint); }
.search:focus { outline: none; border-color: var(--accent); }

.nav-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px; }

.nav-item {
  position: relative;
  display: block;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--text);
}

.nav-item:hover { background: var(--panel-2); text-decoration: none; }
.nav-item.is-active { background: var(--accent-dim); border-color: var(--accent); }
.nav-item.is-nodemo .nav-title { color: var(--text-dim); font-weight: 400; }

.nav-item-link {
  min-width: 0;
  display: block;
  padding: 4px 38px 4px 7px;
  border-radius: var(--radius);
  color: var(--text);
}

.nav-item-link:hover { color: var(--text); text-decoration: none; }
.nav-item-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.nav-item-top { display: flex; align-items: center; gap: 8px; }

.nav-title {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.nav-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 1px;
  padding-left: 16px;
  color: var(--text-faint);
  font-size: 10.5px;
}

.nav-item-actions {
  position: absolute;
  top: 3px;
  right: 4px;
  width: 26px;
  height: 26px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.nav-item:hover .nav-item-actions,
.nav-item:focus-within .nav-item-actions {
  opacity: 1;
  pointer-events: auto;
}

.nav-action {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.nav-action:hover,
.nav-action:focus-visible,
.nav-action.is-on {
  border-color: var(--accent);
  background: var(--panel-2);
  color: var(--accent);
  text-decoration: none;
  outline: none;
}

.nav-more { font-size: 19px; font-weight: 600; }

.nav-action-menu {
  position: fixed;
  z-index: 30;
  width: 180px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.nav-menu-item {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-menu-item:hover,
.nav-menu-item:focus-visible {
  background: var(--accent-dim);
  color: var(--text);
  text-decoration: none;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

@media (hover: none) {
  .nav-item.is-active .nav-item-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.nav-empty { padding: 14px 10px; color: var(--text-faint); font-size: 13px; }

.nav-sort-label {
  padding: 2px 10px 5px;
  color: var(--text-faint);
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

.nav-group + .nav-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.nav-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 3px 10px 4px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.nav-group-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0;
}

/* ── stage ──────────────────────────────────────────────────────────────── */

.stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.stage-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: auto;
}

.demo-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  background: var(--frame-bg);
}

/* ── notices (empty / error / blocked / server down) ────────────────────── */

.notice {
  margin: 22px;
  padding: 20px 22px;
  max-width: 74ch;
  align-self: flex-start;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
}

.notice-title { margin: 0 0 8px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.notice-text { margin: 0 0 12px; color: var(--text-dim); font-size: 14px; max-width: 70ch; }
.notice-hint { margin: 12px 0 0; color: var(--text-faint); font-size: 12.5px; max-width: 70ch; }

.notice-label {
  margin: 14px 0 6px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.notice > .btn { margin-top: 14px; }
.notice > .btn + .btn { margin-left: 8px; }

/* ── buttons and chips ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}

.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.copied { border-color: var(--live); color: var(--live); }
.btn.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
}

/* ── code blocks ────────────────────────────────────────────────────────── */

pre.run,
.md-code {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--text);
  overflow-x: auto;
}

.run-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.run-row pre.run { flex: 1 1 260px; min-width: 0; }
.copy-btn { flex: 0 0 auto; }

/* ── details drawer ─────────────────────────────────────────────────────── */

.drawer {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--panel);
}

.drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.drawer-close {
  border: 0;
  background: none;
  padding: 0 4px;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.drawer-close:hover { color: var(--text); }

.drawer-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px; }

.drawer-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-bottom: 10px; }
.drawer-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }

.drawer-label {
  margin: 18px 0 7px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.drawer-summary { margin: 0; color: var(--text-dim); font-size: 13.5px; }

.drawer-source {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.meta-item { display: inline-flex; align-items: baseline; gap: 6px; font-size: 12.5px; }
.meta-label { color: var(--text-faint); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.06em; }
.meta-value { color: var(--text); }

.link-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.link-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 9px; font-size: 13.5px; }
.link-url { color: var(--text-faint); font-size: 12px; word-break: break-all; }
.link-broken { color: var(--warning); font-size: 13px; word-break: break-all; }
.artifact-link { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

.muted { color: var(--text-dim); }
.small { font-size: 12.5px; }

/* ── rendered Markdown ──────────────────────────────────────────────────── */

.markdown { max-width: 78ch; }

.markdown > *:first-child { margin-top: 0; }
.markdown > *:last-child { margin-bottom: 0; }

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin: 20px 0 9px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.markdown h1 { font-size: 20px; }
.markdown h2 { font-size: 17px; }
.markdown h3 { font-size: 15.5px; }
.markdown h4, .markdown h5, .markdown h6 { font-size: 14px; }

.markdown p { margin: 0 0 11px; }

.markdown ul,
.markdown ol { margin: 0 0 11px; padding-left: 22px; }
.markdown li { margin: 3px 0; }

.markdown code {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--code-bg);
}

.markdown pre.md-code code { padding: 0; border: 0; background: none; }
.markdown strong { font-weight: 650; }

/* ── responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .layout,
  .layout.is-drawer-open { grid-template-columns: 220px minmax(0, 1fr); }

  /* Too narrow for three columns: the drawer overlays the stage instead of
   * squeezing it, so the demo keeps a usable width. */
  .drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(var(--drawer-w), 84vw);
    border-left-color: var(--border-strong);
  }
}

@media (max-width: 620px) {
  .layout,
  .layout.is-drawer-open { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }

  .sidebar {
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .notice { margin: 14px; padding: 16px 16px; }
  .run-row pre.run { flex: 1 1 100%; }
}

[hidden] { display: none !important; }

.account { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; padding: 12px; border-top: 1px solid var(--border); font-size: 12px; }
#account-email { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account button { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; }
/* Region labels describe deployment availability, independently of topic tags. */
.site-region { font-size: .8rem; font-weight: 600; margin-bottom: .65rem; }
.region-label { display: inline-block; padding: .05rem .35rem; border: 1px solid currentColor; border-radius: .3rem; font-size: .65rem; line-height: 1.35; }
/* Login follows the official site's light palette and Liebling typography. */
@font-face { font-family: Liebling; src: url("brand/liebling-regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Liebling; src: url("brand/liebling-bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
body:has(.login-panel:not([hidden])) { height: auto; min-height: 100svh; overflow: auto; background: #f7fbfd; }
.login-panel { color-scheme: light; flex: 1; width: 100%; min-height: 100svh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 5% 55%, #e7f5fb 0, transparent 55%), #fbfdfe; color: #141b20; font-family: Liebling, var(--sans); }
.login-header, .login-footer { width: min(1120px, 100%); margin: 0 auto; padding: 24px 48px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.login-brand { display: flex; }
.login-brand img { display: block; width: 160px; height: 35px; object-fit: contain; }
.login-site-label { font-size: 14px; color: #506773; }
.login-content { flex: 1; width: min(1120px, 100%); margin: 0 auto; padding: 20px 48px; display: grid; grid-template-columns: 1fr 420px; gap: 72px; align-items: center; }
.login-eyebrow { color: #27647f; font-size: 12px; letter-spacing: .16em; font-weight: 700; margin: 0 0 24px; }
.login-intro h1 { font-size: clamp(42px, 5vw, 64px); line-height: 1.1; letter-spacing: -.035em; margin: 0 0 24px; font-weight: 700; }
.login-description { font-size: 19px; line-height: 1.65; color: #4e6571; margin: 0 0 36px; }
.login-region { display: inline-flex; align-items: center; gap: 8px; color: #315d71; border: 1px solid #d4e8f1; background: #f0f8fc; padding: 8px 14px; border-radius: 30px; font-size: 13px; }
.login-region > span:first-child { width: 7px; height: 7px; background: #6ec4e8; border-radius: 50%; }
.login-card { background: #fff; border: 1px solid #dfebf1; border-radius: 24px; padding: 32px; box-shadow: 0 16px 60px #284e6410; }
.login-card h2 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.02em; line-height: 1.3; }
.login-card-description { margin: 0; color: #526773; font-size: 14px; }
.login-controls { min-height: 310px; }
.login-message { min-height: 60px; line-height: 1.5; margin: 22px 0 10px; color: #637681; font-size: 13px; overflow-wrap: anywhere; }
.login-message[data-state="error"] { color: #b42332; }
.google-login { min-height: 44px; }
.google-login:empty { display: none; }
.password-login { display: grid; gap: 18px; margin: 0; }
.login-field { display: grid; gap: 8px; }
.login-field label { font-size: 13px; font-weight: 700; }
.login-field input { box-sizing: border-box; width: 100%; height: 48px; padding: 0 14px; border: 1px solid #cfdde4; border-radius: 10px; background: #fff; color: #17252e; font: 16px Liebling, var(--sans); transition: border-color .15s, box-shadow .15s; }
.login-field input:focus { outline: none; border-color: #389ac5; box-shadow: 0 0 0 3px #6ec4e82b; }
.login-field input[readonly] { background: #f8fbfc; }
.login-submit { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; height: 48px; margin-top: 6px; border: 0; border-radius: 12px; background: #246c8b; color: white; font: 700 16px Liebling, var(--sans); cursor: pointer; transition: background .15s; }
.login-submit:hover { background: #195772; }
.login-submit:focus-visible, .login-panel a:focus-visible { outline: 3px solid #6ec4e8; outline-offset: 4px; }
.login-submit:disabled { background: #5a8193; cursor: wait; }
.login-help { margin: 24px 0 0; padding-top: 20px; border-top: 1px solid #edf2f5; color: #637681; font-size: 12px; line-height: 1.6; }
.login-footer { padding-top: 16px; padding-bottom: 16px; font-size: 12px; color: #738692; }
.login-panel a { color: #315d71; }
@media (max-width: 850px) {
  .login-content { gap: 32px; grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); padding: 32px; }
  .login-header, .login-footer { padding-left: 32px; padding-right: 32px; }
  .login-card { padding: 28px; }
}
@media (max-width: 650px) {
  .login-header { padding: 24px; }
  .login-content { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 16px 24px 32px; align-content: start; }
  .login-intro h1 { font-size: 38px; margin-bottom: 14px; }
  .login-intro h1 br { display: none; }
  .login-eyebrow { margin-bottom: 12px; }
  .login-description { font-size: 16px; margin-bottom: 18px; }
  .login-desktop-break { display: none; }
  .login-card { padding: 26px; }
  .login-message { min-height: 80px; }
  .login-footer { padding: 16px 24px 24px; }
}
