/* Ewings Papers simulations: shared styles for the PIN gate, the landing page and every simulation page.
   The look follows the new Ewings Papers site (/staging/): Plus Jakarta Sans, white and soft grey surfaces, the blue and
   gold of the brand, pill buttons, a floating glass nav bar and a thin blue-to-gold line along the top. */
:root, [data-theme="light"] {
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-surface-alt: #f6f7f9;
  --color-surface-sunken: #eef0f3;
  --color-text: #1b1b1b;
  --color-text-muted: #63666d;
  --color-text-faint: #9498a0;
  --color-border: #e5e7eb;
  --color-border-strong: #d4d7dc;
  --color-blue: #2b5fe2;
  --color-blue-hover: #1f4bc0;
  --color-blue-soft: #ecf1fe;
  --color-blue-contrast: #ffffff;
  --color-gold: #eeaa1f;
  --color-gold-hover: #d3930f;
  --color-gold-soft: #fdf3df;
  --color-gold-ink: #9a6a06;
  --color-danger: #d8433a;
  --color-danger-soft: #fbeae9;
  --color-success: #1c9a6c;
  --color-success-soft: #e8f7f0;
  --shadow-card: 0 1px 2px rgba(27, 27, 27, .04), 0 12px 32px rgba(27, 27, 27, .08);
  --shadow-panel: 0 24px 64px rgba(27, 27, 27, .14);
  --focus-ring: 0 0 0 3px rgba(43, 95, 226, .25);
  --glass: color-mix(in srgb, var(--color-bg) 80%, transparent);
  --view-bg: #e9edf2;
  --font: "Plus Jakarta Sans", "Noto Sans Sinhala", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --color-bg: #1b1b1b;
  --color-surface: #232323;
  --color-surface-alt: #2a2a2b;
  --color-surface-sunken: #181818;
  --color-text: #f5f5f6;
  --color-text-muted: #a7a9ae;
  --color-text-faint: #74767c;
  --color-border: #34343a;
  --color-border-strong: #414147;
  --color-blue: #5a8dff;
  --color-blue-hover: #7ba2ff;
  --color-blue-soft: rgba(90, 141, 255, .14);
  --color-blue-contrast: #0f1420;
  --color-gold: #f3c04b;
  --color-gold-hover: #f7cf70;
  --color-gold-soft: rgba(243, 192, 75, .14);
  --color-gold-ink: #f3c04b;
  --color-danger: #ff7a70;
  --color-danger-soft: rgba(255, 122, 112, .14);
  --color-success: #3fd598;
  --color-success-soft: rgba(63, 213, 152, .14);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-panel: 0 24px 64px rgba(0, 0, 0, .55);
  --focus-ring: 0 0 0 3px rgba(90, 141, 255, .35);
  --view-bg: #202124;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); color: var(--color-text); background: var(--color-bg);
  -webkit-font-smoothing: antialiased; line-height: 1.5; transition: background-color .25s ease, color .25s ease;
}
html[lang="si"] body { line-height: 1.65; }
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.eq, .sym { font-family: var(--serif); font-style: italic; font-weight: 400; }

/* the thin brand line along the top of every page */
.topline { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 90; background: linear-gradient(90deg, var(--color-blue), var(--color-gold)); }

/* soft brand glows behind the landing page */
.glow { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(48vw 40vh at 8% 6%, color-mix(in srgb, var(--color-blue) 11%, transparent), transparent 70%),
              radial-gradient(42vw 36vh at 96% 4%, color-mix(in srgb, var(--color-gold) 14%, transparent), transparent 70%); }

/* ---------- buttons, pills, chips (the site's own shapes) ---------- */
.ew-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 1.5px solid transparent; font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap;
  background: var(--color-surface-sunken); color: var(--color-text);
  transition: background-color .16s ease, color .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.ew-btn:hover { transform: translateY(-1px); }
