.composition-panel{padding:1rem 1.5rem;border-bottom:1px solid var(--border);background:var(--panel-2)}
.composition-header{display:flex;flex-wrap:wrap;align-items:baseline;gap:.4rem 1rem;margin-bottom:.6rem}
.composition-header h3{margin:0;font-size:1rem}
.composition-header span{color:var(--subtle);font-size:.75rem}
.composition-track{display:flex;overflow:hidden;height:36px;border-radius:5px;width:100%}
.composition-region{flex-basis:0;min-width:0;padding:0;border:0;border-right:1px solid white;overflow:hidden;white-space:nowrap;color:#fff;font:600 11px var(--sans);cursor:pointer}
.composition-region:last-child{border-right:0}
.composition-region:focus-visible{outline:3px solid #111;outline-offset:-3px}
.composition-detail{font-size:.8rem;color:var(--subtle);min-height:1.5rem;margin:.5rem 0}
.composition-panel details{font-size:.8rem}
.composition-list{max-height:180px;overflow:auto;padding-left:1.5rem}
.composition-list button{border:0;background:none;text-align:left;color:var(--text);font:inherit;cursor:pointer;padding:.25rem 0}
.composition-list button:hover{text-decoration:underline}
.char.is-selected-region{outline:1px solid var(--accent);filter:brightness(.85)}
.demo-status{margin:0;padding:.3rem 1.5rem;font-size:.8rem;color:var(--subtle)}
.demo-status[data-mode="error"]{color:#b42318}
:root{
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-2: #fbfcff;
  --text: #111827;
  --subtle: #6b7280;
  --accent: #0b5ed7;
  --accent-2: #4ea0ff;
  --border: #e5e7eb;
  --muted: #f3f4f6;
  --chip: #f8fafc;
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);
  --radius: 16px;
  --code-font-size: 13px;
  --code-line-height: 1.5;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

*{box-sizing:border-box}
html,body{min-height:100%}
body{
  margin:0;
  background:
    radial-gradient(1200px 700px at 10% -10%, #ffffff, transparent 60%),
    var(--bg);
  background-attachment:fixed;
  background-repeat:no-repeat;
  color:var(--text);
  font-family:var(--sans);
  line-height:1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,.85);
  backdrop-filter:blur(8px);
}
.brand{
  font-size:20px;
  font-weight:700;
  letter-spacing:.3px;
}
.brand .brand-type{color:var(--accent)}
/* "Seg" in a brighter blue against "Type"'s deeper accent blue. */
.brand-seg{color:var(--accent-2)}
.topbar-actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--chip);
  font-size:12px;
  font-weight:700;
}
.badge.subtle{color:#0f172a}
.badge.neutral{color:var(--subtle)}
.link-badge{color:var(--accent);text-decoration:none;cursor:pointer;transition:background .15s,border-color .15s}
.link-badge:hover{border-color:var(--accent);background:#eef4ff}
.badge.success{
  color:#0b7a3e;
  background:rgba(46, 204, 113, 0.10);
  border-color:rgba(46, 204, 113, 0.30);
}
.badge.error{
  color:#b42318;
  background:rgba(231, 76, 60, 0.10);
  border-color:rgba(231, 76, 60, 0.30);
}

.shell{
  max-width:1240px;
  margin:24px auto;
  padding:0 16px;
  display:grid;
  gap:20px;
}

.panel{
  background:
    radial-gradient(1000px 500px at -10% -10%, #eaf2ff 0%, transparent 50%),
    var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}

.intro{
  display:grid;
  grid-template-columns:minmax(0, 1.5fr) minmax(280px, 1fr);
  gap:20px;
  padding:24px;
}
.eyebrow{
  margin:0 0 8px;
  color:var(--accent);
  text-transform:uppercase;
  letter-spacing:.12em;
  font-size:12px;
  font-weight:800;
}
.intro h1{
  margin:0 0 10px;
  font-size:32px;
  line-height:1.15;
  color:#0f172a;
}
.lede{
  margin:0;
  max-width:70ch;
  color:#475467;
}
.intro-meta{
  display:grid;
  gap:12px;
}
.meta-card{
  padding:16px 18px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.84);
  border-radius:14px;
}
.meta-label{
  display:block;
  margin-bottom:4px;
  color:var(--subtle);
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.08em;
}
.meta-card strong{
  font-size:16px;
  color:#0f172a;
}

.segmentor-panel .panel-head{
  /* Title row stacked above the controls row. Side-by-side never fit within
     the .shell max-width cap (title + controls overflow it), which produced a
     cramped middle band; stacking is robust at every width. */
  display:flex;
  flex-direction:column;
  gap:16px;
  padding:18px 20px;
  border-bottom:1px solid var(--border);
}
.panel-title{
  min-width:0;
}
.panel-title h2{
  margin:0 0 4px;
  font-size:18px;
  color:#0f172a;
  white-space:nowrap;
}
.status-line{
  margin:0;
  color:var(--subtle);
  font-size:13px;
}
.status-line a{color:var(--accent);text-decoration:none;font-weight:600}
.status-line a:hover{text-decoration:underline}

.controls{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
  flex:1 1 auto;
}
/* Keep the examples jump-link on the left, away from the primary actions. */
#moreExamplesBtn{margin-right:auto}
.counter-group{
  min-width:120px;
  padding:5px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
}
.threshold-group{
  min-width:165px;
  padding:5px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
}
.counter-label{
  display:block;
  color:var(--subtle);
  font-size:10px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.07em;
}
.counter-value{
  display:block;
  color:#0f172a;
  font-size:13px;
  font-weight:700;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}
.threshold-controls{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:2px;
}
.threshold-range{
  flex:1;
  min-width:54px;
  accent-color:var(--accent);
}
.threshold-input{
  width:66px;
  padding:3px 6px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--panel-2);
  color:var(--text);
  font:inherit;
  font-size:12px;
  font-weight:700;
  text-align:center;
  font-variant-numeric:tabular-nums;
}
.threshold-input:focus{
  outline:none;
  border-color:rgba(11,94,215,.45);
  box-shadow:0 0 0 3px rgba(11,94,215,.10);
}

.btn{
  background:#ffffff;
  border:1px solid var(--border);
  color:var(--text);
  padding:8px 12px;
  border-radius:12px;
  font-weight:600;
  cursor:pointer;
  box-shadow:0 1px 0 rgba(15,23,42,.03);
  transition:border-color .15s ease, box-shadow .15s ease, transform .02s ease;
}
.btn:hover{border-color:#d1d5db; box-shadow:0 2px 10px rgba(15,23,42,.06)}
.btn.primary{
  background:linear-gradient(180deg, var(--accent-2), var(--accent));
  color:#fff;
  border:none;
  box-shadow:0 6px 18px rgba(11,94,215,.25);
}
.btn:disabled{
  opacity:.6;
  cursor:not-allowed;
}
.btn:active{transform:translateY(1px)}
.btn-arrow{
  display:inline-block;
  vertical-align:-1px;
  margin-left:6px;
  animation:btnArrowBounce 1.8s ease-in-out infinite;
}
.btn:hover .btn-arrow{animation-duration:.9s}
@keyframes btnArrowBounce{
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(2px)}
}
@media (prefers-reduced-motion: reduce){
  .btn-arrow{animation:none}
}

.body{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:20px;
  padding:0 20px 24px;
}
.editor-pane,
.output-pane{
  min-width:0;
  display:flex;
  flex-direction:column;
}
.pane-label{
  display:block;
  margin:0 0 4px;
  color:#0f172a;
  font-size:13px;
  font-weight:700;
}
.code{
  flex:1 1 auto;
  width:100%;
  min-height:500px;
  border:1px solid var(--border);
  border-radius:14px;
  outline:none;
  resize:vertical;
  padding:16px;
  background:var(--panel-2);
  color:var(--text);
  font-family:var(--mono);
  font-size:var(--code-font-size);
  line-height:var(--code-line-height);
  tab-size:2;
}
.code:focus{
  border-color:rgba(11,94,215,.45);
  box-shadow:0 0 0 3px rgba(11,94,215,.10);
}
.input-hint{
  margin:10px 0 0;
  color:var(--subtle);
  font-size:12px;
}

.pane-head{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-start;
  min-height:56px;
  padding-top:16px;
}
.result-meta{
  margin:0;
  color:var(--subtle);
  font-size:12px;
}

.legend{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-start;
  padding-top:12px;
}
.chip{
  display:flex;
  align-items:center;
  gap:8px;
  background:var(--chip);
  border:1px solid var(--border);
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  color:#0f172a;
}
.dot{
  width:10px;
  height:10px;
  border-radius:50%;
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.08);
  flex:0 0 auto;
}

.render{
  flex:1 1 auto;
  min-height:500px;
  overflow:auto;
  white-space:pre-wrap;
  font-family:var(--mono);
  font-size:var(--code-font-size);
  line-height:var(--code-line-height);
  tab-size:2;
  padding:16px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:14px;
  overflow-wrap:normal;
  word-break:normal;
}
.render.empty{
  color:var(--subtle);
}

.stats{
  padding:14px 0 0;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.stat{
  background:#fff;
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color:#0f172a;
}
.bar{
  height:8px;
  width:120px;
  background:#eef2f7;
  border-radius:8px;
  overflow:hidden;
  border:1px solid #e3e8ef;
}
.bar > i{
  display:block;
  height:100%;
}

.char{
  position:relative;
  cursor:pointer;
  display:inline;
  border-radius:3px;
  padding:0;
  margin:0;
  line-height:inherit;
  transition:background .12s ease, box-shadow .12s ease;
  --seg-color:#888888;
}
.char:hover,
.char:focus{
  outline:2px solid color-mix(in srgb, var(--seg-color) 38%, transparent);
  outline-offset:1px;
}
.char.newline{
  /* the literal "\n" inside renders as exactly one break via the
     container's white-space:pre-wrap — no <br>, no block box */
  display:inline;
}

.tooltip{
  display:none;
  position:fixed;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:8px 12px;
  font-family:var(--sans);
  font-size:14px;
  line-height:1.4;
  color:var(--text);
  box-shadow:var(--shadow);
  z-index:1000;
  pointer-events:none;
  max-width:260px;
}
.prob-bar{
  display:flex;
  align-items:center;
  margin:4px 0;
}
.prob-bar .label{
  flex:1;
  min-width:80px;
}
.prob-bar .bar{
  flex:2;
  height:8px;
  background:var(--muted);
  border-radius:4px;
  overflow:hidden;
  margin:0 8px;
}
.prob-bar .fill{
  height:100%;
  background:var(--color, var(--accent));
}
.pp-trace{
  margin-top:6px;
  padding-top:6px;
  border-top:1px solid var(--border);
  font-size:12px;
  color:var(--subtle);
}
.pp-trace b{
  color:var(--text);
}
.pp-trace .pp-step{
  font-style:italic;
}

.footer{
  color:var(--subtle);
  font-size:12px;
  padding:24px 0 40px;
}
.footer-privacy{
  margin:0;
  text-align:center;
}
.footer-acknowledgments{
  width:min(860px, calc(100% - 32px));
  margin:24px auto 0;
  padding-top:24px;
  border-top:1px solid var(--border);
  text-align:left;
  font-size:13px;
  line-height:1.65;
}
.footer-acknowledgments h2{
  margin:0 0 10px;
  color:var(--text);
  font-size:15px;
}
.footer-acknowledgments p{
  margin:0;
}
.footer-acknowledgments a{
  color:inherit;
}

@media (max-width: 1120px){
  .intro{
    grid-template-columns:1fr;
  }
  .body{
    grid-template-columns:1fr;
  }
  .code,
  .render{
    min-height:360px;
  }
}

@media (max-width: 760px){
  .topbar{
    padding:14px 16px;
    align-items:flex-start;
    gap:12px;
    flex-direction:column;
  }
  .segmentor-panel .panel-head{
    flex-direction:column;
  }
  .panel-title{
    flex:0 0 auto;
  }
  .panel-title h2{
    white-space:normal;
  }
  .controls{
    justify-content:flex-start;
  }
  .threshold-group{
    width:100%;
  }
  .legend{
    justify-content:flex-start;
  }
}

/* ── Examples Section ── */
@property --gradient-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes spin-gradient {
  to { --gradient-angle: 360deg; }
}

.examples-section {
  margin-top: 12px;
  text-align: center;
}

.examples-heading {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  background: linear-gradient(135deg, var(--accent), #8b5cf6, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.examples-subtext {
  color: var(--subtle);
  font-size: 0.875rem;
  margin: 0 0 20px 0;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.example-card {
  position: relative;
  border-radius: 14px;
  padding: 2px;
  background: conic-gradient(
    from var(--gradient-angle),
    #0b5ed7 0%,
    #8b5cf6 25%,
    #ec4899 50%,
    #f59e0b 75%,
    #0b5ed7 100%
  );
  animation: spin-gradient 3s linear infinite;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.example-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.25);
}

.example-card-inner {
  background: var(--panel);
  border-radius: 12px;
  padding: 16px;
  height: 100%;
  text-align: left;
}

.example-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 6px 0;
  color: var(--text);
}

.example-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.example-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--muted);
  color: var(--subtle);
}

