/* ThreadForge live demo. Builds on the site tokens in site.css.
   Layout: an app shell. Section nav on the left, the working view in the middle,
   the missions checklist on the right (a slide-over panel below 1280px). */

.demo-body { min-height: 100vh; }

/* Top bar */
.demo-top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--forge); color: var(--forge-fg);
  border-bottom: 1px solid var(--forge-line);
}
.demo-top-inner {
  display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.demo-top .brand { color: var(--forge-fg); }
.demo-top .brand-word { font-size: 1.3rem; }
.demo-top .brand-mark { width: 30px; height: 30px; }
.demo-chip {
  font: 700 .6875rem/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase;
  color: var(--lime-ink); background: var(--lime); border-radius: 999px; padding: 6px 9px; white-space: nowrap;
}
.demo-top-tools { display: flex; align-items: center; gap: 8px; margin-left: 8px; min-width: 0; }
.demo-timer {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font: 600 var(--t-xs)/1 var(--font-mono); font-variant-numeric: tabular-nums;
  border: 1px solid var(--forge-line); border-radius: 999px; padding: 8px 11px; color: var(--forge-fg);
}
.demo-timer::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--lime); }
.demo-timer.is-low::before { background: #f0bf6e; }
.demo-role { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); }
.demo-role select {
  min-height: 36px; border-radius: 999px; padding: 0 30px 0 12px; font: 600 var(--t-xs)/1 var(--font-body);
  background: var(--forge-2); color: var(--forge-fg); border: 1px solid var(--forge-line);
}
.demo-top-btn {
  min-height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 600 var(--t-xs)/1 var(--font-body); border: 1px solid var(--forge-line); background: transparent; color: var(--forge-fg);
}
.demo-top-btn:hover { border-color: var(--forge-muted); }
.demo-top-btn .count { font-family: var(--font-mono); color: var(--lime); }
.demo-dl { position: relative; margin-left: auto; }
.demo-dl > summary { list-style: none; display: inline-flex; align-items: center; }
.demo-dl > summary::-webkit-details-marker { display: none; }
.demo-dl-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: min(280px, calc(100vw - 32px));
  background: var(--bg-raised); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 40px rgb(0 0 0 / .18);
}
.demo-dl-menu a, .demo-dl-menu p { display: block; }
.demo-dl-menu a { padding: 10px 12px; border-radius: 10px; color: var(--fg); font-weight: 650; text-decoration: none; }
.demo-dl-menu a:hover { background: var(--bg-sunk); }
.demo-dl-menu p { margin: 4px 8px 8px; color: var(--fg-2); font-size: var(--t-xs); }
.demo-top :focus-visible { outline-color: var(--lime); }
@media (max-width: 720px) {
  .demo-role-label, .demo-top .brand-word { display: none; }
  .demo-top-inner { gap: 8px; }
}
@media (max-width: 560px) {
  .demo-top .demo-chip, .demo-timer .timer-suffix { display: none; }
  .demo-top-inner { gap: 6px; }
  .demo-top-tools { gap: 6px; }
  .demo-timer { padding: 8px 9px; }
  .demo-role select { padding: 0 24px 0 10px; }
  .demo-top-btn { padding: 0 11px; }
  .demo-top-btn .mlabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Gate: start, resume or ended */
.demo-gate { padding-block: clamp(2.5rem, 2rem + 3vw, 5rem); }
.demo-gate-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(2rem, 1rem + 4vw, 4.5rem); align-items: start; }
@media (max-width: 900px) { .demo-gate-grid { grid-template-columns: minmax(0, 1fr); } }
.demo-gate h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(2.4rem, 1.4rem + 3.6vw, 4.25rem); line-height: 1; letter-spacing: -.015em; word-spacing: .03em; margin-block: 14px 20px; }
.demo-facts { list-style: none; display: grid; gap: 12px; margin-block: 26px; }
.demo-facts li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; font-size: var(--t-sm); color: var(--fg-2); }
.demo-facts li::before {
  content: ""; width: 20px; height: 20px; margin-top: 1px; border-radius: 6px;
  background: var(--ok-bg) no-repeat center / 12px 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%2324653f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.demo-gate .fine, .demo-mission-card .fine { margin-top: 16px; }
.demo-facts b { color: var(--fg); }
.demo-signup { display: grid; gap: 10px; max-width: 32rem; margin-bottom: 8px; }
.demo-signup .fine, .demo-signup .err { margin-top: 0; }
.demo-signup .demo-gate-actions { margin-top: 6px; }
.demo-downloads { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding-bottom: clamp(2rem, 1.5rem + 2vw, 3.5rem); }
.demo-downloads .fine { flex-basis: 100%; margin-top: 0; }
.demo-downloads code { font-family: var(--font-mono); font-size: .75em; word-break: break-all; }
.demo-gate-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.demo-mission-card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 18px; padding: clamp(20px, 1rem + 1vw, 28px); }
.demo-mission-card h2 { font-size: var(--t-lg); font-weight: 700; margin-bottom: 16px; }
.demo-mission-card ol { padding-left: 1.4em; display: grid; gap: 9px; font-size: var(--t-sm); color: var(--fg-2); }
.demo-mission-card li::marker { font-family: var(--font-mono); color: var(--muted); }
.demo-mission-card li.is-done { color: var(--ok); }
.demo-mission-card li.is-done::marker { content: "✓  "; }
.demo-progress { height: 8px; border-radius: 999px; background: var(--bg-sunk); overflow: hidden; margin-block: 8px 4px; }
.demo-progress span { display: block; height: 100%; width: 0; background: var(--forge-2); border-radius: inherit; transition: width .3s ease; }