.ew-btn:active { transform: translateY(1px); }
.ew-btn svg { width: 18px; height: 18px; flex: none; transition: transform .2s ease; }
.ew-btn:hover svg:last-child:not(:first-child) { transform: translateX(4px); }
.ew-btn--blue { background: var(--color-blue); color: var(--color-blue-contrast); box-shadow: 0 8px 22px -8px var(--color-blue); }
.ew-btn--blue:hover { background: var(--color-blue-hover); }
.ew-btn--gold { background: var(--color-gold); color: #1b1b1b; }
.ew-btn--gold:hover { background: var(--color-gold-hover); }
.ew-btn--danger { background: var(--color-danger); color: #fff; box-shadow: 0 8px 22px -8px var(--color-danger); }
.ew-btn--outline { background: transparent; border-color: var(--color-border-strong); }
.ew-btn--outline:hover { border-color: var(--color-blue); color: var(--color-blue); background: var(--color-blue-soft); }
.ew-btn--ghost { background: transparent; color: var(--color-text-muted); }
.ew-btn--ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }
.ew-btn--wide { flex: 1; }
.ew-btn--sm { min-height: 40px; padding: 0 14px; font-size: 13.5px; }
.ew-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.ew-btn--icon { width: 44px; min-height: 44px; padding: 0; }

.ew-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; background: var(--color-blue-soft); color: var(--color-blue);
  font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.ew-chip--gold { background: var(--color-gold-soft); color: var(--color-gold-ink); }
.ew-chip--plain { background: var(--color-surface-sunken); color: var(--color-text-muted); letter-spacing: .02em; text-transform: none; font-size: 12.5px; font-weight: 700; }
html[lang="si"] .ew-chip { letter-spacing: 0; text-transform: none; }

.ew-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.ew-pill {
  display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid transparent; background: var(--color-surface-sunken); color: var(--color-text-muted);
  border-radius: 999px; min-height: 44px; padding: 0 16px; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}
.ew-pill:hover { color: var(--color-blue); background: var(--color-blue-soft); }
.ew-pill[aria-selected="true"], .ew-pill[aria-pressed="true"] { background: var(--color-blue); border-color: var(--color-blue); color: var(--color-blue-contrast); }
.ew-pill__n { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; font-size: 12px; background: var(--color-gold); color: #1b1b1b; }

/* ---------- floating nav bar (both pages) ---------- */
.ew-nav { position: sticky; top: 0; z-index: 60; padding: 12px 16px 0; }
.ew-nav__bar {
  max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 18px;
  border-radius: 999px; border: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); box-shadow: var(--shadow-card);
}
.ew-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ew-brand img { width: 40px; height: 32px; object-fit: contain; flex: none; }
.ew-brand__name { font-weight: 800; font-size: 18px; letter-spacing: -.02em; white-space: nowrap; }
.ew-brand__name b { color: var(--color-gold); }
.ew-nav__spacer { flex: 1; }
.ew-nav__title { font-weight: 800; font-size: 17px; letter-spacing: -.01em; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ew-nav__title .eq { font-size: 1.12em; }
.ew-lang { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--color-surface-sunken); }
.ew-lang button { min-width: 44px; height: 36px; padding: 0 10px; border: 0; border-radius: 999px; background: none; font-weight: 800; font-size: 13px; color: var(--color-text-muted); cursor: pointer; }
.ew-lang button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.ew-round { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--color-surface-sunken); color: var(--color-text); cursor: pointer; transition: background-color .16s ease, color .16s ease; }
.ew-round:hover { background: var(--color-blue-soft); color: var(--color-blue); }
.ew-round svg { width: 20px; height: 20px; }
.ew-back { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px 0 10px; border-radius: 999px; background: var(--color-surface-sunken); font-weight: 700; font-size: 14px; flex: none; }
.ew-back:hover { background: var(--color-blue-soft); color: var(--color-blue); }
.ew-back svg { width: 20px; height: 20px; }

/* ---------- PIN gate ---------- */
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: var(--color-bg); }
.gate::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(50vw 50vh at 15% 10%, color-mix(in srgb, var(--color-blue) 12%, transparent), transparent 70%),
              radial-gradient(45vw 45vh at 90% 90%, color-mix(in srgb, var(--color-gold) 14%, transparent), transparent 70%); }
