/* Protocol Explorer — brand theme layer.
   Loaded after the app stylesheet so these tokens win on equal specificity. */

/* Match the cross-document fade declared in pages.css so section switches
   keep the fixed shell visually stable. */
@view-transition {
  navigation: auto;
}

:root {
  --pe-accent: var(--blue);
  --bg: #f2f5fc;
  --panel: #ffffff;
  --ink: #0e1c3d;
  --ink-strong: #06102b;
  --ink-soft: #3d5384;
  --ink-muted: #6d80a4;
  --line: rgba(16, 46, 104, 0.22);
  --line-soft: rgba(16, 46, 104, 0.12);
  --line-mid: rgba(16, 46, 104, 0.32);
  --blue: #1d4ed8;
  --active: #16389f;
  --green: #0f7a55;
  --amber: #a35a00;
  --grey: #6d80a4;
  --pe-accent: #1d4ed8;
  --pe-accent-soft: rgba(29, 78, 216, 0.1);
}

:root[data-theme="dark"] {
  --bg: #060a16;
  --panel: #0a1224;
  --ink: #dfe8ff;
  --ink-strong: #f4f8ff;
  --ink-soft: #a6b8d8;
  --ink-muted: #7889a9;
  --line: rgba(110, 150, 220, 0.26);
  --line-soft: rgba(110, 150, 220, 0.14);
  --line-mid: rgba(110, 150, 220, 0.4);
  --blue: #4d8dff;
  --active: #7aaeff;
  --green: #23d39c;
  --amber: #ffc24a;
  --grey: #8b9dbc;
  --pe-accent: #4d8dff;
  --pe-accent-soft: rgba(77, 141, 255, 0.14);
}

body {
  background-color: var(--bg);
}

:root[data-theme="dark"] body {
  background-image:
    radial-gradient(circle at 12% -10%, rgba(56, 112, 224, 0.16), transparent 46%),
    radial-gradient(circle at 88% 0%, rgba(24, 78, 168, 0.14), transparent 42%);
  background-repeat: no-repeat;
}

/* ── product nav injected by gate.js ─────────────────────────────── */
.pe-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  font: 500 12px/1 Iosevka, ui-monospace, monospace;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pe-nav a {
  color: var(--ink-soft);
  text-decoration: none;
}

.pe-nav a:hover {
  color: var(--ink);
}

.pe-nav .pe-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-strong);
  text-decoration: none;
}

.pe-nav .pe-brand img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.pe-nav .pe-spacer {
  flex: 1;
}

.pe-nav .pe-link {
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
}

.pe-nav .pe-link:hover {
  border-color: var(--line);
  color: var(--ink);
}

.pe-btn {
  appearance: none;
  cursor: pointer;
  font: 500 12px/1 Iosevka, ui-monospace, monospace;
  letter-spacing: 0.04em;
  padding: 9px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.pe-btn:hover {
  border-color: var(--blue);
}

.pe-btn.pe-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.pe-btn.pe-primary:hover {
  filter: brightness(1.08);
}

.pe-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.pe-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 11px 14px;
  font-size: 12.5px;
  letter-spacing: 0.01em;
  background: var(--panel-2, var(--panel));
}

.pe-google svg {
  flex: 0 0 auto;
}

.pe-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  font: 500 10px/1 Iosevka, ui-monospace, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.pe-divider::before,
.pe-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft, var(--line));
}

.pe-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 4px;
  font: 500 10px/1 Iosevka, ui-monospace, monospace;
  letter-spacing: 0.1em;
  color: var(--pe-accent);
  background: var(--pe-accent-soft);
  border: 1px solid color-mix(in srgb, var(--pe-accent) 34%, transparent);
}

/* shrink the app shell so the fixed nav does not cover the lesson footer */
body.pe-has-nav #pe-app-wrap {
  height: calc(100dvh - 52px);
  margin-top: 52px;
}

/* ── locked protocol rows ────────────────────────────────────────── */
.topbar-tools a.credit {
  display: none !important;
}

.proto-row {
  position: relative;
}

.proto-row.pe-locked {
  opacity: 0.72;
}

.proto-row.pe-locked:hover {
  opacity: 1;
}