.example-card-preview {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--subtle);
  white-space: pre-wrap;
  overflow: hidden;
  max-height: 72px;
  mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

/* ── Runtime status splash overlay ── */
.runtime-overlay{
  position:fixed;
  inset:0;
  z-index:2000;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:
    radial-gradient(900px 600px at 50% 38%, rgba(234,242,255,.55), transparent 70%),
    rgba(247,249,252,.66);
  backdrop-filter:blur(12px) saturate(140%);
  -webkit-backdrop-filter:blur(12px) saturate(140%);
  /* hidden resting state — JS toggles .is-visible */
  opacity:0;
  pointer-events:none;
  transition:opacity .55s cubic-bezier(.22,1,.36,1), visibility .55s;
  visibility:hidden;
}
.runtime-overlay.is-visible{
  opacity:1;
  pointer-events:auto;
  visibility:visible;
}

.runtime-overlay-card{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:16px;
  padding:40px 52px 36px;
  border-radius:24px;
  background:rgba(255,255,255,.84);
  backdrop-filter:blur(22px) saturate(160%);
  -webkit-backdrop-filter:blur(22px) saturate(160%);
  border:1px solid var(--border);
  box-shadow:
    0 36px 90px rgba(15,23,42,.24),
    0 6px 18px rgba(15,23,42,.08),
    inset 0 1px 0 rgba(255,255,255,.75);
  text-align:center;
  transform:translateY(14px) scale(.96);
  transition:transform .55s cubic-bezier(.22,1,.36,1), border-color .4s ease;
  will-change:transform;
}
.runtime-overlay.is-visible .runtime-overlay-card{
  transform:translateY(0) scale(1);
}
.runtime-overlay[data-state="error"] .runtime-overlay-card{
  border-color:rgba(231,76,60,.45);
}