.gate__card { position: relative; width: min(440px, 100%); padding: 32px 28px 26px; text-align: center; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 28px; box-shadow: var(--shadow-panel); }
.gate__card.is-bad { animation: gate-shake .36s; }
@keyframes gate-shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.gate__logo { width: 72px; height: 56px; object-fit: contain; margin: 0 auto; }
.gate h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 14px 0 6px; }
.gate p { margin: 0 0 20px; color: var(--color-text-muted); }
.gate__boxes { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; margin: 0 auto 16px; max-width: 380px; }
.gate__box { height: 56px; display: grid; place-items: center; border-radius: 14px; font-size: 1.6rem; font-weight: 800; background: var(--color-surface-sunken); border: 1.5px solid transparent; transition: border-color .15s, box-shadow .15s; }
.gate__box.is-on { background: var(--color-blue-soft); color: var(--color-blue); }
.gate__box.is-cur { border-color: var(--color-blue); box-shadow: var(--focus-ring); }
.gate__input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; caret-color: transparent; }
.gate__btn { width: 100%; min-height: 52px; border: 0; border-radius: 999px; background: var(--color-blue); color: var(--color-blue-contrast); font-weight: 800; font-size: 16px; cursor: pointer; box-shadow: 0 8px 22px -8px var(--color-blue); }
.gate__btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.gate__err { min-height: 1.5em; margin: 12px 0 0 !important; color: var(--color-danger) !important; font-weight: 700; }
.gate__note { margin-top: 6px; font-size: 13px; color: var(--color-text-faint); }

/* ---------- landing ---------- */
.land { max-width: 1240px; margin: 0 auto; padding: clamp(36px, 6vw, 72px) 24px 64px; }
.hero { display: grid; gap: 18px; max-width: 760px; }
.hero__badge { justify-self: start; display: inline-flex; align-items: center; gap: 9px; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-surface) 70%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-border) 80%, transparent); }
.hero__badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--color-success); box-shadow: 0 0 0 4px var(--color-success-soft); }
.hero h1 { font-size: clamp(38px, 5.4vw, 64px); line-height: 1.06; font-weight: 800; letter-spacing: -.03em; }
html[lang="si"] .hero h1 { font-size: clamp(28px, 3.9vw, 46px); line-height: 1.34; letter-spacing: 0; }
.is-blue { background: linear-gradient(100deg, var(--color-blue), #7aa2ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.is-gold { background: linear-gradient(100deg, var(--color-gold-hover), var(--color-gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero__swash { width: min(420px, 70%); height: 14px; color: var(--color-gold); margin-top: -6px; }
.hero__lead { font-size: 18px; color: var(--color-text-muted); max-width: 60ch; line-height: 1.7; }
.units { margin-top: clamp(32px, 5vw, 56px); }
.units__label { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-faint); margin-bottom: 12px; }
html[lang="si"] .units__label { letter-spacing: 0; text-transform: none; font-size: 14px; }
.ew-pill .unit__no { font-variant-numeric: tabular-nums; opacity: .7; }
.shelf { margin-top: 28px; }
.shelf__head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.shelf__title { font-size: clamp(24px, 3vw, 34px); font-weight: 800; letter-spacing: -.02em; }
html[lang="si"] .shelf__title { letter-spacing: 0; line-height: 1.35; }
.shelf__sub { color: var(--color-text-muted); font-weight: 600; }
.shelf__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 20px; }
.sim { display: flex; flex-direction: column; overflow: hidden; border-radius: 28px; background: var(--color-surface-alt); border: 1px solid transparent;
  transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease; }
.sim:hover { transform: translateY(-4px); box-shadow: var(--shadow-panel); border-color: var(--color-border); }
.sim__img { position: relative; margin: 10px 10px 0; border-radius: 20px; overflow: hidden; aspect-ratio: 16 / 9; background: var(--view-bg); }
.sim__img img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.sim:hover .sim__img img { transform: scale(1.04); }
.sim__formula { position: absolute; left: 14px; top: 14px; padding: 8px 16px; border-radius: 999px; background: color-mix(in srgb, var(--color-bg) 86%, transparent); backdrop-filter: blur(8px);
  font-family: var(--serif); font-size: 22px; line-height: 1.1; box-shadow: var(--shadow-card); }