/* App shell */
.demo-app { display: grid; grid-template-columns: 228px minmax(0, 1fr) 300px; min-height: calc(100vh - 60px); }
.demo-nav {
  border-right: 1px solid var(--line); background: var(--bg-raised);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); align-self: start; height: calc(100vh - 60px); overflow-y: auto;
}
.demo-nav-group { font-size: .6875rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.demo-nav-group:first-child { padding-top: 0; }
.demo-nav button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  text-align: left; border: 0; background: transparent; color: var(--fg-2); cursor: pointer;
  font: 500 var(--t-sm)/1.2 var(--font-body); padding: 10px 10px; border-radius: 9px;
}
.demo-nav button:hover { background: var(--bg-sunk); color: var(--fg); }
.demo-nav button[aria-current="page"] { background: var(--forge); color: var(--forge-fg); font-weight: 650; }
.demo-nav .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.demo-nav button[aria-current="page"] .dot { background: var(--lime); }
.demo-main { min-width: 0; padding: 22px max(16px, env(safe-area-inset-right, 0px)) 60px max(16px, env(safe-area-inset-left, 0px)); padding-inline: clamp(16px, 1rem + 1.5vw, 36px); }
.demo-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 22px;
  font-size: var(--t-xs); color: var(--fg-2); background: var(--bg-sunk); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.demo-banner b { color: var(--fg); }
