/* Digital-twin widgets */
.twin { --stage-h: clamp(360px, 52vw, 620px); }
.twin-variants { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.twin-variants .chip[aria-checked='true'] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.twin-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 1040px) { .twin-main { grid-template-columns: 1fr; } }
.twin-stage { position: relative; height: var(--stage-h); border-radius: var(--radius-lg); overflow: hidden; background: #0d1210; border: 1px solid var(--rule); }
.twin-canvas { position: absolute; inset: 0; }
.twin-canvas .twin-gl { width: 100% !important; height: 100% !important; display: block; cursor: grab; touch-action: pan-y; }
.twin-canvas .twin-gl:active { cursor: grabbing; }
.twin-canvas picture img { width: 100%; height: 100%; object-fit: cover; }
.twin-2d { width: 100%; height: calc(100% - 60px); image-rendering: auto; object-fit: contain; }
.twin-fallback { padding: 16px 18px 0; margin: 0; }
.twin-stage .concept-tag { left: auto; right: 12px; top: 12px; bottom: auto; }
.twin-hint { position: absolute; right: 12px; bottom: 12px; font-size: 0.72rem; color: var(--ink-3); pointer-events: none; }
.twin-legend { position: absolute; left: 14px; bottom: 14px; width: min(340px, calc(100% - 28px)); padding: 12px 14px; border-radius: 8px; background: rgba(11, 14, 13, 0.78); backdrop-filter: blur(8px); border: 1px solid var(--rule); font-size: 0.78rem; }
.lg-title { color: var(--ink-2); margin-bottom: 8px; line-height: 1.35; }
.lg-bar { height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgb(16, 24, 30) 0%, rgb(21, 58, 66) 15%, rgb(24, 112, 96) 35%, rgb(62, 176, 120) 55%, rgb(170, 222, 140) 75%, rgb(232, 240, 186) 90%, rgb(252, 248, 232) 100%); }
.lg-scale { display: flex; justify-content: space-between; margin-top: 6px; color: var(--ink); }
.twin-hud { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 10px; }
.hud-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mini { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--rule-2); background: transparent; font-size: 0.78rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.mini:hover { color: var(--ink); border-color: var(--ink-3); }
.mini[aria-pressed='true'] { color: var(--ink); border-color: var(--emerald-deep); background: rgba(62, 207, 152, 0.1); }
.mini-select { height: 32px; border-radius: 999px; border: 1px solid var(--rule-2); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.78rem; padding: 0 10px; }
.twin-panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 18px; }
.twin-controls { display: grid; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; }
.tw-field label { display: flex; justify-content: space-between; gap: 12px; font-size: 0.82rem; color: var(--ink-2); margin-bottom: 6px; }
.tw-field output { color: var(--ink); font-weight: 600; white-space: nowrap; }
.tw-field select { width: 100%; height: 38px; border-radius: 8px; border: 1px solid var(--rule-2); background: var(--raised); color: var(--ink); font: inherit; font-size: 0.88rem; padding: 0 10px; }
.tw-field input[type='range'] { width: 100%; accent-color: var(--emerald); height: 24px; }
.tw-check { display: flex; align-items: center; gap: 10px; }
.tw-check label { margin: 0; color: var(--ink); }
.tw-check input { width: 18px; height: 18px; accent-color: var(--emerald); }
.twin-result-title { margin-bottom: 10px; }
.tw-stats { margin: 0; display: grid; gap: 0; }
.tw-stat { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--rule); }
.tw-stat dt { font-size: 0.8rem; color: var(--ink-2); line-height: 1.3; }
.tw-stat dd { margin: 0; font-weight: 620; font-size: 0.98rem; white-space: nowrap; }
.tw-stat.ok dd { color: var(--emerald-2); }
.tw-stat.warn dd { color: var(--warn); }
.tw-verdict { margin: 10px 0 6px; font-size: 0.84rem; padding: 8px 10px; border-radius: 6px; }
.tw-verdict.ok { background: rgba(62, 207, 152, 0.1); color: var(--emerald-2); }
.tw-verdict.warn { background: rgba(227, 178, 106, 0.1); color: var(--warn); }
.twin-charts { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; margin-top: 18px; }
@media (max-width: 900px) { .twin-charts { grid-template-columns: 1fr; } }
.twin-chart { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 16px 18px; margin: 0; }
.twin-chart figcaption { margin: 0 0 10px; color: var(--ink-2); font-size: 0.84rem; }
.chart { width: 100%; height: auto; }
.chart .c-grid { stroke: var(--rule); stroke-width: 1; }
.chart .c-axis { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .c-cur { fill: var(--ink); font-weight: 700; }
.chart .c-band { fill: rgba(62, 207, 152, 0.12); stroke: rgba(62, 207, 152, 0.45); stroke-dasharray: 4 3; }
.chart .c-nat { fill: #5d7f95; }
.chart .c-sup { fill: #ff5a8e; }
.chart .c-sel { fill: none; stroke: var(--ink-3); stroke-width: 1; }
.chart .c-par { fill: rgba(255, 255, 255, 0.03); }
.chart .c-fr { fill: rgba(125, 35, 51, 0.18); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--ink-2); margin-top: 8px; }
.chart-legend .k::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart-legend .nat::before { background: #5d7f95; }
.chart-legend .sup::before { background: #ff5a8e; }
.chart-legend .band::before { background: rgba(62, 207, 152, 0.3); border: 1px dashed rgba(62, 207, 152, 0.7); }
.twin-notes { margin-top: 18px; }
.twin-notes ul { padding-left: 1.1em; color: var(--ink-2); }
.twin-notes li { margin: 0.45em 0; }

/* Home sequence */
.seq { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.seq-stage { position: sticky; top: calc(var(--header-h) + 24px); height: min(70vh, 620px); border-radius: var(--radius-lg); overflow: hidden; background: #0d1210; border: 1px solid var(--rule); }
.seq-stage .twin-canvas { position: absolute; inset: 0; }
.seq-tag { left: auto !important; right: 12px; top: 12px; bottom: auto !important; }
.seq-legend { position: absolute; left: 14px; bottom: 14px; right: 14px; max-width: 420px; padding: 12px 14px; border-radius: 8px; background: rgba(11, 14, 13, 0.8); backdrop-filter: blur(8px); border: 1px solid var(--rule); font-size: 0.78rem; }
.seq-legend .chart { margin-top: 8px; max-height: 150px; }
.seq-legend .chart-legend { font-size: 0.72rem; gap: 10px; }
.seq-steps { list-style: none; margin: 0; padding: 0; }
.seq-step { padding: 0 0 0 0; min-height: 38vh; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--rule); padding-left: 24px; position: relative; transition: opacity 0.4s var(--ease); opacity: 0.45; }
.seq-step.is-active { opacity: 1; }
.seq-step.is-active::before { content: ''; position: absolute; left: -1px; top: 30%; bottom: 30%; width: 2px; background: var(--emerald); }
.seq-step button { display: flex; align-items: baseline; gap: 14px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: var(--ink); }
.seq-step .seq-n { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.12em; color: var(--emerald); }
.seq-step .h4 { font-size: 1.4rem; font-weight: 500; letter-spacing: -0.02em; }
.seq-step p { color: var(--ink-2); margin: 10px 0 0 34px; max-width: 40ch; }
@media (max-width: 900px) {
  .seq { grid-template-columns: 1fr; }
  .seq-stage { position: sticky; top: calc(var(--header-h) + 8px); height: 46vh; z-index: 2; }
  .seq-step { min-height: 46vh; }
}
@media (prefers-reduced-motion: reduce) { .seq-step { transition: none; } }