.runtime-overlay-brand{
  font-size:26px;
  font-weight:800;
  letter-spacing:.3px;
  line-height:1;
}
.runtime-overlay-brand .brand-type{color:var(--accent)}
.runtime-overlay-brand .brand-seg{color:var(--accent-2)}

.runtime-overlay-icon{
  position:relative;
  width:56px;
  height:56px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin:4px 0 2px;
}
/* Show only the glyph for the current state. */
.runtime-overlay .rt-spinner,
.runtime-overlay .rt-check,
.runtime-overlay .rt-cross{display:none}
.runtime-overlay[data-state="loading"] .rt-spinner{display:block}
.runtime-overlay[data-state="success"] .rt-check{display:block}
.runtime-overlay[data-state="error"] .rt-cross{display:block}

/* Gradient-arc ring spinner (masked donut). */
.rt-spinner{
  width:52px;
  height:52px;
  border-radius:50%;
  background:conic-gradient(from 90deg, transparent 6%, var(--accent-2) 55%, var(--accent) 100%);
  -webkit-mask:radial-gradient(farthest-side, #0000 calc(100% - 6px), #000 calc(100% - 5.5px));
  mask:radial-gradient(farthest-side, #0000 calc(100% - 6px), #000 calc(100% - 5.5px));
  animation:rtSpin .85s linear infinite;
}
@keyframes rtSpin{to{transform:rotate(360deg)}}

/* Check / cross stroke-draw on state entry. */
.rt-check, .rt-cross{ width:40px; height:40px; }
.rt-check path{
  stroke:#0b7a3e;
  stroke-width:2.4;
  stroke-linecap:round;
  stroke-linejoin:round;
  stroke-dasharray:24;
  stroke-dashoffset:24;
}
.runtime-overlay[data-state="success"] .rt-check path{
  animation:rtDraw .45s .05s cubic-bezier(.65,0,.35,1) forwards;
}
.rt-cross path{
  stroke:#b42318;
  stroke-width:2.4;
  stroke-linecap:round;
  stroke-dasharray:32;
  stroke-dashoffset:32;
}
.runtime-overlay[data-state="error"] .rt-cross path{
  animation:rtDraw .32s ease forwards;
}
@keyframes rtDraw{to{stroke-dashoffset:0}}

.runtime-overlay-title{
  font-size:18px;
  font-weight:700;
  color:var(--text);
}
.runtime-overlay[data-state="error"] .runtime-overlay-title{
  color:#b42318;
}
.runtime-overlay-sub{
  font-size:13px;
  color:var(--subtle);
  margin-top:-6px;
}
.runtime-overlay[data-state="error"] .runtime-overlay-sub{
  color:var(--subtle);
}

@media (prefers-reduced-motion: reduce){
  .runtime-overlay{ transition:opacity .2s ease, visibility .2s; }
  .runtime-overlay-card{ transform:none; transition:none; }
  .runtime-overlay.is-visible .runtime-overlay-card{ transform:none; }
  .rt-spinner{ animation-duration:1.5s; }
  .rt-check path,
  .rt-cross path{ animation:none; stroke-dashoffset:0; }
}