.demo-missions {
  border-left: 1px solid var(--line); background: var(--bg-raised); padding: 20px 18px 40px;
  position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); align-self: start; height: calc(100vh - 60px); overflow-y: auto;
}
.demo-missions-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.demo-missions h2 { font-size: var(--t-md); font-weight: 700; }
.demo-missions .close { display: none; }
.mission-list { list-style: none; display: grid; gap: 8px; margin-top: 14px; }
.mission {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
.mission-check { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-strong); margin-top: 1px; display: grid; place-items: center; font: 700 12px/1 var(--font-body); color: transparent; }
.mission.is-done .mission-check { background: var(--forge-2); border-color: var(--forge-2); color: var(--forge-fg); }
.mission-title { font-size: var(--t-xs); font-weight: 650; line-height: 1.4; }
.mission.is-done .mission-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.mission-hint { font-size: .75rem; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.mission button { margin-top: 6px; border: 0; background: none; padding: 0; color: var(--link); font: 600 .75rem/1.2 var(--font-body); cursor: pointer; text-decoration: underline; text-underline-offset: .2em; }
.demo-missions-foot { display: grid; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.demo-all-done { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--forge); color: var(--forge-fg); font-size: var(--t-xs); display: grid; gap: 10px; }
.demo-all-done a { color: var(--lime); font-weight: 650; }

@media (max-width: 1279px) {
  .demo-app { grid-template-columns: 210px minmax(0, 1fr); }
  .demo-missions {
    position: fixed; top: 0; right: 0; bottom: 0; height: auto; width: min(340px, 92vw); z-index: 70;
    padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px));
    box-shadow: -20px 0 50px -20px rgba(0, 0, 0, .45); transform: translateX(105%); transition: transform .25s ease; visibility: hidden;
  }
  .demo-missions.is-open { transform: none; visibility: visible; }
  .demo-missions .close { display: inline-grid; }
}
@media (max-width: 860px) {
  .demo-app { grid-template-columns: minmax(0, 1fr); }
  .demo-nav {
    position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); z-index: 40; height: auto; flex-direction: row; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 8px max(12px, env(safe-area-inset-left, 0px)); gap: 4px; scrollbar-width: thin;
  }
  .demo-nav-group { display: none; }
  .demo-nav button { width: auto; white-space: nowrap; padding: 9px 12px; }
  .demo-nav .dot { display: none; }
}

/* Views */
.view-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.view-head h2 { font-family: var(--font-display); font-weight: 400; font-size: var(--t-xl); line-height: 1.1; }
.view-head h2:focus { outline: none; }
.view-head p { font-size: var(--t-sm); color: var(--fg-2); max-width: 64ch; margin-top: 6px; }
.panel {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 14px;
  padding: clamp(16px, .8rem + 1vw, 22px); margin-bottom: 18px; min-width: 0;
}
.panel h3 { font-size: var(--t-md); font-weight: 700; margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel-note { font-size: var(--t-xs); color: var(--muted); margin-top: -6px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .panel { margin-bottom: 0; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 4px; }
.metric strong { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.6rem, 1.2rem + 1vw, 2.1rem); line-height: 1; font-variant-numeric: tabular-nums; }
.metric span { font-size: var(--t-xs); color: var(--muted); }
@media (max-width: 760px) { .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tbl-wrap { overflow-x: auto; margin-inline: -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-xs); }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .mono { font-family: var(--font-mono); font-size: .75rem; color: var(--fg-2); white-space: nowrap; }
.tbl .low { color: var(--amber); font-weight: 650; }
.tbl .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tbl tr.is-selected td { background: var(--bg-sunk); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 650; padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--line); color: var(--fg-2); background: var(--bg); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.badge.bad { background: #f7d9d4; color: #8f2a19; border-color: transparent; }
:root[data-theme="dark"] .badge.bad { background: #3b1a14; color: #f2a493; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .badge.bad { background: #3b1a14; color: #f2a493; } }
.badge.sim { background: transparent; border-style: dashed; color: var(--muted); }
.badge.sim::before { display: none; }

.btn-s {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--fg); cursor: pointer;
  font: 600 var(--t-xs)/1 var(--font-body); white-space: nowrap; text-decoration: none;
}
.btn-s:hover { border-color: var(--fg); }
.btn-s.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn-s.primary:hover { background: var(--forge); border-color: var(--forge); color: var(--forge-fg); }
.btn-s.go { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.btn-s.go:hover { filter: brightness(1.04); }
.btn-s.danger { color: var(--amber); }
.btn-s[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.form { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 10px; align-items: end; }
.fld { display: grid; gap: 5px; min-width: 0; }
.fld > span { font-size: .75rem; font-weight: 650; color: var(--fg-2); }
.fld input, .fld select, .fld textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--fg); font: 400 var(--t-sm)/1.4 var(--font-body);
}
.fld textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.fld textarea.mono-in { font: 400 .8125rem/1.6 var(--font-mono); min-height: 140px; }
.fld input:focus-visible, .fld select:focus-visible, .fld textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: 1px dashed var(--line-strong); background: transparent; color: var(--fg-2); border-radius: 999px; padding: 6px 11px; font: 500 .75rem/1.3 var(--font-body); cursor: pointer; text-align: left; }
.chip-btn:hover { border-style: solid; color: var(--fg); }
.note-inline { font-size: var(--t-xs); color: var(--muted); line-height: 1.55; }
.err { color: var(--amber); font-size: var(--t-xs); font-weight: 600; }

.kv-list { display: grid; gap: 0; margin: 0; }
.kv-list > div { display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr); gap: 4px 14px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: var(--t-xs); }
.kv-list > div:last-child { border-bottom: 0; }
.kv-list dt { color: var(--muted); font-weight: 600; }
.kv-list dd { margin: 0; color: var(--fg); overflow-wrap: anywhere; }
@media (max-width: 520px) { .kv-list > div { grid-template-columns: minmax(0, 1fr); } }

