/* Worksheet maker screen — Direction A (the site's design language): cream paper, deep teal, coral; Baloo 2 + Nunito. */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700&family=Nunito:wght@400;600;700;800&display=swap');
:root {
  --bg: #FBF3E4; --paper: #FFFFFF; --teal: #146B5E; --teal-2: #1A7E70; --coral: #F2784B; --ink: #2E2A24; --muted: #6E665B;
  --line: #E8DCC6; --soft: #F5EBD8; --radius: 14px; --shadow: 0 1px 2px rgba(46,42,36,.08), 0 6px 18px rgba(46,42,36,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; }
button { font: inherit; cursor: pointer; }
.mk-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 12px 20px; background: var(--bg); border-bottom: 1px solid var(--line); }
.mk-name { margin: 0; font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 26px; color: var(--teal); line-height: 1.1; }
.mk-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.mk-btn { min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 2px solid var(--teal); background: var(--paper);
  color: var(--teal); font-weight: 800; }
.mk-btn:hover { background: var(--soft); }
.mk-btn.mk-primary { background: var(--teal); color: #fff; }
.mk-btn.mk-primary:hover { background: var(--teal-2); }
.mk-btn:focus-visible, .mk-card:focus-visible, .mk-chip:focus-visible, .mk-theme:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
.mk-main { display: grid; grid-template-columns: minmax(250px, 300px) 1fr; gap: 20px; padding: 20px; align-items: start; }
.mk-gallery { position: sticky; top: 86px; max-height: calc(100vh - 106px); overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-right: 4px; }
.mk-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: var(--radius); border: 2px solid transparent;
  background: var(--paper); box-shadow: var(--shadow); text-align: left; color: var(--ink); }