.pe-pro-tag {
  position: absolute;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 6px;
  border-radius: 3px;
  font: 600 9px/1.4 Iosevka, ui-monospace, monospace;
  letter-spacing: 0.12em;
  color: #ffffff;
  background: var(--blue);
  pointer-events: none;
}

.pe-step-lock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  cursor: pointer;
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: 6px;
  border: 1px dashed var(--line-mid);
  color: var(--ink-soft);
  background: var(--pe-accent-soft);
  font: 400 11px/1.5 Iosevka, ui-monospace, monospace;
  text-align: left;
}

.pe-step-lock strong {
  color: var(--pe-accent);
  font-weight: 600;
}

/* ── Search protocols: Pro markers inside the candidate list ───────── */
.pal-option.pe-pal-locked {
  grid-template-columns: 150px minmax(0, 1fr) auto auto;
  column-gap: 10px;
}

.pal-option.pe-pal-locked > .pe-pal-pro {
  grid-column: 4;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: center;
  justify-self: end;
  padding: 3px 6px;
  border: 1px solid var(--amber);
  border-radius: 3px;
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  color: var(--amber);
  font: 700 9px/1 Iosevka, ui-monospace, monospace;
  letter-spacing: 0.1em;
  white-space: nowrap;
  pointer-events: none;
}

.pal-option.pe-pal-locked > .pe-pal-pro svg {
  flex: none;
}

.pal-option.pe-pal-locked.is-step > .pal-sub {
  grid-column: 2 / 4;
}

.palette-foot {
  flex-wrap: wrap;
}

.pe-pal-legend {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-basis: 100%;
  margin-top: 2px;
  color: var(--ink-muted);
}

.pe-pal-legend-mark {
  padding: 2px 5px;
  border: 1px solid var(--amber);
  border-radius: 3px;
  color: var(--amber);
  font: 700 9px/1 Iosevka, ui-monospace, monospace;
  letter-spacing: 0.1em;
}

/* 390px: the stock 3-column result row leaves no room for a badge, so
   Pro results become a two-line card with the marker on the first line. */
@media (max-width: 720px) {
  .pal-option.pe-pal-locked {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    row-gap: 2px;
    padding-block: 8px;
  }

  .pal-option.pe-pal-locked > .pal-name {
    grid-column: 1;
    grid-row: 1;
  }

  .pal-option.pe-pal-locked > .pe-pal-pro {
    grid-column: 2;
    grid-row: 1;
  }

  .pal-option.pe-pal-locked > .pal-sub,
  .pal-option.pe-pal-locked.is-step > .pal-sub {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .pal-option.pe-pal-locked > .pal-tag {
    display: none;
  }
}

/* ── paywall dialog ──────────────────────────────────────────────── */
.pe-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 8, 20, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.pe-modal[hidden] {
  display: none;
}

.pe-modal-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 26px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(2, 6, 18, 0.4);
}

.pe-modal-card h2 {
  margin: 10px 0 8px;
  font: 500 20px/1.3 Iosevka, ui-monospace, monospace;
  color: var(--ink-strong);
}

.pe-modal-card p {
  margin: 0 0 14px;
  font: 400 12px/1.7 Iosevka, ui-monospace, monospace;
  color: var(--ink-soft);
}

.pe-modal-card ul {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  font: 400 12px/1.9 Iosevka, ui-monospace, monospace;
  color: var(--ink-soft);
}

.pe-modal-card li::before {
  content: "▸ ";
  color: var(--pe-accent);
}

.pe-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--ink-strong);
}

.pe-price b {
  font: 500 30px/1 Iosevka, ui-monospace, monospace;
}

.pe-price span {
  font: 400 11px/1 Iosevka, ui-monospace, monospace;
  color: var(--ink-muted);
}

.pe-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pe-actions .pe-btn {
  flex: 1 1 140px;
  text-align: center;
}

.pe-error {
  margin: 10px 0 0;
  font: 400 11px/1.6 Iosevka, ui-monospace, monospace;
  color: #e5484d;
}

.pe-close {
  float: right;
  appearance: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: 400 18px/1 Iosevka, ui-monospace, monospace;
}

