:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: #202631;
  background: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; }
a { color: #28558a; text-decoration: none; }
a:hover { text-decoration: underline; }

.page { width: min(100% - 40px, 1180px); margin: 0 auto; padding-bottom: 35px; }
.page-header { width: 100%; margin: 54px auto 36px; text-align: center; }
h1 { margin: 0; font-size: clamp(1.55rem, 2.45vw, 2rem); font-weight: 680; line-height: 1.27; letter-spacing: -.025em; }
.resource-links { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 19px; }
.resource-links img { display: block; height: 20px; }
.page-header p { width: 100%; margin: 17px auto 0; color: #4c5562; font-size: 1.1rem; line-height: 1.6; text-align: left; }

.demo { border: 1px solid #d9dfe7; border-radius: 8px; background: #fff; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.tabs { display: flex; gap: 4px; padding: 0 25px; border-bottom: 1px solid #e7ebef; }
.tab { min-height: 52px; margin-bottom: -1px; padding: 0 16px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: #4e5865; font-size: 1.02rem; font-weight: 620; line-height: 1.25; letter-spacing: -.01em; }
.tab-icon { margin-right: 7px; }
.tab:hover:not(:disabled) { background: transparent; border-color: transparent; border-bottom-color: #b9c4d2; color: #202631; }
.tab[aria-selected="true"], .tab[aria-selected="true"]:hover:not(:disabled) { border-bottom-color: #28558a; color: #28558a; }
.tab:focus-visible { outline-offset: -2px; border-radius: 4px 4px 0 0; }
.tabpanel[hidden] { display: none; }

.controls { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, .9fr) minmax(0, .9fr) minmax(0, 1.05fr) minmax(0, 1.05fr) auto; align-items: end; gap: 12px; padding: 20px 25px; border-bottom: 1px solid #e7ebef; }
.controls .field { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.controls .field label { color: #4e5865; font-size: .8rem; font-weight: 600; }
select { width: 100%; height: 36px; padding: 0 30px 0 10px; border: 1px solid #cbd3dd; border-radius: 5px; background: #fff; color: #202631; font-size: .88rem; }
select[hidden] { display: none; }
.dropdown { position: relative; width: 100%; }
.dropdown-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left; background: #fff; font-weight: 500; }
.dropdown-trigger::after { content: ""; flex: none; width: 7px; height: 7px; margin: -4px 2px 0 10px; border-right: 1.5px solid #4e5865; border-bottom: 1.5px solid #4e5865; transform: rotate(45deg); }
.dropdown-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: 100%; max-height: min(260px, 50vh); overflow-y: auto; padding: 4px; border: 1px solid #cbd3dd; border-radius: 5px; background: #fff; box-shadow: 0 6px 18px rgba(30, 40, 55, .12); }
.dropdown-menu[hidden] { display: none; }
.dropdown-option { display: block; width: 100%; min-height: 32px; padding: 6px 8px; border: 0; border-radius: 3px; text-align: left; background: #fff; font-size: .88rem; font-weight: 450; }
.dropdown-option[aria-selected="true"] { color: #28558a; background: #edf3fa; font-weight: 620; }
.dropdown-option:hover:not(:disabled) { border-color: transparent; background: #f4f7fb; }
button { min-height: 36px; padding: 7px 12px; border: 1px solid #cbd3dd; border-radius: 5px; background: #fff; color: #273341; font-size: .88rem; font-weight: 570; cursor: pointer; }
button:hover:not(:disabled) { background: #f5f7fa; border-color: #9facbb; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid #28558a; outline-offset: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: #28558a; border-color: #28558a; color: #fff; white-space: nowrap; }
button.primary:hover:not(:disabled) { background: #214771; border-color: #214771; }

.summary { margin: 14px 25px 0; color: #4e5865; font-size: .82rem; line-height: 1.4; }
.summary:empty { display: none; }
.message { min-height: 0; margin: 15px 25px 0; color: #697381; font-size: .8rem; line-height: 1.4; }
.message:empty { display: none; }
.message.error { color: #ae3040; }
.prediction-summary { padding: 18px 25px 17px; border-bottom: 1px solid #e7ebef; }
.question-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.goto { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.goto label { color: #4e5865; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.goto input { width: 92px; height: 36px; padding: 0 10px; border: 1px solid #cbd3dd; border-radius: 5px; background: #fff; color: #202631; font: inherit; font-size: .88rem; }
.result-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; border: 1px solid #d9dfe7; border-radius: 4px; font-size: .72rem; font-weight: 650; white-space: nowrap; }
.result-badge[hidden] { display: none; }
.result-badge.solved { color: #22704a; border-color: #cbe5d8; background: #f0faf4; }
.result-badge.unsolved { color: #a23e48; border-color: #edd5d8; background: #fff5f5; }
.question-meta { color: #202631; font-size: 1.2rem; font-weight: 680; line-height: 1.3; letter-spacing: -.015em; }
.prediction-sequence { margin-top: 14px; }
.prediction-sequence h3 { margin: 0 0 8px; color: #4e5865; font-size: .82rem; font-weight: 650; }
.action-note { margin: -2px 0 9px; color: #627080; font-size: .8rem; line-height: 1.45; }
.action-note:empty { display: none; }
.demo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 25px 0; }
.demo-head h3 { margin: 0 0 3px; font-size: 1.03rem; font-weight: 650; line-height: 1.35; }
.demo-head p { margin: 0; color: #627080; font-size: .9rem; line-height: 1.45; }
.playback-panel { display: flex; flex: none; flex-direction: column; align-items: flex-end; gap: 7px; }
.player { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.playback-meta { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
#progress { color: #66717f; font-size: .82rem; white-space: nowrap; }
.boards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2.8vw, 34px); padding: 21px 25px 25px; }
figure { min-width: 0; max-width: 324px; margin: 0 auto; width: 100%; }
figcaption { margin-bottom: 9px; color: #505b69; text-align: center; font-size: .82rem; font-weight: 600; }
canvas { display: block; width: 100%; height: auto; border: 1px solid #adb8c7; background: #f8fafc; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.actions li { padding: 5px 7px; border: 1px solid #dbe1e8; border-radius: 4px; color: #566474; background: #f8fafb; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .74rem; }
.actions li.done { color: #28558a; border-color: #c8d7e8; background: #f2f7fc; }
.actions li.active { color: #fff; border-color: #28558a; background: #28558a; }

.atomic-intro { padding: 20px 25px 4px; }
.atomic-intro p { margin: 0; color: #4c5562; font-size: .92rem; line-height: 1.6; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 12px 0 0; padding: 0; list-style: none; color: #627080; font-size: .8rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.swatch { flex: none; width: 16px; height: 16px; border: 1px solid #aeb9c9; border-radius: 3px; }
.swatch-move { background: #fff0b9; }
.swatch-change { background: #fff0f3; }
.atomic-groups { padding: 8px 25px 25px; }
.atomic-group { margin-top: 20px; }
.atomic-group h3 { margin: 0; font-size: 1.03rem; font-weight: 650; line-height: 1.35; }
.atomic-hint { margin: 2px 0 12px; color: #627080; font-size: .86rem; line-height: 1.45; }
.atomic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.atomic-card { display: flex; min-width: 0; flex-direction: column; padding: 14px 16px 16px; border: 1px solid #e0e5ec; border-radius: 6px; background: #fff; }
.atomic-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.atomic-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 9px; min-width: 0; }
.atomic-name { margin: 0; font-size: 1rem; font-weight: 650; }
.atomic-name code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; color: #28558a; }
.atomic-kind { padding: 2px 7px; border: 1px solid #d9dfe7; border-radius: 4px; color: #566474; background: #f8fafb; font-size: .72rem; font-weight: 650; }
.atomic-play { flex: none; min-height: 30px; padding: 3px 10px; font-size: .82rem; }
.atomic-play[aria-disabled="true"], .atomic-play[aria-disabled="true"]:hover { opacity: .45; border-color: #cbd3dd; background: #fff; cursor: not-allowed; }
.atomic-text { flex: 1; margin: 8px 0 0; color: #4c5562; font-size: .88rem; line-height: 1.5; }
.atomic-example { margin: 8px 0 0; color: #627080; font-size: .8rem; }
.atomic-example code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #28558a; }
.atomic-boards { display: flex; align-items: center; justify-content: center; gap: clamp(8px, 2vw, 16px); margin-top: 14px; }
.atomic-boards figure { flex: 1 1 0; max-width: 200px; margin: 0; }
.atomic-boards figcaption { margin-bottom: 7px; font-size: .78rem; overflow-wrap: anywhere; }
.atomic-arrow { flex: none; margin-top: 22px; color: #8896a6; font-size: 1.4rem; line-height: 1; }

footer { display: flex; flex-direction: column; gap: 7px; padding: 19px 2px 0; color: #77808c; font-size: .74rem; overflow-wrap: anywhere; }
footer[hidden] { display: none; }

@media (max-width: 1040px) {
  .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .atomic-grid { grid-template-columns: 1fr; gap: 12px; }
  .demo-head { flex-direction: column; }
  .playback-panel { width: 100%; }
  .boards { gap: 14px; }
}
@media (max-width: 700px) {
  .page { width: min(100% - 24px, 480px); }
  .page-header { margin: 30px auto 27px; }
  .page-header p { font-size: 1rem; }
  .tabs { padding: 0 16px; }
  .tab { flex: 1; padding: 0 8px; font-size: .95rem; }
  .tab-icon { margin-right: 5px; }
  .atomic-intro { padding: 17px 16px 2px; }
  .atomic-groups { padding: 4px 16px 20px; }
  .controls { gap: 11px; padding: 17px 16px; }
  .controls .field:first-child { grid-column: 1 / -1; }
  .controls .primary { grid-column: 1 / -1; }
  .summary, .message { margin: 14px 16px 0; }
  .prediction-summary { padding: 17px 16px 16px; }
  .demo-head { gap: 12px; padding: 17px 16px 0; }
  .question-meta { font-size: 1.08rem; }
  .goto { width: 100%; margin: 4px 0 0; }
  .goto input { flex: 1; min-width: 0; }
  .boards { grid-template-columns: 1fr; gap: 19px; padding: 19px 16px 22px; }
  figure { max-width: 330px; }
}
@media (max-width: 560px) {
  .atomic-boards { flex-direction: column; }
  .atomic-boards figure { flex: none; width: 100%; max-width: 220px; }
  .atomic-arrow { margin-top: 0; transform: rotate(90deg); }
}
