:root {
  --ink: #1d2733;
  --muted: #5d6b7a;
  --line: #d3dde5;
  --blue: #235a81;
  --blue-dark: #173d59;
  --accent: #d44917;
  --ok-bg: #dff0d8;
  --ok-fg: #245c24;
  --err-bg: #f8e3e3;
  --err-fg: #8d2f2f;
  --warn-bg: #fdf3d8;
  --radius: 10px;
  font-family: "Segoe UI", "Noto Sans", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: #eef3f7; }
body { min-height: 100vh; }
a { color: var(--blue); }
code, pre, textarea.sql { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
code { background: #e8eef3; padding: 0 4px; border-radius: 3px; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 0; background: var(--blue); color: #fff; padding: 8px 12px; }
.skip:focus { left: 0; z-index: 20; }
:focus-visible { outline: 3px solid #7ab3d9; outline-offset: 2px; }

#boot, #blocked { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.boot-card { max-width: 620px; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: 0 10px 34px rgba(20,40,60,.10); }
.boot-card h1 { margin: 6px 0 10px; color: var(--blue-dark); font-size: 1.5rem; }
.spinner { width: 24px; height: 24px; border: 3px solid #d3dce3; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

#app { max-width: 1240px; margin: 0 auto; padding: 22px 18px 34px; }
.top { display: flex; gap: 24px; align-items: start; justify-content: space-between; }
.top h1 { margin: 0 0 8px; font-size: 1.9rem; color: var(--blue-dark); }
.top p { margin: 0; max-width: 720px; line-height: 1.55; color: #33424f; }
.progress-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 230px; }
.progress-track { height: 9px; background: #e6edf2; border-radius: 99px; margin: 9px 0; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), #3f8e5a); transition: width .3s ease; }

.student-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(15,23,42,.55); display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px; overflow: auto; }
.student-overlay[hidden] { display: none; }
.student-panel { position: relative; background: #fffdf5; border: 1px solid #e5d9ae; border-radius: var(--radius); padding: 14px 16px; width: min(760px, 100%); box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.student-close { position: absolute; top: 8px; right: 10px; padding: 4px 10px; line-height: 1.2; }
.student-panel h2 { margin: 0 0 5px; font-size: 1.08rem; color: var(--blue-dark); }
.student-panel p { margin: 0; line-height: 1.5; }
.student-panel label { display: flex; flex-direction: column; gap: 5px; font-weight: 650; font-size: .92rem; }
.student-panel .grow { flex: 1; min-width: 220px; }
#student-load { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 10px; }
#student-active { margin-top: 10px; }
#student-identity { font-weight: 650; margin-bottom: 10px; }
#student-active label { margin-bottom: 9px; }
.student-panel input[type="text"] { border: 1px solid #b8ab7d; border-radius: 6px; padding: 8px 10px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .92rem; background: #fff; width: 100%; }
.student-actions { display: flex; flex-wrap: wrap; gap: 9px; }
#student-msg { margin-top: 10px; }
#student-msg.ok { color: var(--ok-fg); }
#student-msg.ko { color: var(--err-fg); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 20px; }
.filters label { display: flex; flex-direction: column; gap: 5px; font-weight: 650; font-size: .92rem; }
.filters .grow { flex: 1; min-width: 190px; }
select, input[type="search"] { border: 1px solid #aebfca; border-radius: 6px; padding: 8px 10px; font: inherit; background: #fff; }
button { border: 1px solid #aebfca; background: #f5f8fa; border-radius: 7px; padding: 8px 13px; font: inherit; cursor: pointer; }
button:hover { background: #fff; }
button.primary { background: var(--blue); border-color: var(--blue-dark); color: #fff; font-weight: 700; }
button.primary:hover { background: #2f6c97; }
button.mini { padding: 4px 9px; font-size: .86rem; }
button:disabled { opacity: .55; cursor: wait; }
.pool-line { color: var(--muted); margin: 10px 2px 0; }

.layout { display: grid; grid-template-columns: 315px 1fr; gap: 18px; margin-top: 14px; align-items: start; }
.list-box, .exercise { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.list-box { padding: 14px; max-height: calc(100vh - 40px); overflow: auto; position: sticky; top: 16px; }
.list-box h2 { margin: 0 0 10px; font-size: 1rem; }
.ex-item { display: block; width: 100%; text-align: left; margin: 7px 0; padding: 9px 10px; border-radius: 8px; background: #f5f8fa; }
.ex-item:hover { background: #eaf2f8; }
.ex-item.current { border-color: var(--blue); background: #dcecf7; box-shadow: inset 3px 0 0 var(--blue); }
.ex-item .t { display: block; font-weight: 650; line-height: 1.35; }
.ex-item .m { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.chip { font-size: .76rem; font-weight: 700; border-radius: 99px; padding: 2px 8px; background: #e7edf2; color: #3d5064; }
.chip.sub { background: #dcecf7; color: var(--blue-dark); }
.chip.Base { background: #def0dc; color: #245c24; }
.chip.Media { background: #fdf0c9; color: #755b12; }
.chip.Alta { background: #f8dede; color: #8d2f2f; }
.done-mark { margin-left: auto; color: #2e7d32; font-weight: 800; }

.exercise { padding: 22px 24px 26px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.exercise h2 { font-size: 1.45rem; margin: 12px 0 8px; color: var(--blue-dark); }
.prompt { line-height: 1.65; font-size: 1.02rem; }
.prompt pre { background: #f5f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow: auto; line-height: 1.45; }
.prompt ul { padding-left: 22px; }
.prompt li { margin: 6px 0; }
.note { background: var(--warn-bg); border: 1px solid #ecd88f; border-radius: 8px; padding: 10px 12px; line-height: 1.5; }
.setup { margin: 16px 0; }
.setup summary { cursor: pointer; color: var(--blue); font-weight: 650; }
.setup pre, .box pre { background: #14202b; color: #eaf3fa; padding: 14px; border-radius: 8px; overflow: auto; line-height: 1.5; white-space: pre-wrap; }
.editor-label { display: block; font-weight: 700; margin: 16px 0 7px; }
textarea.sql { width: 100%; border: 1px solid #9fb3c1; border-radius: 8px; padding: 12px; line-height: 1.55; resize: vertical; background: #fbfdff; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 12px; }
.actions .spacer { flex: 1; }
.box { border-radius: 8px; padding: 12px 14px; margin-top: 14px; line-height: 1.55; }
.box.hint { background: #eef5fb; border: 1px solid #bdd7ea; }
.box.solution { background: #f4f8f2; border: 1px solid #c8dcc3; }
#result { margin-top: 16px; }
.result-summary { border-radius: 8px; padding: 13px 15px; font-weight: 700; }
.result-summary.ok { background: var(--ok-bg); color: var(--ok-fg); }
.result-summary.ko { background: var(--err-bg); color: var(--err-fg); }
.checks { list-style: none; padding: 0; margin: 12px 0 0; }
.checks li { border: 1px solid var(--line); border-left-width: 5px; border-radius: 7px; padding: 9px 12px; margin: 8px 0; line-height: 1.45; }
.checks li.ok { border-left-color: #3f8e5a; }
.checks li.ko { border-left-color: #c0504d; }
.checks .detail { display: block; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.error-panel { background: #fff7f7; border: 1px solid #dfaeac; border-left: 5px solid #c0504d; border-radius: 8px; padding: 14px 16px; margin-top: 12px; line-height: 1.55; }
.error-panel strong { color: var(--err-fg); }
.error-panel .error-message { margin: 8px 0 4px; overflow-wrap: anywhere; }
.error-panel .error-where { color: var(--muted); margin: 6px 0; }
.error-panel .error-label { display: block; font-weight: 700; font-size: .86rem; margin: 10px 0 4px; }
.error-panel pre { background: #2b1616; color: #fbeeee; padding: 10px 12px; border-radius: 7px; overflow: auto; white-space: pre-wrap; margin: 0 0 4px; }
.statusbar { color: var(--muted); margin-top: 16px; font-size: .92rem; }
.empty { color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 14px; }

@media (max-width: 880px) {
  .top { flex-direction: column; }
  .progress-box { width: 100%; }
  .layout { grid-template-columns: 1fr; }
  .list-box { position: static; max-height: 330px; }
  .exercise { padding: 18px 15px 22px; }
}