/* ── marketing / SEO block under the app ─────────────────────────── */
html.pe-scroll,
html.pe-scroll body {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

#pe-app-wrap {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.pe-marketing {
  border-top: 1px solid var(--line-soft);
  background: var(--bg);
  padding: 56px 20px 40px;
  color: var(--ink-soft);
}

.pe-marketing .pe-inner {
  max-width: 940px;
  margin: 0 auto;
  font: 400 13px/1.85 Iosevka, ui-monospace, monospace;
}

.pe-marketing h1 {
  margin: 0 0 12px;
  font: 500 26px/1.35 Iosevka, ui-monospace, monospace;
  color: var(--ink-strong);
  letter-spacing: -0.01em;
}

.pe-marketing h2 {
  margin: 34px 0 10px;
  font: 500 15px/1.4 Iosevka, ui-monospace, monospace;
  color: var(--ink-strong);
  letter-spacing: 0.02em;
}

.pe-marketing p {
  margin: 0 0 12px;
  max-width: 74ch;
}

.pe-marketing .pe-byline {
  margin: -2px 0 16px;
  color: var(--ink-muted);
  font-size: 11px;
}

.pe-marketing .pe-byline a,
.pe-marketing .pe-table a {
  color: var(--ink-strong);
}

.pe-table-wrap {
  max-width: 100%;
  margin: 12px 0 8px;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
}

.pe-marketing .pe-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font: 400 11px/1.65 Iosevka, ui-monospace, monospace;
}

.pe-marketing .pe-table caption {
  padding: 10px 12px;
  color: var(--ink-strong);
  font-weight: 500;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}

.pe-marketing .pe-table th,
.pe-marketing .pe-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

.pe-marketing .pe-table thead th {
  color: var(--ink-strong);
  font-weight: 600;
  background: var(--panel);
}

.pe-marketing .pe-table tbody th {
  min-width: 110px;
  color: var(--ink);
  font-weight: 500;
}

.pe-marketing .pe-table tbody tr:last-child th,
.pe-marketing .pe-table tbody tr:last-child td {
  border-bottom: 0;
}

.pe-marketing strong {
  color: var(--ink);
  font-weight: 500;
}

.pe-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 18px 0 8px;
}

.pe-col {
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
}

.pe-col h3 {
  margin: 0 0 6px;
  font: 500 12px/1.4 Iosevka, ui-monospace, monospace;
  color: var(--ink-strong);
  letter-spacing: 0.04em;
}

.pe-col p {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
}

.pe-faq {
  margin: 12px 0 0;
}

.pe-faq dt {
  margin: 16px 0 4px;
  font: 500 12px/1.5 Iosevka, ui-monospace, monospace;
  color: var(--ink);
}

.pe-faq dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.pe-foot {
  max-width: 940px;
  margin: 32px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font: 400 11px/1.6 Iosevka, ui-monospace, monospace;
  color: var(--ink-muted);
}