.mk-card[aria-current="true"] { border-color: var(--coral); }
.mk-card .mk-thumb { width: 100%; aspect-ratio: 703 / 945; overflow: hidden; border-radius: 8px; background: #fff; position: relative; border: 1px solid var(--line); }
.mk-card .mk-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }
.mk-card .mk-thumb iframe { position: absolute; left: 0; top: 0; width: 703px; height: 945px; border: 0; transform-origin: 0 0; pointer-events: none; }
.mk-card .mk-title { font-weight: 800; font-size: 13px; line-height: 1.25; }
.mk-work { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.mk-controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; padding: 14px 16px; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
.mk-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.mk-label { font-weight: 800; color: var(--muted); font-size: 14px; }
.mk-chip { min-width: 44px; min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--line); background: var(--paper); font-weight: 800; color: var(--ink); }
.mk-chip[aria-pressed="true"] { border-color: var(--teal); background: var(--teal); color: #fff; }
.mk-switch { display: flex; gap: 6px; }
.mk-themes { display: flex; gap: 6px; overflow-x: auto; max-width: min(560px, 100%); padding: 2px; }
.mk-theme { flex: 0 0 auto; width: 84px; min-height: 44px; padding: 4px 4px 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mk-theme-pic { width: 44px; height: 44px; background: center / contain no-repeat; }
.mk-theme-name { font-size: 11px; font-weight: 700; line-height: 1.15; text-align: center; color: var(--ink); hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
.mk-theme[aria-pressed="true"] { border-color: var(--coral); box-shadow: 0 0 0 2px var(--coral); }
.mk-select { min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); font: inherit; font-weight: 700; }
.mk-pages { display: flex; flex-direction: column; gap: 22px; align-items: center; }
.mk-page { position: relative; width: min(100%, 720px); }
.mk-page-head { display: flex; justify-content: space-between; align-items: center; margin: 0 0 6px; color: var(--muted); font-weight: 800; font-size: 14px; }
.mk-sheet { width: 100%; aspect-ratio: 703 / 945; background: #fff; box-shadow: var(--shadow); border-radius: 6px; overflow: hidden; position: relative; }
.mk-sheet iframe { position: absolute; left: 0; top: 0; width: 703px; height: 945px; border: 0; transform-origin: 0 0; }
.mk-note { padding: 18px; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); font-weight: 700; color: var(--muted); }
.mk-link { background: none; border: 0; color: var(--coral); font-weight: 800; padding: 6px; min-height: 44px; }
/* the gate frame: laid out at the catalogue viewport, never seen */
#mk-gate-host { position: fixed; left: -10000px; top: 0; width: 703px; height: 945px; overflow: hidden; }
#mk-gate-host iframe { width: 703px; height: 945px; border: 0; }
.mk-btn:disabled { opacity: .45; cursor: not-allowed; }
#mk-print-host { position: fixed; width: 0; height: 0; overflow: hidden; left: -10px; top: -10px; }
@media (max-width: 820px) {
  .mk-main { grid-template-columns: 1fr; padding: 12px; }
  /* phone: the page first; the gallery is a sideways strip above it */
  .mk-gallery { position: static; max-height: none; display: flex; overflow-x: auto; gap: 10px; padding-bottom: 6px; scroll-snap-type: x mandatory; }
  .mk-card { flex: 0 0 132px; scroll-snap-align: start; }
  .mk-themes { max-width: 100%; }
  .mk-top { flex-direction: column; align-items: stretch; }
  .mk-actions .mk-btn { flex: 1 1 auto; }
}
/* a template not opened: the access card replaces the controls (anonymous: sign in; free: spend one of 3; none left: plans) */
.mk-access { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; flex: 1 1 100%; }
.mk-access p { margin: 0; flex: 1 1 260px; font-weight: 700; color: var(--ink); line-height: 1.4; }
.mk-access-note { flex: 1 1 100%; margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--soft); font-weight: 700; }
/* Ctrl+P on the screen prints a hint, never the previews: printing goes through the (metered) Print button */
@media print {
  body > * { display: none !important; }
  body::before { content: attr(data-print-hint); display: block; padding: 40px; font: 700 18px 'Nunito', sans-serif; }
}
/* tap-to-edit: the hint, and the picker of one slot (the type's own pool) */
.mk-tap-hint { flex: 1 1 100%; margin: 0; color: var(--muted); font-weight: 700; font-size: 14px; }
.mk-picker { width: min(720px, calc(100vw - 32px)); max-height: min(80vh, 760px); padding: 18px; border: 0; border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); color: var(--ink); }
.mk-picker::backdrop { background: rgba(46, 42, 36, .35); }
.mk-pick-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.mk-pick-head h2 { margin: 0; font-family: 'Baloo 2', sans-serif; color: var(--teal); font-size: 22px; }
.mk-pick-note { margin: 0 0 8px; min-height: 1.4em; color: var(--coral); font-weight: 800; }
.mk-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; overflow: auto; max-height: calc(min(80vh, 760px) - 110px); }
.mk-pick-themes { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 4px; }
.mk-pick-themes .mk-chip { flex: 0 0 auto; }
.mk-pick-words { display: flex; flex-wrap: wrap; gap: 8px; overflow: auto; max-height: calc(min(80vh, 760px) - 110px); }
.mk-pick { min-height: 44px; min-width: 44px; padding: 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); font-weight: 800; color: var(--ink); }
.mk-pick img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.mk-pick[aria-pressed="true"] { border-color: var(--coral); box-shadow: 0 0 0 2px var(--coral); }
.mk-pick:disabled { opacity: .35; cursor: not-allowed; }
.mk-pick-words .mk-pick { padding: 8px 16px; font-size: 18px; }
/* the picker tiles do not hand out their pictures either (see guardFrame in shell.js) */
.mk-pick img { -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }
/* the word of one page (one-word templates): in that page's header */
.mk-page-head { gap: 12px; flex-wrap: wrap; }
.mk-page-word { display: flex; align-items: center; gap: 8px; margin-right: auto; color: var(--ink); }
.mk-page-word .mk-select { min-height: 40px; }
/* the title / instruction editor */
.mk-text-input { width: 100%; font: inherit; font-weight: 700; font-size: 18px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; resize: vertical; }
.mk-text-input:focus { outline: 3px solid var(--coral); outline-offset: 1px; }
.mk-text-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
/* page tools: up, down, duplicate, remove */
.mk-page-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.mk-icon { min-width: 40px; min-height: 40px; border-radius: 10px; border: 2px solid var(--line); background: var(--paper); font-weight: 800; color: var(--teal); }
.mk-icon:disabled { opacity: .35; cursor: default; }
/* the preview is the whole sheet of paper (its aspect ratio and iframe size come from the paper; set inline) */
.mk-sheet iframe { width: auto; height: auto; }
/* "More options" */
.mk-more { min-height: 40px; padding: 6px 12px; border: 0; background: none; color: var(--teal); font-weight: 800; }
.mk-more-box { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 12px 22px; padding-top: 10px; border-top: 1px dashed var(--line); }
/* drawing on a page: colours, undo, clear */
.mk-ink-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; padding: 6px 10px; border-radius: 12px; background: var(--paper); border: 2px solid var(--line); }
.mk-ink { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; background: var(--ink); box-shadow: 0 0 0 2px var(--line); }
.mk-ink[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--teal); }
.mk-ink-bar .mk-link:disabled { opacity: .4; cursor: default; }
/* phone: the action buttons two per row, and the header scrolls with the page (a sticky header of four buttons took a
   quarter of a 390 px screen) — the buttons are one swipe up */
