:root {
  color-scheme: dark;
  --bg: #071017;
  --surface: #0b1720;
  --surface-2: #0e1d27;
  --line: #223540;
  --line-soft: rgba(130, 166, 181, .14);
  --text: #edf7f8;
  --muted: #8ca4ad;
  --cyan: #37e2c3;
  --cyan-soft: rgba(55, 226, 195, .13);
  --blue: #55a8ff;
  --orange: #ffb15c;
  --red: #ff6f78;
  --shadow: 0 24px 64px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 4%, rgba(36, 117, 126, .22), transparent 27rem),
    radial-gradient(circle at 88% 18%, rgba(41, 88, 145, .18), transparent 31rem),
    var(--bg);
  min-height: 100vh;
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
a { color: var(--cyan); }

.app-shell { width: min(1580px, 100%); margin: 0 auto; padding: 0 28px; }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { display: grid; place-items: center; width: 48px; aspect-ratio: 1; border: 1px solid #37717a; color: var(--cyan); font: 700 14px/1 ui-monospace, monospace; letter-spacing: .08em; background: linear-gradient(145deg, #102832, #09151c); clip-path: polygon(0 0, 88% 0, 100% 12%, 100% 100%, 12% 100%, 0 88%); }
.eyebrow { margin: 0 0 3px; color: #75919c; font: 700 11px/1.2 ui-monospace, SFMono-Regular, monospace; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 20px; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.save-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.save-state i, .connection i, .server-light i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.ghost-button, .primary-button, .lesson-arrow, .commit-button, .connection, .text-button, .tab { border: 0; cursor: pointer; }
.ghost-button { padding: 10px 14px; border: 1px solid var(--line); background: rgba(12, 28, 37, .7); border-radius: 8px; color: #b7c9ce; }
.ghost-button:hover { border-color: #43616b; }

.lesson-strip { display: grid; grid-template-columns: 44px 150px minmax(300px, 1fr) auto 44px; gap: 22px; align-items: center; min-height: 176px; padding: 26px 0; }
.lesson-arrow { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; }
.lesson-arrow:hover { color: var(--cyan); border-color: var(--cyan); }
.lesson-meta { display: flex; justify-content: space-between; margin-bottom: 10px; font: 600 11px/1 ui-monospace, monospace; color: var(--muted); }
.progress-track { height: 3px; background: #1b2c35; overflow: hidden; }
.progress-track span { display: block; width: 12.5%; height: 100%; background: var(--cyan); transition: width .35s ease; }
.lesson-copy p { margin-bottom: 0; max-width: 760px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.lesson-copy > p:first-child { margin-bottom: 7px; color: var(--cyan); font: 700 11px/1.2 ui-monospace, monospace; letter-spacing: .13em; text-transform: uppercase; }
.lesson-copy h2 { margin-bottom: 9px; font-size: clamp(20px, 2.1vw, 30px); line-height: 1.16; letter-spacing: -.035em; }
.primary-button { min-width: 126px; padding: 13px 18px; border-radius: 8px; background: var(--cyan); color: #042019; font-weight: 800; box-shadow: 0 9px 30px rgba(55, 226, 195, .16); }
.primary-button:hover { filter: brightness(1.07); transform: translateY(-1px); }

.workspace { display: grid; grid-template-columns: minmax(240px, 1fr) 70px minmax(230px, .82fr) 70px minmax(240px, 1fr); align-items: stretch; min-height: 395px; }
.node { position: relative; background: linear-gradient(155deg, rgba(15, 32, 42, .98), rgba(7, 18, 25, .98)); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.node::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, transparent 49.8%, rgba(255,255,255,.018) 50%, transparent 50.2%); background-size: 32px 100%; }
.client-node { padding: 23px; border-radius: 14px; }
.server-node { padding: 23px; border-radius: 4px; border-color: #31505b; background: linear-gradient(165deg, rgba(15, 37, 46, .98), rgba(4, 16, 22, .98)); }
.node-head { position: relative; display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.node-index { display: block; margin-bottom: 5px; color: #52707b; font: 700 10px/1 ui-monospace, monospace; }
.node h3 { margin-bottom: 0; font-size: 17px; }
.connection { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; background: var(--cyan-soft); color: var(--cyan); border-radius: 5px; font-size: 12px; }
.connection.offline { color: var(--red); background: rgba(255, 111, 120, .12); }
.connection.offline i { background: var(--red); box-shadow: 0 0 12px var(--red); }
.issue-card { position: relative; padding: 17px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(4, 12, 17, .47); }
.issue-top { display: flex; justify-content: space-between; margin-bottom: 17px; }
.issue-id { color: var(--blue); font: 700 11px/1 ui-monospace, monospace; }
.pill { padding: 4px 8px; border: 1px solid #334c58; border-radius: 99px; color: #a9bec6; font-size: 10px; }
.issue-card label { display: block; margin: 10px 0 6px; color: #79919a; font-size: 11px; }
.issue-card input, .issue-card select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid #263c46; border-radius: 5px; background: #08131a; color: var(--text); }
.issue-card input:focus, .issue-card select:focus { border-color: var(--cyan); }
.commit-button { width: 100%; margin-top: 13px; padding: 10px; border: 1px solid #315d62; border-radius: 5px; background: #102a2f; color: var(--cyan); font-weight: 700; font-size: 12px; }
.commit-button:hover { background: #15373c; }
.state-grid { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 14px; }
.state-grid div, .server-stats div { min-width: 0; padding: 10px; border: 1px solid var(--line-soft); background: rgba(10, 25, 33, .7); }
.state-grid span, .server-stats span { display: block; margin-bottom: 5px; color: #6f8a94; font-size: 9px; }
.state-grid strong, .server-stats strong { display: block; overflow: hidden; text-overflow: ellipsis; color: #cfe0e4; font: 700 11px/1.2 ui-monospace, monospace; }
.server-light { display: inline-flex; align-items: center; gap: 6px; color: var(--cyan); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .08em; }
.sync-orbit { position: relative; display: grid; place-items: center; width: 150px; height: 150px; margin: 5px auto 18px; }
.orbit-ring { position: absolute; inset: 9px; border: 1px dashed #2e6670; border-radius: 50%; animation: spin 16s linear infinite; }
.orbit-ring::before, .orbit-ring::after { content: ""; position: absolute; top: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 16px var(--cyan); }
.orbit-ring::before { left: -4px; }.orbit-ring::after { right: -4px; }
.sync-core { display: grid; place-items: center; width: 94px; height: 94px; border-radius: 50%; background: radial-gradient(circle, #17383f, #091b22 66%); box-shadow: inset 0 0 24px rgba(55, 226, 195, .13), 0 0 38px rgba(55, 226, 195, .08); }
.sync-core span { color: #75939d; font: 10px/1 ui-monospace, monospace; }
.sync-core strong { font: 700 22px/1 ui-monospace, monospace; color: var(--cyan); }
.server-record { padding: 14px; border-left: 2px solid var(--cyan); background: rgba(55, 226, 195, .055); }
.server-record span, .server-record small { display: block; color: #78939c; font-size: 10px; }
.server-record strong { display: block; margin: 5px 0; font-size: 12px; line-height: 1.35; }
.server-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 13px; }
.packet-lane { position: relative; overflow: hidden; }
.packet-lane::before, .packet-lane::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: #28404a; }
.packet-lane::before { top: 45%; }.packet-lane::after { top: 55%; }
.packet { position: absolute; z-index: 2; top: calc(50% - 13px); left: -6px; display: grid; place-items: center; width: 36px; height: 26px; border: 1px solid var(--cyan); border-radius: 4px; background: #0b2b2f; color: var(--cyan); opacity: 0; font: 800 10px/1 ui-monospace, monospace; }
.packet.travel-right { animation: travelRight .9s ease-in-out; }.packet.travel-left { animation: travelLeft .9s ease-in-out; }

.lower-grid { display: grid; grid-template-columns: 1.1fr .9fr 1fr; gap: 14px; margin-top: 14px; }
.panel { min-height: 250px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: rgba(9, 23, 31, .92); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.panel h3 { margin-bottom: 0; font-size: 16px; }
.tabs { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 6px; }
.tab { padding: 6px 9px; border-radius: 4px; background: transparent; color: var(--muted); font-size: 10px; }
.tab.active { background: #18313a; color: var(--cyan); }
pre { height: 170px; margin: 0; padding: 14px; overflow: auto; border-radius: 5px; background: #050d12; color: #9fc1c8; font: 11px/1.6 ui-monospace, SFMono-Regular, monospace; white-space: pre-wrap; }
.experiment-buttons { display: grid; gap: 8px; }
.experiment-buttons button { display: grid; grid-template-columns: 27px 1fr; gap: 2px 10px; padding: 10px; text-align: left; border: 1px solid var(--line-soft); border-radius: 5px; background: #0a1820; color: var(--text); cursor: pointer; }
.experiment-buttons button:hover { border-color: #3a5a65; background: #0f2029; }
.experiment-buttons span { grid-row: 1 / 3; color: var(--cyan); font: 700 11px/1.4 ui-monospace, monospace; }
.experiment-buttons strong { font-size: 12px; }.experiment-buttons small { color: var(--muted); font-size: 10px; }
.toggles { display: flex; gap: 14px; margin-top: 14px; color: var(--muted); font-size: 11px; }
.toggles label { display: flex; align-items: center; gap: 6px; }
.toggles input { accent-color: var(--cyan); }
.text-button { padding: 2px 0; background: transparent; color: var(--muted); font-size: 11px; }
#eventLog { height: 170px; margin: 0; padding: 0; overflow: auto; list-style: none; }
#eventLog li { display: grid; grid-template-columns: 42px 54px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); color: #b7cbd0; font-size: 10px; line-height: 1.35; }
#eventLog time { color: #58717a; font-family: ui-monospace, monospace; }
#eventLog b { color: var(--blue); font-family: ui-monospace, monospace; }
#eventLog li.warn b { color: var(--orange); } #eventLog li.error b { color: var(--red); } #eventLog li.ok b { color: var(--cyan); }
.concept-map { display: grid; grid-template-columns: repeat(9, auto); justify-content: center; align-items: center; gap: 13px; margin: 46px 0 28px; }
.concept-map div { max-width: 160px; text-align: center; }.concept-map span { color: var(--cyan); font: 700 11px/1 ui-monospace, monospace; letter-spacing: .08em; }.concept-map p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }.concept-map i { color: #3d5b65; font-style: normal; }
footer { display: flex; justify-content: space-between; gap: 24px; padding: 22px 0 32px; border-top: 1px solid var(--line); color: #6e8790; font-size: 11px; line-height: 1.6; }
footer p { max-width: 720px; margin: 0; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 22px; transform: translate(-50%, 20px); padding: 10px 16px; border: 1px solid #32525a; border-radius: 6px; background: #0c2028; color: #d9eaed; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s ease; font-size: 12px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.flash { animation: flash .7s ease; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes travelRight { 0% { left: -6px; opacity: 0; } 15%, 85% { opacity: 1; } 100% { left: calc(100% - 30px); opacity: 0; } }
@keyframes travelLeft { 0% { left: calc(100% - 30px); opacity: 0; } 15%, 85% { opacity: 1; } 100% { left: -6px; opacity: 0; } }
@keyframes flash { 35% { border-color: var(--cyan); box-shadow: 0 0 30px rgba(55,226,195,.2); } }

@media (max-width: 1080px) {
  .lesson-strip { grid-template-columns: 36px 110px 1fr 36px; }
  .lesson-strip .primary-button { grid-column: 3; justify-self: start; }
  .workspace { grid-template-columns: 1fr 42px .8fr 42px 1fr; }
  .client-node, .server-node { padding: 16px; }
  .lower-grid { grid-template-columns: 1fr 1fr; }.log-panel { grid-column: 1 / -1; min-height: 210px; }
}

@media (max-width: 760px) {
  .app-shell { padding: 0 14px; }
  .topbar { min-height: 74px; }.save-state { display: none; }.brand-mark { width: 40px; }
  .lesson-strip { grid-template-columns: 38px 1fr 38px; gap: 12px; padding: 22px 0; }
  .lesson-progress { grid-column: 2; grid-row: 1; }.lesson-copy { grid-column: 1 / -1; grid-row: 2; }.lesson-strip .primary-button { grid-column: 1 / -1; grid-row: 3; width: 100%; }.lesson-arrow:first-child { grid-column: 1; grid-row: 1; }.lesson-arrow:last-child { grid-column: 3; grid-row: 1; }
  .workspace { grid-template-columns: 1fr; gap: 10px; }.packet-lane { display: none; }.node { min-height: 0; }.sync-orbit { width: 110px; height: 110px; }.sync-core { width: 76px; height: 76px; }
  .lower-grid { grid-template-columns: 1fr; }.log-panel { grid-column: auto; }.panel { min-height: 0; }
  .concept-map { grid-template-columns: 1fr; gap: 8px; }.concept-map i { transform: rotate(90deg); }.concept-map div { max-width: none; }
  footer { display: block; } footer p + p { margin-top: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
