:root{--ink:#14233f;--muted:#5b6678;--accent:#4f35c0;--accent-dark:#3d2899;--bg:#f6f7fb;--card:#fff;--line:#dfe3ec;--code:#14233f;--danger:#b00020;--soft:#eeeafb}
*{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;font-family:"DM Sans",system-ui,-apple-system,"Segoe UI",sans-serif;background:var(--bg);color:var(--ink);line-height:1.55}
a{color:var(--accent)}

.topbar{background:#fff;border-bottom:1px solid var(--line)}
.topbar-inner{max-width:1040px;margin:0 auto;padding:12px 20px;display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}
.brand{display:flex;align-items:center;gap:10px;font-weight:700;color:var(--ink);text-decoration:none}
.brand-mark{background:var(--accent);color:#fff;border-radius:8px;padding:4px 9px;font-family:ui-monospace,Consolas,monospace}
.topnav{display:flex;gap:6px;flex-wrap:wrap}
.topnav a{padding:6px 12px;border-radius:8px;color:var(--accent);text-decoration:none;font-weight:600}
.topnav a:hover,.topnav a[aria-current="page"]{background:var(--soft)}

.intro,main{max-width:1040px;margin:0 auto;padding-left:20px;padding-right:20px}
.intro{padding-top:28px}
.intro h1{margin:0 0 6px;font-size:2rem;letter-spacing:-0.01em}
.intro p{margin:0;color:var(--muted);max-width:70ch}

.card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:20px;margin:18px 0}
.card h2{margin:0 0 14px;font-size:1.2rem;display:flex;align-items:center;gap:10px}
.card h3{margin:18px 0 8px;font-size:1rem}
.step{display:inline-grid;place-items:center;width:28px;height:28px;border-radius:50%;background:var(--accent);color:#fff;font-size:.9rem}
.hint{color:var(--muted);font-size:.9rem;margin:6px 0}

button{font:inherit;cursor:pointer;border-radius:8px;border:1px solid var(--line);background:#fff;color:var(--ink);padding:8px 14px;margin:4px 8px 4px 0}
button:hover{border-color:var(--accent)}
button.primary{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:700}
button.primary:hover{background:var(--accent-dark)}
button:disabled{opacity:.55;cursor:not-allowed}
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible{outline:3px solid #b9aef0;outline-offset:2px}

input:not([type]),select{font:inherit;padding:7px 10px;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--ink);min-width:0;max-width:100%}
input[type=file]{font:inherit;max-width:100%}
label{font-weight:600}

.samples{margin:10px 0}
.samples summary{cursor:pointer;font-weight:600;color:var(--accent)}
.samples div{margin-top:8px}

#moduleSelect{width:100%;max-width:520px}
#moduleDesc{color:var(--muted);max-width:80ch}
#moduleOptions{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px 18px;margin-top:12px}
#moduleOptions label{display:grid;gap:4px;font-size:.9rem}
#moduleOptions br{display:none}

#code{width:100%;min-height:340px;resize:vertical;background:var(--code);color:#e8ecf7;border:0;border-radius:10px;padding:14px;font:13px/1.55 ui-monospace,Consolas,"Cascadia Mono",monospace}
#status{color:var(--muted)}

#output{background:#f1f3f9;border-radius:10px;padding:12px;white-space:pre-wrap;overflow:auto;margin:0 0 8px}
.error{color:var(--danger)}
#tables{overflow:auto}
#tables h3{margin:18px 0 6px}
#tables table{border-collapse:collapse;font-size:.9rem;margin:6px 0 18px}
#tables th{background:#eef0f7;text-align:left;white-space:nowrap}
#tables th,#tables td{padding:6px 10px;border-bottom:1px solid var(--line)}
#tables tr:nth-child(even) td{background:#fafbfd}
#figures img{max-width:100%;height:auto;border:1px solid var(--line);border-radius:10px;background:#fff;margin:8px 0}

.foot{max-width:1040px;margin:30px auto;padding:0 20px;color:var(--muted);font-size:.9rem}

@media (max-width:640px){
  .card{padding:14px}
  .intro h1{font-size:1.5rem}
  button{padding:10px 14px}
}

.howto { margin: .6rem 0 .9rem; border: 1px solid #dfe3ee; border-radius: 10px; padding: .1rem .9rem; background: #f8f9fd; }
.howto summary { cursor: pointer; font-weight: 600; color: #4f35c0; padding: .55rem 0; }
.howto-body { padding-bottom: .7rem; font-size: .93rem; line-height: 1.55; }
.howto-body h3 { font-size: .98rem; margin: 1rem 0 .3rem; }
.howto-body ul { margin: .3rem 0 .3rem 1.1rem; padding: 0; }
.howto-body table { border-collapse: collapse; width: 100%; }
.howto-body th, .howto-body td { text-align: left; border-bottom: 1px solid #e6e9f2; padding: .45rem .5rem; vertical-align: top; }
.howto-body pre { background: #14233f; color: #fff; padding: .7rem .9rem; border-radius: 8px; overflow-x: auto; }
.howto-body code { background: #eceefa; padding: 0 .25rem; border-radius: 4px; }
.howto-body pre code { background: none; padding: 0; }

.data-message { margin: .4rem 0 .8rem; padding: .55rem .8rem; border-radius: 8px; font-size: .9rem; line-height: 1.45; border: 1px solid transparent; }
.data-message.error { background: #fdecec; border-color: #f2b8b5; color: #8a1c14; }
.data-message.warn { background: #fff6e0; border-color: #f0d28a; color: #6b4a00; }
.data-message.info { background: #eef6fb; border-color: #cfe3f1; color: #1d4a66; }

#figures img { max-width: min(100%, 720px); height: auto; }
.fig-wrap { margin: 0 0 1.2rem; }
.fig-wrap img { display: block; margin-bottom: .6rem; }