:root {
  --sky: #dff2fc;
  --navy: #17354b;
  --blue: #257da8;
  --muted: #5d7383;
  --line: #cbdfea;
  --paper: #fff;
  --bg: #f3f8fc;
  --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--navy); font: 15px/1.6 system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif; }
a { color: var(--blue); }
button, input, select { font: inherit; }
button, .button, .file-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; max-width: 100%; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--sky); color: var(--navy); font-weight: 650;
  text-decoration: none; cursor: pointer;
}
button:hover, .button:hover, .file-button:hover { filter: brightness(.97); }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed=true], .primary { background: var(--navy); color: white; border-color: var(--navy); }
.secondary { background: white; }
input:not([type=checkbox]):not([type=range]):not([type=color]):not([type=file]), select {
  width: 100%; min-width: 0; min-height: 42px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--navy);
}
input[type=color] { width: 44px; height: 42px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; }
input[type=range] { width: 100px; max-width: 100%; }
input[type=checkbox] { flex: 0 0 auto; accent-color: var(--blue); }
input[type=file] { max-width: 100%; font-size: 12px; }
.file-button { position: relative; font-size: 13px; }
.file-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
label { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 13px; font-weight: 600; }
.check { flex-direction: row; align-items: center; gap: 8px; margin: 12px 0; font-weight: 400; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.3; letter-spacing: -1px; }
h2 { font-size: 20px; line-height: 1.4; }
h3 { font-size: 17px; line-height: 1.5; }
h4 { font-size: 15px; }
p { margin-top: 6px; }
.help, .panel-heading p { font-size: 12px; color: var(--muted); }
.help, .warning, #status, #source-name { overflow-wrap: anywhere; }
.site-header { max-width: 1248px; margin: auto; padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); font-size: 20px; font-weight: 800; text-decoration: none; }
.brand img { width: 44px; height: 44px; }
.brand small { display: block; font-size: 9px; letter-spacing: 2px; }
.site-header nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.site-header nav a { padding: 8px 12px; border-radius: 10px; text-decoration: none; }
.site-header nav a[aria-current] { background: var(--sky); font-weight: 750; }
.collab-brand-family { display: flex; align-items: center; gap: 24px; min-width: 0; }
.site-header .collab-brand-family nav { gap: 12px; flex-wrap: nowrap; }
.site-header .service-brand { display: flex; align-items: center; gap: 6px; min-height: 42px; padding: 5px 3px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.site-header .service-brand:hover { background: var(--sky); }
.site-header .service-brand img { width: 32px; height: 32px; object-fit: contain; }
main { max-width: 1248px; margin: auto; padding: 0 24px 32px; }
.intro { padding: 16px 0 20px; }
.eyebrow { margin-bottom: 6px; color: var(--blue); font-size: 10px; letter-spacing: 2px; font-weight: 700; }
.intro > p:not(.eyebrow) { color: var(--muted); }
.privacy { font-size: 12px; }
.workspace-toolbar, .role-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.role-switch, .work-file-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.role-switch button, .work-file-actions button, .work-file-actions .file-button { font-size: 13px; }
.workspace-options { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.recovery-choice { margin: 0; flex-wrap: wrap; font-size: 12px; gap: 6px; }
.recovery-choice small { color: var(--muted); font-size: 11px; }
#save-state { margin: 0; }
#status { color: var(--blue); padding: 8px 0 0; }
#status:empty, #save-state:empty, #source-name:empty, #source-note:empty, #drawing-status:empty { display: none; }
#status.error, .warning { color: #a3372e; }
.panel { min-width: 0; margin-bottom: 16px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.panel-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.step { display: grid; place-items: center; flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--sky); font-weight: 800; }
.step-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 680px; margin: 20px 0 16px; }
.step-nav button { background: white; padding-inline: 8px; }
.step-nav button[aria-current=step] { background: var(--navy); color: white; }
.setup-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); gap: 24px; align-items: start; }
.setup-fields { display: grid; gap: 12px; min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
.fields > #catalog-field, .fields > #source-field { grid-column: 1 / -1; }
.fields.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#aspect-field { grid-column: auto; }
.times { display: none; }
.setup-fields > p { margin: 0; }
.setup-submit { width: 100%; margin-top: 4px; }
.setup-preview-wrap { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
#setup-preview { width: min(100%, 330px, calc(380px * var(--preview-aspect, 1))); margin: 12px auto 0; }
.preview-cell { position: relative; min-width: 0; border: 1px solid #46677c77; }
.preview-cell span { position: absolute; top: 0; left: 1px; padding: 0 2px; background: #ffffffdc; color: var(--navy); font-size: 9px; }
.distribution-note + .share-content { margin-top: 16px; }
.qr-card { display: grid; justify-items: center; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 12px; color: var(--muted); }
.share-content { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 24px; align-items: start; }
.share-instructions { margin: 16px 0 0; padding-left: 22px; font-size: 13px; }
.share-instructions li + li { margin-top: 8px; }
.distribution-note { padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--sky); font-size: 13px; }
.distribution-note p { margin-top: 4px; }
#qr { display: grid; place-items: center; }
#qr svg { display: block; width: 130px; height: 130px; max-width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.workspace-heading { margin: 20px 0 16px; }
.workspace-heading p { font-size: 13px; color: var(--muted); }
.work-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
body[data-role=student] .work-grid { grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); }
.board { display: grid; position: relative; margin-top: 12px; border: 1px solid var(--line); background: white; background-size: 100% 100%; overflow: hidden; }
.board-cell { position: relative; display: block; min-width: 0; min-height: 0; padding: 0; border: 1px solid #49677c55; border-radius: 0; background: transparent; aspect-ratio: var(--cell-aspect, 1); overflow: hidden; }
.board-cell:hover { background: #dff2fc55; }
.board-cell.selected { outline: 3px solid var(--blue); outline-offset: -3px; z-index: 1; }
.board-cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: white; }
.board-cell span { position: absolute; left: 2px; top: 2px; z-index: 1; padding: 0 3px; border-radius: 3px; background: #ffffffdc; color: var(--navy); font-size: 10px; line-height: 1.5; }
.board-cell.filled span:after { content: ' ✓'; }
.board-cell.filled { background: white; }
body[data-role=teacher] .board-cell:not(.filled) { background: repeating-linear-gradient(45deg, #f1f5f8 0, #f1f5f8 7px, #fff 7px, #fff 14px); }
body[data-role=student] .board-cell { background: transparent; }
#student-source-field { width: 100%; margin-top: 12px; }
.paint-tools, .drawing-view-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.paint-tools button, .drawing-view-tools button { font-size: 12px; padding: 8px 10px; }
.paint-tools label { font-size: 12px; }
.quick-colors { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; padding: 3px; }
.quick-colors button { width: 30px; min-height: 30px; height: 30px; padding: 0; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.quick-colors button[aria-pressed=true] { outline: 3px solid var(--navy); outline-offset: 2px; }
.paint-wrap { display: block; height: min(60vh, 640px); min-height: 160px; margin: 12px 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #edf5fa; overflow: auto; }
#paint-canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 65vh; margin: auto; touch-action: none; background: white; }
.drawing-pan { cursor: grab; }
.drawing-pan:active { cursor: grabbing; }
#save-drawing-work, #download-tile { width: 100%; margin-top: 12px; }
.drawing-focus { position: fixed; inset: 0; z-index: 500; display: flex; flex-direction: column; margin: 0; padding: 16px; border-radius: 0; overflow: auto; }
.drawing-focus .paint-wrap { flex: 1; height: auto; min-height: 160px; max-height: none; margin: 8px 0; }
.drawing-focus #student-steps, .drawing-focus > p:last-child { display: none; }
.collab-drawing-focus { overflow: hidden; }
.drop-zone { display: block; position: relative; padding: 24px 16px; border: 2px dashed var(--line); border-radius: 10px; background: var(--bg); text-align: center; cursor: pointer; }
.drop-zone.over { border-color: var(--blue); background: var(--sky); }
#counts { margin: 16px 0; font-weight: 650; }
#cell-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
#cell-controls h4 { width: 100%; }
#cell-controls > label { flex: 1 1 160px; }
#cell-preview { display: block; width: 100%; max-width: 320px; max-height: 320px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
#pending-section { margin-top: 20px; }
#pending-list { display: grid; gap: 12px; margin-top: 12px; }
.pending-row { display: grid; grid-template-columns: 45px minmax(0, 1fr); gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.pending-row img { width: 45px; height: 45px; object-fit: contain; background: var(--bg); }
.pending-row p { font-size: 12px; overflow-wrap: anywhere; }
.pending-row .actions { grid-column: 1 / -1; margin: 0; }
.pending-row select { width: 100px; }
.pending-row button { font-size: 12px; padding: 8px 10px; }
.notice { padding: 16px; margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sky); }
.notice button { margin: 12px 8px 0 0; }
#busy-indicator { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: #f3f8fce8; font-size: 18px; font-weight: 700; text-align: center; }
#import-errors { max-height: 180px; margin: 12px 0; overflow: auto; }
#artwork-view { width: min(95vw, 1100px); max-height: 95vh; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--navy); overflow: auto; }
#artwork-view::backdrop { background: #102d46b3; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
#artwork-canvas { display: block; max-width: 100%; max-height: 70vh; margin: 16px auto; background: white; }
#service-message { position: fixed; bottom: 24px; left: 50%; z-index: 1100; max-width: calc(100vw - 32px); padding: 12px 24px; border-radius: 10px; background: var(--navy); color: white; font-weight: 650; box-shadow: 0 4px 20px #17354b33; transform: translateX(-50%); }
footer { max-width: 1248px; margin: auto; padding: 16px 24px; color: var(--muted); font-size: 11px; }
[hidden] { display: none !important; }
:focus-visible, .file-button:focus-within, .drop-zone:focus-within { outline: 3px solid #c76a15; outline-offset: 3px; }
@media (max-width: 900px) {
  .site-header { flex-wrap: wrap; }
  .collab-brand-family { width: 100%; justify-content: space-between; gap: 12px; }
  .site-header > nav { margin-left: auto; }
  .setup-layout { grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); gap: 16px; }
  .work-grid, body[data-role=student] .work-grid { grid-template-columns: minmax(0, 1fr); }
  .overview .board { max-width: 500px; margin-inline: auto; }
}
@media (max-width: 620px) {
  .site-header { padding: 12px 16px; gap: 8px; }
  main { padding: 0 16px 24px; }
  .intro { padding: 12px 0 16px; }
  .intro > p:not(.eyebrow) { font-size: 13px; }
  .panel { padding: 16px; }
  .panel-heading { gap: 10px; margin-bottom: 16px; }
  .workspace-toolbar { align-items: stretch; }
  .role-switch, .work-file-actions { width: 100%; gap: 8px; }
  .role-switch > *, .work-file-actions > * { flex: 1 1 0; padding-inline: 8px; font-size: 12px; }
  .workspace-options { margin-top: 12px; }
  .step-nav { gap: 6px; margin-top: 16px; }
  .step-nav button { padding: 8px 4px; font-size: 12px; }
  .setup-layout { grid-template-columns: minmax(0, 1fr); }
  .setup-preview-wrap { padding: 12px; }
  #setup-preview { max-width: 280px; }
  .share-content { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .qr-card { justify-self: start; }
  .fields.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #aspect-field { grid-column: 1 / -1; }
  .share-instructions { font-size: 12px; }
  .fields { gap: 12px; }
  .paint-tools, .drawing-view-tools { gap: 6px; }
  .paint-tools button, .drawing-view-tools button { padding-inline: 8px; }
  .drawing-focus { padding: 12px; }
  .drawing-focus .paint-wrap { min-height: 140px; }
  #artwork-view { padding: 16px; }
  footer { padding: 16px; }
}
@media (max-width: 480px) {
  .brand { gap: 8px; font-size: 17px; }
  .brand img { width: 36px; height: 36px; }
  .site-header .collab-brand-family nav { gap: 6px; }
  .site-header .service-brand { flex-direction: column; gap: 2px; padding: 3px; font-size: 9px; }
  .site-header .service-brand img { width: 27px; height: 27px; }
  .collab-brand-family { gap: 8px; }
  .site-header > nav { font-size: 12px; }
  .site-header > nav a { padding: 6px 10px; }
  .fields:not(.compact) { grid-template-columns: minmax(0, 1fr); }
}
#preparation-warning{margin-bottom:16px}textarea{font:inherit;color:var(--navy);width:100%;padding:12px;border:1px solid var(--line);border-radius:10px;resize:vertical;background:white}#student-instructions{margin:16px 0}#student-instructions summary,#missing-summary summary{cursor:pointer;font-weight:650}#student-instructions label{margin:12px 0}#missing-summary{margin:12px 0}.board-filter-label{margin:12px 0;max-width:240px;font-size:12px}.board-cell.filtered-filled{opacity:.2}.board-cell.missing-match{outline-offset:-2px}#cell-ratio-warning{flex-basis:100%;color:#9a4f19}#missing-cells{overflow-wrap:anywhere}
