:root {
    --ink: #e9f3f5;
    --muted: #96aeb5;
    --surface: #102126;
    --surface-soft: #183138;
    --line: rgba(183, 231, 228, .16);
    --teal: #62ead7;
    --yellow: #f5d86c;
    --red: #f17874;
}

* { box-sizing: border-box; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at 12% 10%, #234950 0, transparent 31rem), #091518;
}
button, select { font: inherit; }
.page-shell { width: min(1080px, calc(100% - 2.5rem)); margin: 0 auto; padding: 5.5rem 0 4rem; }
.hero { max-width: 650px; margin-bottom: 3.5rem; }
.eyebrow { margin: 0 0 .7rem; color: var(--teal); font-size: .74rem; font-weight: 800; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .85rem; font-size: clamp(3.3rem, 9vw, 6.8rem); line-height: .88; letter-spacing: -.075em; }
h1 span { color: var(--teal); }
.hero > p:last-child { max-width: 38rem; color: var(--muted); font-size: 1.08rem; line-height: 1.65; }
.logic-board { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 1.5rem; align-items: center; padding: 1.5rem; border: 1px solid var(--line); border-radius: 1.5rem; background: rgba(16, 33, 38, .82); box-shadow: 0 25px 80px rgba(0, 0, 0, .22); }
.signal-column { display: grid; gap: .75rem; }
.signal-column h2 { margin: 0 0 .2rem; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; }
.signal-card, .output-card { display: grid; min-height: 115px; padding: 1rem 1.1rem; text-align: left; color: var(--ink); border: 1px solid var(--line); border-radius: 1rem; background: var(--surface-soft); }
.signal-card { cursor: pointer; transition: transform .18s, border-color .18s, background .18s; }
.signal-card:hover { transform: translateY(-2px); border-color: rgba(98, 234, 215, .52); }
.signal-card.is-active, .output-high { border-color: var(--teal); background: linear-gradient(135deg, #15514f, #17363a); }
.signal-name { color: var(--muted); font-size: .82rem; font-weight: 700; }
.signal-value { margin: auto 0 .1rem; font-size: 3.1rem; line-height: .9; }
.signal-state { color: var(--muted); font-size: .7rem; font-weight: 900; letter-spacing: .14em; }
.is-active .signal-state, .output-high .signal-state { color: var(--teal); }
.gate-column { text-align: center; }
.gate-column label { display: block; margin-bottom: .55rem; color: var(--muted); font-size: .82rem; font-weight: 700; }
select { width: 100%; padding: .82rem 2.3rem .82rem .9rem; color: var(--ink); border: 1px solid var(--line); border-radius: .7rem; outline: none; background: #0b1a1e; cursor: pointer; }
select:focus { border-color: var(--teal); }
.gate-display { display: grid; place-items: center; width: 145px; height: 145px; margin: 1.2rem auto .85rem; border: 3px solid var(--yellow); border-radius: 50%; color: var(--yellow); box-shadow: inset 0 0 0 11px rgba(245, 216, 108, .06), 0 0 30px rgba(245, 216, 108, .08); }
.gate-symbol { font-size: 3.2rem; line-height: .75; }
.gate-name { margin-top: -.85rem; font-size: .78rem; font-weight: 900; letter-spacing: .14em; }
.gate-description { min-height: 2.8em; margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.output-column { text-align: right; }
.output-column h2 { text-align: right; }
.output-card { text-align: right; transition: background .18s, border-color .18s; }
.output-low { border-color: rgba(241, 120, 116, .35); }
.output-low .signal-state { color: var(--red); }
.circuit-section { margin-top: 4.5rem; }
.section-heading { max-width: 42rem; margin-bottom: 1.6rem; }
.section-heading h2 { margin-bottom: .55rem; font-size: clamp(1.8rem, 4vw, 2.7rem); letter-spacing: -.055em; }
.section-heading > p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.circuit-board { display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem minmax(0, 1fr); grid-template-rows: 1fr 1fr; gap: 1rem; align-items: stretch; padding: 1.25rem; border: 1px solid var(--line); border-radius: 1.5rem; background: rgba(16, 33, 38, .82); }
.circuit-stage { display: grid; gap: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: rgba(8, 24, 28, .55); }
.stage-one { grid-column: 1; grid-row: 1; }
.stage-two { grid-column: 1; grid-row: 2; }
.stage-title { display: flex; align-items: center; gap: .55rem; }
.stage-title > span { display: grid; place-items: center; width: 1.55rem; height: 1.55rem; border-radius: 50%; color: #092023; background: var(--yellow); font-size: .75rem; font-weight: 900; }
.stage-title h3 { margin: 0; font-size: 1rem; }
.mini-inputs, .linked-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.mini-signal, .linked-inputs > div { display: flex; align-items: center; justify-content: space-between; min-height: 3.2rem; padding: .55rem .7rem; color: var(--ink); border: 1px solid var(--line); border-radius: .6rem; background: var(--surface-soft); }
.mini-signal { cursor: pointer; transition: transform .18s, border-color .18s, background .18s; }
.mini-signal:hover { transform: translateY(-2px); border-color: rgba(98, 234, 215, .52); }
.mini-signal.is-active { border-color: var(--teal); background: #15514f; }
.mini-signal span, .linked-inputs span, .stage-result span { color: var(--muted); font-size: .72rem; font-weight: 800; }
.mini-signal strong, .linked-inputs strong { font-size: 1.3rem; }
.circuit-stage label { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .04em; }
.circuit-select { padding: .66rem 2.1rem .66rem .7rem; font-size: .87rem; }
.stage-result { display: flex; align-items: center; justify-content: space-between; min-height: 3.2rem; padding: .6rem .75rem; border: 1px solid rgba(245, 216, 108, .3); border-radius: .65rem; background: rgba(245, 216, 108, .06); }
.stage-result strong { color: var(--yellow); font-size: 1.65rem; line-height: 1; }
.circuit-connection { display: grid; grid-column: 2; grid-row: 1 / span 2; align-content: center; justify-items: center; gap: .15rem; color: var(--muted); text-align: center; font-size: .66rem; font-weight: 800; line-height: 1.2; }
.circuit-connection i { color: var(--teal); font-size: 2.1rem; font-style: normal; line-height: 1; }
.final-stage { grid-column: 3; grid-row: 1 / span 2; align-self: center; border-color: rgba(98, 234, 215, .3); }
.final-result { border-color: rgba(241, 120, 116, .35); background: var(--surface-soft); transition: background .18s, border-color .18s; }
.final-result.output-high { border-color: var(--teal); background: linear-gradient(135deg, #15514f, #17363a); }
.final-result.output-high strong { color: var(--teal); }
.final-result.output-low strong { color: var(--red); }
.truth-section { display: grid; grid-template-columns: .42fr 1fr; gap: 2rem; align-items: start; margin-top: 4.5rem; padding: 0 1rem; }
.truth-section h2 { font-size: 1.7rem; letter-spacing: -.04em; }
.truth-heading > p:last-child { color: var(--muted); line-height: 1.55; }
.truth-tables { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
.truth-card { overflow: hidden; border: 1px solid var(--line); border-radius: .85rem; background: rgba(16, 33, 38, .74); }
.truth-card-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem .85rem; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .025); }
.truth-card-header h3 { margin: 0; font-size: .9rem; letter-spacing: .04em; }
.truth-card-header span { color: var(--yellow); font-size: 1.35rem; line-height: 1; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .5rem; text-align: center; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; background: rgba(255, 255, 255, .018); }
tbody tr:last-child td { border-bottom: 0; }
.result-one { color: var(--teal); font-weight: 900; background: rgba(98, 234, 215, .06); }
.result-zero { color: var(--red); font-weight: 800; }
@media (max-width: 960px) { .truth-section { grid-template-columns: 1fr; padding: 0; } .truth-tables { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) { .truth-tables { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .page-shell { width: min(100% - 1.5rem, 540px); padding-top: 3rem; } .logic-board, .truth-section, .circuit-board { grid-template-columns: 1fr; } .gate-column { grid-row: 1; } .signal-column { grid-template-columns: 1fr 1fr; } .signal-column h2 { grid-column: 1 / -1; } .output-column, .output-column h2, .output-card { text-align: left; } .stage-one, .stage-two, .final-stage, .circuit-connection { grid-column: auto; grid-row: auto; } .circuit-connection { grid-template-columns: auto auto; grid-template-rows: auto auto; } .circuit-connection i { transform: rotate(90deg); } .truth-section { gap: .6rem; } .truth-tables { grid-template-columns: 1fr; } }