.pe-foot a {
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.pe-foot a:hover {
  color: var(--ink);
}

@media (max-width: 720px) {
  :root {
    --pe-nav-h: calc(48px + env(safe-area-inset-top, 0px));
    --pe-tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  .pe-nav {
    height: var(--pe-nav-h);
    padding: env(safe-area-inset-top, 0px) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
    gap: 6px;
    /* below the app's own scrim (45) and drawer (50): full-screen panels should
       take over the whole viewport instead of sliding under our bar */
    z-index: 40;
  }

  body.pe-has-nav #pe-app-wrap {
    height: calc(100dvh - var(--pe-nav-h) - var(--pe-tabbar-h));
    margin-top: var(--pe-nav-h);
  }

  .pe-nav .pe-link {
    display: none;
  }

  /* On the visualiser the app header right below already carries the wordmark,
     so our copy hides itself and hands that space to the section links. */
  body.pe-app-page .pe-nav .pe-brand {
    display: none;
  }

  body.pe-app-page .pe-nav .pe-link {
    display: inline-flex;
    align-items: center;
    height: 100%;
    font-size: 11px;
  }

  /* links hug the left edge, buttons stay right where the thumb expects them */
  body.pe-app-page .pe-nav .pe-spacer {
    display: none;
  }

  body.pe-app-page .pe-nav .pe-btn:first-of-type {
    margin-left: auto;
  }

  .pe-marketing {
    padding: 36px 16px 28px;
  }

  .pe-marketing h1 {
    font-size: 21px;
  }
}

/* ── mobile bottom tab bar ──────────────────────────────────────── */
.pe-tabbar {
  display: none;
}

@media (max-width: 720px) {
  .pe-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 41;
    display: flex;
    height: var(--pe-tabbar-h);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border-top: 1px solid var(--line-soft);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  /* The app ships its own fixed playback bar at bottom:0 — park it directly
     above our tab bar instead of letting the two stack on top of each other.
     `.is-single` is the app's own mobile class, so the selector must match it. */
  .is-single .packet-actions {
    bottom: var(--pe-tabbar-h);
    padding-bottom: 10px;
  }

  /* "ステップ" wraps onto two lines inside the app's 64px column; CJK labels
     are wider than the English ones it was sized for. */
  .is-single .packet-actions .btn {
    font-size: 12px;
    padding: 0 4px;
    white-space: nowrap;
  }

  .pe-tabbar a:link,
  .pe-tabbar a:visited {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font: 500 10px/1.2 Iosevka, ui-monospace, monospace;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-muted);
    text-decoration: none;
  }

  .pe-tabbar a.is-active:link,
  .pe-tabbar a.is-active:visited {
    color: var(--pe-accent);
  }

  .pe-tabbar a.is-active {
    box-shadow: inset 0 2px 0 var(--pe-accent);
  }
}

/* ── mobile v2: one bar, protocol strip, detail sheet ───────────────
   Everything below is phone-only. Desktop keeps the original top bar,
   the always-visible overview panel and the text-only tab bar. */

.pe-brand-mark,
.pe-menu-btn,
.pe-pro-icon,
.pe-pro-label {
  display: none;
}