@media (max-width: 600px) {
  .mk-top { position: static; }
  .mk-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .mk-actions .mk-btn { padding: 8px 10px; line-height: 1.2; }
  .mk-actions .mk-btn[hidden] { display: none; }
  .mk-actions:has(#mk-pdf[hidden]) #mk-print { grid-column: 1 / -1; }
}
/* the title row: the maker's name + "My worksheets" */
.mk-title-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
/* My worksheets */
.mk-mine-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 60vh; overflow: auto; }
.mk-mine-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); }
.mk-mine-open { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; color: var(--ink); text-decoration: none; }
.mk-mine-open strong { overflow-wrap: anywhere; }
.mk-mine-open span { color: var(--muted); font-size: 14px; }
.mk-mine-open:hover strong { text-decoration: underline; }

/* the screen version preview (screen-from-marks, 2026-11-01): the student's page inside the dialog */
.mk-screen-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.mk-screen-host { min-height: 120px; }
/* the screen version gets (almost) the whole window: the student page fills it and scrolls in ONE place — inside the
   small picker dialog it was a box with two scrollbars (operator 2026-11-01) */
.mk-picker.mk-screen-dialog { width: min(1180px, calc(100vw - 24px)); height: calc(100vh - 24px); max-height: none; padding: 14px 18px; display: flex; flex-direction: column; }
.mk-screen-dialog .mk-screen-host { flex: 1; min-height: 0; display: flex; }
.mk-screen-frame { width: 100%; height: min(72vh, 900px); border: 0; border-radius: 12px; background: #FBF3E4; }
.mk-screen-dialog .mk-screen-frame { height: 100%; flex: 1; }
.mk-screen-dialog .mk-pick-note:empty { display: none; }
/* the share sheet (student link + QR, embed code, the maker's page, the colleague link) */
.mk-share { display: grid; gap: 16px; overflow: auto; max-height: calc(min(80vh, 760px) - 80px); padding-right: 4px; }
.mk-share-sec { display: grid; gap: 8px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; }
.mk-share-sec h3 { margin: 0; font-family: 'Baloo 2', sans-serif; font-size: 19px; color: var(--teal); }
.mk-share-note { margin: 0; color: var(--muted); font-weight: 700; font-size: 14px; line-height: 1.4; }
.mk-share-row { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.mk-share-row .mk-share-field { flex: 1 1 240px; min-width: 0; font-size: 15px; }
.mk-share-row textarea.mk-share-field { font-family: ui-monospace, Consolas, monospace; font-size: 12px; font-weight: 500; white-space: pre; }
.mk-share-student { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.mk-share-student .mk-share-row { flex: 1 1 260px; }
.mk-share-qr { width: 160px; height: 160px; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
/* several pages: each page names its template; the selected page (the one the gallery and the settings change) is outlined */
.mk-page-tpl { margin-right: auto; color: var(--ink); font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }
.mk-pages.mk-multi .mk-page { cursor: pointer; }
.mk-pages.mk-multi .mk-page[aria-current="true"] .mk-sheet { outline: 3px solid var(--coral); outline-offset: 3px; }
.mk-editing { padding: 6px 12px; border-radius: 999px; background: var(--coral); color: #fff; font-weight: 800; font-size: 14px; }