.sim__formula i { font-style: italic; }
.sim__body { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.sim__title { font-size: 21px; font-weight: 800; letter-spacing: -.01em; line-height: 1.3; }
html[lang="si"] .sim__title { letter-spacing: 0; line-height: 1.45; }
.sim__text { color: var(--color-text-muted); }
.sim__facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sim__foot { margin-top: auto; padding-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.empty { border-radius: 28px; padding: 36px; background: var(--color-surface-alt); text-align: center; color: var(--color-text-muted); }
.empty__icon { width: 56px; height: 56px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 18px; background: var(--color-gold-soft); color: var(--color-gold-ink); }
.empty strong { display: block; font-size: 18px; color: var(--color-text); margin-bottom: 4px; }
.foot { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--color-border); color: var(--color-text-faint); font-size: 13px; }

@media (max-width: 760px) {
  .ew-nav { padding: 8px 10px 0; }
  .ew-nav__bar { padding: 6px 6px 6px 12px; gap: 8px; }
  .ew-brand__name span { display: none; }
  .units .ew-pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .units .ew-pills::-webkit-scrollbar { display: none; }
}

/* ---------- simulation page ---------- */
.simpage { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.simpage .ew-nav { position: relative; padding-bottom: 10px; }
.simpage .ew-nav__bar { max-width: none; }
.stage { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr clamp(360px, 27vw, 450px); gap: 12px; padding: 0 12px 12px; }
.view { position: relative; min-width: 0; min-height: 0; overflow: hidden; touch-action: none; border-radius: 24px; background: var(--view-bg); box-shadow: inset 0 0 0 1px var(--color-border); }
.view canvas.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.view.is-grab canvas.gl { cursor: grab; }
.view.is-hot canvas.gl { cursor: pointer; }
.view.is-turn canvas.gl { cursor: ew-resize; }
.loading { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; align-content: center; gap: 14px; font-weight: 700; color: var(--color-text-muted); background: var(--view-bg); }
.loading::before { content: ""; width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--color-blue-soft); border-top-color: var(--color-blue); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* glass cards floating on the 3D view */
.glass { background: color-mix(in srgb, var(--color-bg) 84%, transparent); backdrop-filter: blur(12px) saturate(1.3); -webkit-backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid color-mix(in srgb, var(--color-border) 80%, transparent); box-shadow: var(--shadow-card); }
.formula { position: absolute; left: 14px; top: 14px; z-index: 4; display: flex; align-items: flex-end; gap: clamp(8px, 1.4vw, 20px); padding: 12px 22px 10px; border-radius: 22px; }
.formula__cell { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 7ch; }
.formula__sym { font-family: var(--serif); font-style: italic; font-size: clamp(26px, 2.6vw, 38px); line-height: 1; }
.formula__val { font-weight: 800; font-size: clamp(17px, 1.6vw, 24px); font-variant-numeric: tabular-nums; white-space: nowrap; }
.formula__cap { font-size: 12px; font-weight: 600; color: var(--color-text-muted); white-space: nowrap; }
.formula__op { font-family: var(--serif); font-size: clamp(24px, 2.4vw, 34px); color: var(--color-text-faint); align-self: center; padding-bottom: 14px; }
.formula__cell--i .formula__val { color: var(--color-blue); }
.status { position: absolute; right: 14px; top: 14px; z-index: 4; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: 44%; }
.stat { display: inline-flex; align-items: center; gap: 9px; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14.5px; }
.stat b { font-variant-numeric: tabular-nums; font-weight: 800; }
.stat .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-text-faint); flex: none; }
.stat .dot.is-on { background: var(--color-success); box-shadow: 0 0 0 4px var(--color-success-soft); }
.stat .dot.is-rec { background: var(--color-danger); box-shadow: 0 0 0 4px var(--color-danger-soft); animation: rec 1s infinite; }
@keyframes rec { 50% { opacity: .35; } }
.stat--warn { background: var(--color-gold-soft); color: var(--color-gold-ink); border-color: transparent; }
.stat--bad { background: var(--color-danger); color: #fff; border-color: transparent; }
.graph { position: absolute; left: 14px; bottom: 74px; z-index: 4; width: min(380px, 40%); padding: 12px 14px 10px; border-radius: 22px; }
.graph__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.graph h2 { font-size: 14px; font-weight: 800; }
.graph.is-folded canvas { display: none; }
.graph.is-folded { width: auto; }
.graph canvas { width: 100%; height: 170px; display: block; touch-action: none; }
.graph__tip { position: absolute; pointer-events: none; padding: 5px 10px; border-radius: 999px; background: var(--color-text); color: var(--color-bg); font-size: 13px; font-weight: 700; white-space: nowrap; transform: translate(-50%, -125%); }
.views { position: absolute; right: 14px; bottom: 14px; z-index: 4; display: flex; gap: 2px; padding: 5px; border-radius: 999px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: calc(100% - 28px); }
.views::-webkit-scrollbar { display: none; }
.views button { flex: none; min-height: 40px; padding: 0 13px; border: 0; border-radius: 999px; background: none; font-weight: 700; font-size: 14px; color: var(--color-text-muted); cursor: pointer; white-space: nowrap; }
.views button:hover { color: var(--color-blue); background: var(--color-blue-soft); }
.views button[aria-pressed="true"] { background: var(--color-blue); color: var(--color-blue-contrast); }
.result { position: absolute; right: 14px; bottom: 74px; z-index: 6; width: min(480px, calc(100% - 28px)); padding: 20px 22px; border-radius: 24px; background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow-panel); }
.result::before { content: ""; position: absolute; left: 22px; right: 22px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: linear-gradient(90deg, var(--color-blue), var(--color-gold)); }
.result h2 { font-size: 17px; font-weight: 800; margin: 2px 0 10px; }
.result .lines { display: grid; gap: 4px; font-size: 17px; font-variant-numeric: tabular-nums; }
.result .lines div:last-child { font-weight: 800; color: var(--color-blue); }
.result .ok { margin-top: 10px; color: var(--color-text-muted); }
.result__x { position: absolute; right: 10px; top: 10px; }
/* names floating over the 3D parts */
.tags { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 800; white-space: nowrap;
  background: rgba(27, 27, 27, .78); color: #fff; backdrop-filter: blur(6px); transition: opacity .2s ease; }
.tag--gold { color: #ffd77a; }
.tag--blue { color: #a9c3ff; }
.tag--red { color: #ffb0a9; }
.hint { position: absolute; z-index: 7; left: 0; top: 0; pointer-events: none; transform: translate(14px, 14px); padding: 8px 12px; border-radius: 14px; font-size: 13.5px; font-weight: 700; max-width: 280px;
  background: var(--color-text); color: var(--color-bg); box-shadow: var(--shadow-card); }
.hint small { display: block; font-weight: 600; opacity: .7; }
.toast { position: absolute; left: 50%; top: 14px; z-index: 7; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; font-weight: 800; font-size: 14.5px;
  background: var(--color-danger); color: #fff; box-shadow: 0 10px 30px -10px var(--color-danger); max-width: calc(100% - 28px); text-align: center; }
.toast--gold { background: var(--color-gold); color: #1b1b1b; box-shadow: 0 10px 30px -10px var(--color-gold); }

/* the side panel */
.panel { min-height: 0; overflow-y: auto; border-radius: 24px; background: var(--color-surface-alt); display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; }
.tabs { position: sticky; top: 12px; z-index: 2; box-shadow: 0 -12px 0 12px var(--color-surface-alt); display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 12px 12px 0; padding: 5px; border-radius: 999px; background: var(--color-surface-sunken); }
.tabs button { min-height: 44px; border: 0; border-radius: 999px; background: none; font-weight: 800; font-size: 14.5px; color: var(--color-text-muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.pane { padding: 14px 12px 24px; display: flex; flex-direction: column; gap: 12px; }
.card { padding: 16px; border-radius: 20px; background: var(--color-surface); display: flex; flex-direction: column; gap: 12px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card__title { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card__title svg { width: 18px; height: 18px; color: var(--color-blue); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.big-val { font-weight: 800; font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.big-val small { font-size: 15px; color: var(--color-text-muted); font-weight: 700; }
.lbl { font-size: 13.5px; font-weight: 700; color: var(--color-text-muted); }
.switch { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 6px 4px; border: 0; background: none; cursor: pointer; text-align: left; }
.switch__track { flex: none; width: 56px; height: 32px; border-radius: 999px; background: var(--color-border-strong); position: relative; transition: background .2s; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
[aria-checked="true"] > .switch__track { background: var(--color-blue); }
[aria-checked="true"] > .switch__track::after { transform: translateX(24px); }
.switch__text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.switch__text b { font-size: 15px; }
.switch__text span { color: var(--color-text-muted); font-size: 13px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slider { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; align-items: center; }
.slider input[type="range"] { width: 100%; height: 44px; accent-color: var(--color-blue); cursor: pointer; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 999px; background: var(--color-surface-sunken); }
.seg button { min-height: 42px; border: 0; border-radius: 999px; background: none; font-weight: 800; font-size: 14px; color: var(--color-text-muted); cursor: pointer; padding: 0 6px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-blue); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid transparent; background: var(--color-surface-sunken); font-weight: 800; font-size: 13.5px; color: var(--color-text-muted); cursor: pointer; }
.chips button:hover { color: var(--color-blue); background: var(--color-blue-soft); }
.chips button[aria-pressed="true"] { background: var(--color-blue); color: var(--color-blue-contrast); }
.check { display: flex; align-items: center; gap: 12px; min-height: 46px; cursor: pointer; font-weight: 600; font-size: 14.5px; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--color-border-strong); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.check input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.check input:checked { background: var(--color-blue); }
.check input:checked::after { transform: translateX(18px); }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.note { font-size: 13px; color: var(--color-text-muted); }
.lampstate { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; padding: 10px 14px; border-radius: 16px; background: var(--color-success-soft); color: var(--color-success); }
.lampstate.is-warn { background: var(--color-gold-soft); color: var(--color-gold-ink); }
.lampstate.is-bad { background: var(--color-danger-soft); color: var(--color-danger); }
.lampstate.is-off { background: var(--color-surface-sunken); color: var(--color-text-muted); }
.legend { display: grid; gap: 8px; font-size: 14px; font-weight: 600; }
.legend div { display: flex; align-items: center; gap: 10px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.step { position: relative; padding: 16px 16px 16px 58px; border-radius: 20px; background: var(--color-surface); border: 1.5px solid transparent; counter-increment: step; transition: border-color .2s; }
.step::before { content: counter(step); position: absolute; left: 16px; top: 16px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--color-surface-sunken); color: var(--color-text-muted); font-weight: 800; font-size: 14px; }
.step.is-on { border-color: var(--color-blue); }
.step.is-on::before { background: var(--color-blue); color: var(--color-blue-contrast); }
.step h3 { margin: 0 0 4px; font-size: 16px; font-weight: 800; }
.step p { margin: 0 0 12px; color: var(--color-text-muted); }
.qcard { padding: 18px; border-radius: 20px; background: var(--color-surface); }
.qcard p { font-size: 17px; font-weight: 600; }
.qcard .sol { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--color-border-strong); font-size: 17px; }
.qcard .sol div { margin: 4px 0; }
.qcard .sol b { color: var(--color-blue); }

@media (max-width: 1000px) {
  .simpage { height: auto; overflow: visible; }
  .stage { grid-template-columns: 1fr; }
  .view { height: 62vh; min-height: 380px; }
  .ew-back span { display: none; }
  .formula { left: 8px; top: 8px; padding: 8px 14px 6px; }
  .formula__cap { display: none; }
  .status { top: auto; bottom: 64px; right: 8px; flex-direction: row; flex-wrap: wrap; max-width: calc(100% - 16px); }
  .graph { display: none; }
  .views { left: 8px; right: 8px; bottom: 8px; max-width: none; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .views button { flex: none; min-height: 38px; font-size: 13px; padding: 0 12px; }
  .ew-nav__title { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- typeset equations (assets/tex.js) ---------- */
.tx { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", Cambria, "Times New Roman", Times, serif; font-style: normal; font-weight: 400;
  font-size: 1.14em; white-space: nowrap; letter-spacing: 0; line-height: 1; display: inline-block; vertical-align: middle; }
.tx i { font-style: italic; padding-right: .03em; }
.tx-rm { font-style: normal; }
.tx-bf { font-weight: 700; }
.tx-op { padding: 0 .26em; }
.tx-sl { padding: 0 .06em; }
.tx sup .tx-op, .tx sub .tx-op { padding: 0; }
.tx-sp { display: inline-block; width: .2em; }
.tx sup, .tx sub { font-size: .7em; line-height: 0; position: relative; vertical-align: baseline; }
.tx sup { top: -.5em; }
.tx sub { top: .25em; }
.tx-frac { display: inline-flex; flex-direction: column; align-items: stretch; vertical-align: middle; text-align: center; margin: 0 .1em; font-size: .88em; }
.tx--display .tx-frac { font-size: 1em; }
.tx-num { padding: 0 .18em .1em; border-bottom: max(1px, .065em) solid currentColor; }
.tx-den { padding: .12em .18em 0; }
.formula { align-items: center; }
.formula__eq { font-size: clamp(22px, 2.2vw, 32px); color: var(--color-text); }
.formula__eq .tx-val { color: var(--color-blue); }
.formula__caps { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.formula__caps .tx { font-size: 1.15em; }
.formula__box { display: flex; flex-direction: column; }
.result .lines .tx { font-size: 1.12em; }
.step p .tx, .note .tx, .qcard .tx { font-size: 1.12em; }
.sim__formula .tx { font-size: 1em; }

/* the count panel of the drift-velocity page */
.countgrid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; align-items: center; }
.countgrid span { color: var(--color-text-muted); font-weight: 600; }
.countgrid b { font-weight: 700; text-align: right; }
.countgrid .tx { font-size: 1.05em; }
.chips button small { font-weight: 600; opacity: .8; margin-left: 4px; }
.formula__sub { font-size: .7em; margin-top: 8px; color: var(--color-text-muted); }
.formula__eq > div { white-space: nowrap; }

/* the readings table of the conductor page */
.rtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.rtable th { text-align: left; font-weight: 700; color: var(--color-text-muted); padding: 4px 6px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.rtable th small { font-weight: 600; }
.rtable td { padding: 6px; border-bottom: 1px solid var(--color-border); white-space: nowrap; position: relative; }
.rtable .vbar { position: absolute; left: 0; top: 4px; bottom: 4px; width: var(--w); background: var(--color-blue-soft); border-radius: 6px; z-index: -1; }
.rtable td:last-child { z-index: 0; }
.rtable td:last-child { isolation: isolate; }

/* the equation card can be folded away (button added by core.js) */
.formula { padding-right: 46px; }
.formula__toggle { position: absolute; right: 8px; top: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 999px; background: var(--color-surface-sunken); color: var(--color-text-muted); font: inherit; font-weight: 800; font-size: 14px; cursor: pointer; }
.formula__toggle:hover { color: var(--color-blue); background: var(--color-blue-soft); }
.formula__toggle svg { width: 16px; height: 16px; flex: none; }
.formula.is-collapsed { padding: 0; border-radius: 999px; }
.formula.is-collapsed > :not(.formula__toggle) { display: none; }
.formula.is-collapsed .formula__toggle { position: static; width: auto; height: 40px; padding: 0 16px 0 12px; background: none; color: var(--color-text); }
.formula.is-collapsed .formula__toggle:hover { color: var(--color-blue); }

/* the controls panel can be folded away (button added to the top bar by core.js) */
.ew-panelbtn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px 0 13px; border: 0; border-radius: 999px; background: var(--color-surface-sunken); color: var(--color-text); font: inherit; font-weight: 800; font-size: 14px; cursor: pointer; transition: background-color .16s ease, color .16s ease; }
.ew-panelbtn:hover { background: var(--color-blue-soft); color: var(--color-blue); }
.ew-panelbtn[aria-pressed="false"] { background: var(--color-blue); color: var(--color-blue-contrast); }
.ew-panelbtn svg { width: 20px; height: 20px; flex: none; }
.stage.is-wide { grid-template-columns: 1fr; }
@media (max-width: 560px) { .ew-panelbtn span { display: none; } .ew-panelbtn { padding: 0; width: 44px; justify-content: center; } }

/* long text (Sinhala especially) never spills out of its box: formulas in the panel and the result card may wrap after a
   top-level =, ≈, × or + (tex.js marks those places), and the buttons of a segmented control may take two lines */
.step p .tx, .note .tx, .qcard .tx, .result .tx, .countgrid .tx, .lines .tx { display: inline; white-space: normal; line-height: inherit; }
.step p .tx-frac, .note .tx-frac, .qcard .tx-frac, .result .tx-frac { line-height: 1.15; }
.step, .qcard, .card, .result, .pane { min-width: 0; overflow-wrap: anywhere; }
.seg button { white-space: normal; line-height: 1.2; padding: 4px 8px; }
.chips button { max-width: 100%; white-space: normal; line-height: 1.2; }
.card__head { flex-wrap: wrap; row-gap: 4px; }
@media (max-width: 560px) {
  .ew-nav__title { white-space: normal; font-size: 13px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .formula__box { max-width: calc(100vw - 96px); overflow-x: auto; scrollbar-width: none; }
}