@media (max-width: 720px) {
  :root {
    --pe-nav-h: calc(48px + env(safe-area-inset-top, 0px));
    --pe-tabbar-h: calc(62px + env(safe-area-inset-bottom, 0px));
  }

  /* ── one bar: menu + brand + yellow Pro ── */
  .pe-nav {
    gap: 8px;
    height: var(--pe-nav-h);
    padding: env(safe-area-inset-top, 0px) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }

  .pe-nav .pe-link,
  .pe-nav .pe-btn.pe-nav-secondary {
    display: none;
  }

  .pe-nav .pe-brand {
    display: flex;
    gap: 7px;
    font-size: 11px;
    letter-spacing: 0.07em;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
  }

  body.pe-app-page .pe-nav .pe-brand {
    display: flex;
  }

  body.pe-app-page .pe-nav .pe-link {
    display: none;
  }

  body.pe-app-page .pe-nav .pe-spacer {
    display: block;
  }

  .pe-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: color-mix(in srgb, var(--panel) 72%, transparent);
    color: var(--ink-soft);
    cursor: pointer;
  }

  body.pe-app-page .pe-menu-btn {
    display: inline-flex;
  }

  .pe-menu-btn svg {
    width: 16px;
    height: 16px;
  }

  .pe-brand-mark {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border: 1px solid color-mix(in srgb, var(--pe-accent) 45%, transparent);
    border-radius: 6px;
    background: var(--pe-accent-soft);
    color: var(--pe-accent);
  }

  body.pe-app-page .pe-brand-mark {
    display: inline-flex;
  }

  .pe-brand-mark svg {
    width: 15px;
    height: 15px;
  }

  .pe-nav .pe-btn.pe-pro-cta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    margin-inline-start: auto;
    padding: 0 12px;
    border: 1px solid #ffd77e;
    border-radius: 7px;
    background: #ffc24a;
    color: #101a33;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0.1em;
    box-shadow: 0 0 0 3px rgba(255, 194, 74, 0.12);
  }

  .pe-nav .pe-btn.pe-pro-cta:hover {
    background: #ffcf6d;
    border-color: #ffe3a3;
    filter: none;
  }

  .pe-pro-icon {
    display: inline-flex;
  }

  .pe-pro-icon svg {
    width: 12px;
    height: 12px;
  }

  .pe-pro-label {
    display: inline;
  }

  .pe-pro-long {
    display: none;
  }

  /* ── the visualiser header folds into the bar above ── */
  html.is-single body.pe-app-page .topbar {
    display: none;
  }

  html.is-single body.pe-app-page .shell {
    grid-template-rows: auto auto;
  }

  /* ── current protocol strip ── */
  .pe-mob-ctx {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-inline-start: 2px solid var(--pe-accent);
    border-radius: 3px;
    background:
      linear-gradient(90deg, color-mix(in srgb, var(--pe-accent) 14%, transparent), transparent 62%),
      var(--panel);
    font-family: Iosevka, ui-monospace, monospace;
    cursor: pointer;
  }

  .pe-mob-ctx-open {
    display: flex;
    flex: 0 1 auto;
    min-width: 0;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    text-align: start;
    cursor: pointer;
  }

  /* label stays in the DOM for a11y / long-form context, but a single row
     has no room for it — it lives in the detail sheet header instead */
  .pe-mob-ctx-kicker {
    display: none;
  }

  .pe-mob-ctx-name {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    font-size: 21px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--ink-strong);
  }

  .pe-mob-ctx-name-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pe-mob-ctx-info {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink-muted);
    font-size: 9px;
    line-height: 13px;
    font-style: normal;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0;
  }

  .pe-mob-ctx-badge {
    display: flex;
    flex: 0 0 auto;
    margin-inline-start: auto;
  }

  .pe-mob-ctx-badge .badge {
    height: 21px;
    gap: 5px;
    padding-inline: 7px;
    margin-top: 0;
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  .pe-mob-ctx-badge .badge i {
    width: 7px;
    height: 7px;
  }

  .pe-mob-ctx-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 1 auto;
    height: 22px;
    max-width: 96px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: color-mix(in srgb, var(--panel) 70%, transparent);
    color: var(--ink-soft);
    font: 600 8px/1 Iosevka, ui-monospace, monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .pe-mob-ctx-switch-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pe-mob-ctx-switch svg {
    flex: 0 0 10px;
    width: 10px;
    height: 10px;
    color: var(--ink-muted);
  }

  /* the overview panel is replaced by the strip + sheet while reading */
  html.is-single body.pe-app-page.pe-mob-overview .workspace > .overview {
    display: none;
  }

  /* ── protocol detail sheet ── */
  body.pe-mob-sheet-open {
    overflow: hidden;
  }

  .pe-mob-sheet,
  .pe-mob-lang {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--pe-tabbar-h);
    z-index: 300;
    display: none;
    flex-direction: column;
    height: min(360px, 62vh);
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    background: var(--panel);
    box-shadow: 0 -16px 40px rgba(4, 10, 26, 0.34);
  }

  body.pe-mob-sheet-open .pe-mob-sheet {
    display: flex;
    animation: pe-sheet-up 0.22s ease-out;
  }

  @keyframes pe-sheet-up {
    from { transform: translateY(24px); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
  }

  .pe-mob-sheet-grab {
    width: 34px;
    height: 4px;
    flex: 0 0 4px;
    margin: 8px auto 2px;
    border-radius: 2px;
    background: var(--line);
  }

  .pe-mob-sheet-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 8px;
    border-bottom: 1px solid var(--line-soft);
  }

  .pe-mob-sheet-kicker {
    flex: 1;
    min-width: 0;
    font: 700 8.5px/1.3 Iosevka, ui-monospace, monospace;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--pe-accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pe-mob-sheet-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
  }

  .pe-mob-sheet-close svg {
    width: 14px;
    height: 14px;
  }

  .pe-mob-sheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px 18px;
    overscroll-behavior: contain;
  }

  .pe-mob-sheet-body .overview-name h3 {
    font-size: 26px;
    line-height: 1.05;
  }

  .pe-mob-sheet-body .overview-full {
    margin: 6px 0 0;
    font-size: 13px;
    line-height: 1.35;
    color: var(--ink-soft);
  }

  .pe-mob-sheet-body .overview-desc {
    margin: 10px 0 0;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--ink-soft);
  }

  .pe-mob-sheet-body .overview-facts {
    margin: 12px 0 0;
  }

  .pe-mob-sheet-scrim {
    position: fixed;
    inset: 0;
    z-index: 299;
    background: rgba(3, 8, 20, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.pe-mob-sheet-open .pe-mob-sheet-scrim,
  body.pe-mob-lang-open .pe-mob-sheet-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── language sheet ── */
  body.pe-mob-lang-open {
    overflow: hidden;
  }

  .pe-mob-lang {
    height: min(70vh, 520px);
    z-index: 320;
  }

  body.pe-mob-lang-open .pe-mob-lang {
    display: flex;
    animation: pe-sheet-up 0.22s ease-out;
  }

  .pe-mob-lang-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 6px;
    padding: 6px 12px 18px;
    overscroll-behavior: contain;
  }

  .pe-mob-lang-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 9px;
    border: 1px solid var(--line-soft);
    border-radius: 6px;
    background: transparent;
    color: var(--ink-soft);
    text-align: start;
    cursor: pointer;
  }

  .pe-mob-lang-item.is-on {
    border-color: color-mix(in srgb, var(--pe-accent) 55%, transparent);
    background: var(--pe-accent-soft);
    color: var(--ink-strong);
  }

  .pe-mob-lang-code {
    flex: 0 0 26px;
    font: 700 9px/1 Iosevka, ui-monospace, monospace;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pe-accent);
  }

  .pe-mob-lang-name {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pe-mob-lang-check {
    flex: 0 0 12px;
    color: var(--pe-accent);
  }

  .pe-mob-lang-check svg {
    width: 12px;
    height: 12px;
  }

  /* ── drawer: language beside close, search on top, theme at the bottom ── */
  .panel.sidebar {
    display: flex;
    flex-direction: column;
  }

  .panel.sidebar > .panel-head {
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
  }

  .panel.sidebar > .panel-head .panel-title {
    flex: 1;
    min-width: 0;
    font-size: 17px;
    letter-spacing: 0.05em;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .panel.sidebar > .tabs,
  .panel.sidebar > .panel-head,
  .panel.sidebar > .pe-mob-search {
    flex: 0 0 auto;
  }

  .panel.sidebar > .proto-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .pe-mob-lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    height: 28px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: color-mix(in srgb, var(--panel) 70%, transparent);
    color: var(--ink-soft);
    font: 700 9px/1 Iosevka, ui-monospace, monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .pe-mob-lang-btn svg {
    width: 13px;
    height: 13px;
  }

  .pe-mob-lang-btn svg:last-child {
    width: 10px;
    height: 10px;
    color: var(--ink-muted);
  }

  .pe-mob-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    margin: 10px 12px 8px;
    padding: 0 10px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: color-mix(in srgb, var(--panel) 70%, transparent);
    color: var(--ink-muted);
    font: 500 11px/1 Iosevka, ui-monospace, monospace;
    letter-spacing: 0.04em;
    text-align: start;
    cursor: pointer;
  }

  .pe-mob-search svg {
    width: 13px;
    height: 13px;
    flex: 0 0 13px;
  }

  .pe-mob-search-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pe-mob-theme {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex: 0 0 auto;
    margin-top: auto;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line-soft);
  }

  .pe-mob-theme-label {
    font: 600 9px/1 Iosevka, ui-monospace, monospace;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-muted);
  }

  .pe-mob-theme-pill {
    display: flex;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
  }

  .pe-mob-theme-pill button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
  }

  .pe-mob-theme-pill button.is-on {
    background: var(--pe-accent-soft);
    color: var(--pe-accent);
  }

  .pe-mob-theme-pill svg {
    width: 14px;
    height: 14px;
  }

  /* ── tab bar with icons ── */
  .pe-tabbar a:link,
  .pe-tabbar a:visited {
    position: relative;
    flex-direction: column;
    gap: 4px;
    padding-top: 3px;
  }

  .pe-tab-ico {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 20px;
    color: inherit;
  }

  .pe-tab-ico svg {
    width: 20px;
    height: 20px;
  }

  .pe-tab-label {
    font: 600 9.5px/1.1 Iosevka, ui-monospace, monospace;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pe-tabbar a.is-active {
    box-shadow: none;
  }

  .pe-tabbar a.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 28%;
    right: 28%;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: var(--pe-accent);
  }

  .pe-tabbar a.is-active .pe-tab-ico {
    color: var(--pe-accent);
  }
}
