:root {
  --navy: #173a5e;
  --navy-dark: #102a43;
  --blue-soft: #e9f2f9;
  --orange: #b45309;
  --orange-soft: #fff3e6;
  --green: #2f6f4e;
  --green-soft: #eaf5ef;
  --ink: #1f2933;
  --muted: #5b6773;
  --line: #cbd5df;
  --surface: #ffffff;
  --page: #f4f7fa;
  --danger: #9b1c1c;
  --danger-soft: #fff0f0;
  --focus: #0b6fa4;
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); color: var(--ink); }
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--ink); }
a { color: #0b5f95; }
a:hover { color: #083f64; }
button, input, textarea, select { font: inherit; }
button, .button {
  border: 1px solid transparent;
  border-radius: 0.4rem;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.button-primary, button.primary { background: var(--navy); color: #fff; }
.button-primary:hover, button.primary:hover { background: var(--navy-dark); color: #fff; }
.button-secondary, button.secondary { background: #fff; color: var(--navy-dark); border-color: var(--line); }
.button-warn, button.warn { background: var(--orange); color: #fff; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.site-header { background: var(--navy-dark); color: #fff; border-bottom: 4px solid var(--orange); }
.site-header .inner {
  max-width: 1200px; margin: 0 auto; padding: 0.8rem 1rem;
  display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; letter-spacing: 0.01em; }
.site-nav { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; }
.site-nav a { color: #fff; text-underline-offset: 0.2em; }
.site-nav button { padding: 0.45rem 0.65rem; background: transparent; color: #fff; border-color: #8ba3b8; }

main.page { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
main.narrow { max-width: 720px; }
h1, h2, h3 { color: var(--navy-dark); line-height: 1.2; }
h1 { margin-top: 0; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 78ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 0.65rem; padding: 1rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgb(15 23 42 / 0.05); }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.actions { display: flex; gap: 0.65rem; flex-wrap: wrap; align-items: center; }
.meta { color: var(--muted); font-size: 0.92rem; }
.status { min-height: 1.4rem; font-weight: 700; }
.status.ok { color: var(--green); }
.status.error { color: var(--danger); }
.notice { border-left: 4px solid var(--navy); background: var(--blue-soft); padding: 0.8rem 1rem; margin: 1rem 0; }
.notice.warning { border-left-color: var(--orange); background: var(--orange-soft); }
.notice.success { border-left-color: var(--green); background: var(--green-soft); }
.notice.danger { border-left-color: var(--danger); background: var(--danger-soft); }

label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; border: 1px solid #96a7b7; border-radius: 0.35rem; padding: 0.65rem; background: #fff; color: var(--ink);
}
.form-row { margin-bottom: 0.9rem; }
.help { margin-top: 0.25rem; color: var(--muted); font-size: 0.9rem; }
.checkbox-row { display: flex; align-items: flex-start; gap: 0.55rem; }
.checkbox-row input { margin-top: 0.2rem; }
.checkbox-row label { font-weight: 600; margin: 0; }

.hero { padding: 3.5rem 1rem; max-width: 1000px; margin: 0 auto; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); max-width: 16ch; }
.hero .actions { margin-top: 1.5rem; }
.dashboard-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.dashboard-links a.card { color: inherit; text-decoration: none; }
.dashboard-links a.card:hover { border-color: var(--navy); }
.progress-line { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; }

.ide-page { min-height: calc(100vh - 66px); padding: 0.75rem; }
.ide-toolbar { display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.75rem; }
.ide-toolbar .spacer { flex: 1; }
.ide-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.65fr);
  grid-template-rows: minmax(390px, 53vh) minmax(280px, 38vh);
  grid-template-areas: "instructions editor" "preview preview";
  gap: 0.75rem;
}
.ide-panel { background: #fff; border: 1px solid var(--line); border-radius: 0.55rem; overflow: hidden; min-width: 0; }
.instructions-panel { grid-area: instructions; display: flex; flex-direction: column; }
.editor-panel { grid-area: editor; display: flex; flex-direction: column; }
.preview-panel { grid-area: preview; display: flex; flex-direction: column; }
.panel-heading { padding: 0.65rem 0.8rem; background: #edf3f8; border-bottom: 1px solid var(--line); color: var(--navy-dark); font-weight: 800; }
.instructions-content { padding: 0.9rem; overflow: auto; white-space: pre-wrap; line-height: 1.5; }
.editor-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); background: #edf3f8; flex-wrap: wrap; }
.editor-tab { border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--navy-dark); padding: 0.65rem 0.8rem; }
.editor-tab[aria-selected="true"] { background: #fff; box-shadow: inset 0 -3px 0 var(--orange); }
.editor-wrap { flex: 1; min-height: 0; }
.code-editor { display: none; width: 100%; height: 100%; resize: none; border: 0; border-radius: 0; padding: 0.85rem; font-family: Consolas, "Courier New", monospace; font-size: 0.95rem; line-height: 1.45; tab-size: 2; }
.code-editor.active { display: block; }
.code-editor[readonly] { background: #f7f8fa; }
.preview-meta { padding: 0.45rem 0.8rem; border-bottom: 1px solid var(--line); background: #fbfcfd; color: var(--muted); }
.preview-frame { flex: 1; width: 100%; border: 0; background: white; }
.publish-box { margin-top: 0.75rem; background: #fff; border: 1px solid var(--line); border-radius: 0.55rem; padding: 0.85rem; }
.publish-box textarea { min-height: 70px; }

.work-session { margin-bottom: 1.25rem; }
.work-team { margin: 0.8rem 0; padding: 0.8rem; border-left: 4px solid var(--orange); background: #fff; }
.work-students { display: grid; gap: 0.65rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.student-site-link { border: 1px solid var(--line); border-radius: 0.45rem; padding: 0.65rem; background: #fafcfe; }
.student-site-link a { font-weight: 800; }
.work-page-links { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.45rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border: 1px solid var(--line); padding: 0.6rem; text-align: left; vertical-align: top; }
th { background: var(--navy); color: #fff; }
tr:nth-child(even) td { background: #f8fafc; }
.badge { display: inline-block; padding: 0.16rem 0.45rem; border-radius: 999px; background: var(--blue-soft); color: var(--navy-dark); font-size: 0.82rem; font-weight: 700; }
.badge.good { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--orange-soft); color: #7a3c00; }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

.published-layout { display: grid; grid-template-rows: auto minmax(70vh, 1fr); min-height: calc(100vh - 66px); }
.published-bar { padding: 0.75rem 1rem; background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.published-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.submission-list { display: grid; gap: 1rem; }
.submission-card { border: 1px solid var(--line); border-radius: 0.55rem; padding: 0.85rem; background: #fff; }
.submission-preview { width: 100%; min-height: 360px; border: 1px solid var(--line); margin-top: 0.75rem; background: #fff; }
.team-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.8rem; }
.team-summary .card { margin: 0; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  .grid.two, .grid.three, .dashboard-links { grid-template-columns: 1fr; }
  .ide-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(420px, 52vh) minmax(300px, 42vh); grid-template-areas: "instructions" "editor" "preview"; }
  .instructions-content { max-height: 40vh; }
}
.actions-between { justify-content: space-between; }
.compact-title { margin-bottom: 0.35rem; }
.compact-title-tight { margin-bottom: 0.25rem; }
.no-top-margin { margin-top: 0; }
.action-row { margin-top: 0.8rem; }
.editor-save-row { align-items: end; min-height: 100%; }