.finding { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.finding:last-child { border-bottom: 0; }
.finding .src { grid-column: 1 / -1; font-size: .6875rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.finding b { display: block; font-size: var(--t-sm); }
.finding p { font-size: var(--t-xs); color: var(--fg-2); margin-top: 2px; overflow-wrap: anywhere; }
.recommend { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 16px; border-radius: 12px; margin-bottom: 12px; background: var(--bg-sunk); border: 1px solid var(--line); }
.recommend strong { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; line-height: 1; }
.recommend.hold { background: #f7d9d4; border-color: transparent; color: #6f1f12; }
.recommend.review { background: var(--amber-bg); border-color: transparent; color: var(--amber); }
.recommend.none { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
:root[data-theme="dark"] .recommend.hold { background: #3b1a14; color: #f2a493; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .recommend.hold { background: #3b1a14; color: #f2a493; } }

.term-box { background: var(--console-bg); color: var(--console-fg); border-radius: 14px; border: 1px solid var(--console-line); overflow: hidden; }
.term-out { margin: 0; padding: 16px; font: 400 .8125rem/1.7 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 380px; overflow-y: auto; }
.term-out .p { color: var(--lime); }
.term-out .dim { color: var(--console-muted); }
.term-out .w { color: var(--console-warn); }
.term-out .ok { color: var(--console-ok); }
.term-out .i { color: var(--console-info); }
.term-out .u { color: #fff; font-weight: 600; }
.term-in { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--console-line); background: var(--console-raised); }
.term-in input { flex: 1; min-width: 0; min-height: 40px; border-radius: 9px; border: 1px solid var(--console-line); background: var(--console-bg); color: var(--console-fg); padding: 0 12px; font: 400 .8125rem/1 var(--font-mono); }
.term-box + .chips { margin-top: 12px; }
.term-in input:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }
.repair-list { list-style: none; display: grid; gap: 8px; }
.repair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.repair b { font-size: var(--t-sm); display: block; }
.repair small { font-size: .75rem; color: var(--muted); }
.repair .confirm { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); font-size: var(--t-xs); font-weight: 600; }

.steps-run { list-style: none; display: grid; gap: 10px; }
.steps-run li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; font-size: var(--t-sm); color: var(--muted); }
.steps-run li::before { content: ""; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.steps-run li.is-done { color: var(--fg); }
.steps-run li.is-done::before { border-color: var(--ok); background: radial-gradient(circle, var(--ok) 0 3.5px, transparent 4px); }
.steps-run li.is-now::before { border-color: var(--amber); background: radial-gradient(circle, var(--amber) 0 3.5px, transparent 4px); }
@media (prefers-reduced-motion: no-preference) { .steps-run li.is-now::before { animation: pulse 1s ease-in-out infinite; } }
@keyframes pulse { 50% { transform: scale(.75); } }
.steps-run b { color: inherit; }
.steps-run small { display: block; font-size: var(--t-xs); color: var(--muted); }
.diff-block { margin: 0; padding: 14px; border-radius: 12px; background: var(--console-bg); color: var(--console-fg); font: 400 .75rem/1.65 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--console-line); }
.diff-block .add { color: var(--console-ok); }
.diff-block .del { color: #f2a493; }
.diff-block .hunk { color: var(--console-info); }
.file-list { list-style: none; display: grid; gap: 4px; font: 400 .75rem/1.6 var(--font-mono); color: var(--fg-2); }

.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; align-items: end; height: 150px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.bar { display: grid; align-content: end; gap: 1px; height: 100%; }
.bar i { display: block; border-radius: 3px 3px 0 0; min-height: 0; }
.bar .in { background: var(--forge-2); }
.bar .out { background: var(--line-strong); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .75rem; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .in::before { background: var(--forge-2); }
.legend .out::before { background: var(--line-strong); }

.secret { padding: 14px; border-radius: 12px; border: 2px solid var(--amber); background: var(--amber-bg); display: grid; gap: 8px; }
.secret code { font: 600 .875rem/1.4 var(--font-mono); overflow-wrap: anywhere; color: var(--fg); user-select: all; }
.eml { margin: 0; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font: 400 .75rem/1.6 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow: auto; }
.perm-tbl td:not(:first-child), .perm-tbl th:not(:first-child) { text-align: center; }
.perm-yes { color: var(--ok); font-weight: 700; }
.perm-no { color: var(--muted); }

.demo-toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 90;
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 12px;
  background: var(--fg); color: var(--bg); font-size: var(--t-sm); box-shadow: var(--shadow);
}
.demo-toast:empty { display: none; }
.demo-toast.is-warn { background: var(--amber); color: #fff; }
.demo-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 65; }

.demo-view-controls { display: inline-flex; align-items: center; gap: 8px; }
.demo-theme-select { min-height: 36px; border-radius: 999px; padding: 0 28px 0 12px; font: 600 var(--t-xs)/1 var(--font-body); background: rgba(255, 255, 255, .1); color: var(--forge-fg); border: 1px solid var(--forge-line); }
.demo-theme-select option { color: #0f1d2e; background: #ffffff; }
.demo-footer { padding: 18px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--t-xs); text-align: center; }

/* WCAG Readability & Contrast Safeguards Across All 4 Themes */
:root[data-theme="emerald"] .badge.bad,
:root[data-theme="emerald"] .recommend.hold {
  background: #3b1a14; color: #fca5a5;
}
:root[data-theme="kerjata"] .badge.bad,
:root[data-theme="kerjata"] .recommend.hold {
  background: #fef2f2; color: #b91c1c; border-color: #fecaca;
}
:root[data-theme="dark"] .demo-progress span,
:root[data-theme="emerald"] .demo-progress span,
:root[data-theme="kerjata"] .demo-progress span,
:root[data-theme="dark"] .bar .in,
:root[data-theme="emerald"] .bar .in,
:root[data-theme="kerjata"] .bar .in,
:root[data-theme="dark"] .legend .in::before,
:root[data-theme="emerald"] .legend .in::before,
:root[data-theme="kerjata"] .legend .in::before {
  background: var(--lime);
}
:root[data-theme="dark"] .demo-facts li::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%2396d6a4' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="emerald"] .demo-facts li::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%23b4f04a' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="kerjata"] .demo-facts li::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%232563eb' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.demo-toast.is-warn { background: var(--amber-bg); color: var(--amber); border: 1.5px solid var(--amber); }
.demo-role select option, .demo-theme-select option { background-color: var(--bg-raised); color: var(--fg); }
