/* Front Desk: a calm, modern take on the Access look. No external fonts or assets:
   the system UI font is Segoe UI on the school's Windows PCs. */

:root {
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "Courier New", monospace;

  --access: #a4373a;          /* Access red, for accents */
  --access-dark: #7d2629;     /* darker Access red, for fills and borders */
  --access-ink: #7d2629;      /* Access red for text: headings, the room code */
  --access-tint: #f6e7e7;
  --ink: #1f1f1f;
  --ink-soft: #505050;        /* 7.5:1 on white */
  --line: #c8c6c4;
  --line-soft: #e1dfdd;
  --paper: #ffffff;
  --ribbon: #f3f2f1;
  --canvas: #e9e8e7;
  --section-bar: #d6d4d2;
  --focus: #0f62d6;
  --good: #0f6b2f;            /* 6.6:1 on white */
  --good-tint: #e7f4ea;
  --bad: #b3261e;             /* 6.0:1 on white */
  --bad-tint: #fbe9e7;
  --note: #8a5300;            /* 6.3:1 on white */
  --note-tint: #fff4e0;
  --grid-dot: #c9c7c5;

  --on-accent: #ffffff;       /* text on Access red: the app bar, primary buttons */
  --on-status: #ffffff;       /* text on the round good / bad / note marks and MessageBox icons */
  --bar-line: rgba(255, 255, 255, 0.7);  /* app bar button borders */
  --bar-hover: rgba(255, 255, 255, 0.15);
  --info: #1d5fbf;            /* MessageBox information icon, macro keywords */
  --warning: #b25e00;         /* MessageBox warning icon */
  --link: #1d4f91;            /* links and the shift log's messages */
  --customer-tint: #dbe7f7;   /* the customer's avatar */
  --control-border: #8a8886;  /* Text Box, Combo Box and Command Button borders */
  --control-mark: #605e5c;    /* Check Box and Option Button outlines, move handles */
  --selected: #e8912d;        /* the selected control in Design View, the active control in Form View */
  --hover: #e5e3e1;           /* ribbon and Command Button hover */
  --form-band: #f4f4f4;       /* Form Header and Form Footer in Form View */
  --macro-block: #fbfbfb;     /* If blocks in the Macro Builder */
  --greyed: #f7f7f7;          /* greyed-out Property Sheet rows */
  --disabled-ink: #6e6e6e;
  --disabled-bg: #f0f0f0;
  --arrive: #fff2b3;          /* a new record arriving in a datasheet */
  --backdrop: rgba(0, 0, 0, 0.3);

  --radius: 4px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  --dialog-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);

  color-scheme: light;
}

/* Themes (docs/decisions.md, "Dark mode and high contrast"). theme.js sets
   data-theme on <html> from the Theme list in the app bar. Light (above) is the
   default. Every colour in this file comes from a token, so a theme only has to
   change the tokens. Text pairs are checked for WCAG AA (4.5:1). */

[data-theme="dark"] {
  --access: #b23f42;          /* white text on it: 5.6:1 */
  --access-dark: #8e2f32;
  --access-ink: #f2a7a9;      /* 8.4:1 on --paper */
  --access-tint: #43282a;
  --ink: #e8e6e3;             /* 12.9:1 on --paper */
  --ink-soft: #b8b5b1;        /* 7.6:1 on --paper */
  --line: #5c5a58;
  --line-soft: #403e3c;
  --paper: #252423;
  --ribbon: #2f2e2d;
  --canvas: #1b1a19;
  --section-bar: #3d3c3b;
  --focus: #6ea8ff;
  --good: #72cf8f;            /* 8.6:1 on --paper */
  --good-tint: #1f3527;
  --bad: #ff8f85;             /* 6.9:1 on --paper */
  --bad-tint: #452321;
  --note: #f2b65e;            /* 8.4:1 on --paper */
  --note-tint: #3d2e15;
  --grid-dot: #484644;

  --on-accent: #ffffff;
  --on-status: #1b1a19;       /* the status colours are light here, so the marks use dark text */
  --bar-line: rgba(255, 255, 255, 0.7);
  --bar-hover: rgba(255, 255, 255, 0.15);
  --info: #86b5ff;
  --warning: #f2a250;
  --link: #93bcff;            /* 7.6:1 on --paper */
  --customer-tint: #263a57;
  --control-border: #8f8d8b;
  --control-mark: #a8a6a4;
  --selected: #f0a040;
  --hover: #3b3a39;
  --form-band: #2c2b2a;
  --macro-block: #2a2928;
  --greyed: #2b2a29;
  --disabled-ink: #9d9a97;    /* 5.2:1 on --greyed */
  --disabled-bg: #2f2e2d;
  --arrive: #5c4c12;
  --backdrop: rgba(0, 0, 0, 0.6);

  --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  --dialog-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);

  color-scheme: dark;
}

[data-theme="contrast"] {
  --access: #ffff00;          /* yellow accents with black text on them */
  --access-dark: #e0e000;
  --access-ink: #ffff00;
  --access-tint: #2e2e00;
  --ink: #ffffff;
  --ink-soft: #e6e6e6;
  --line: #ffffff;
  --line-soft: #a6a6a6;
  --paper: #000000;
  --ribbon: #000000;
  --canvas: #000000;
  --section-bar: #333333;
  --focus: #00ffff;
  --good: #3cff6e;
  --good-tint: #002b0e;
  --bad: #ff7a7a;
  --bad-tint: #330000;
  --note: #ffbf33;
  --note-tint: #2e2000;
  --grid-dot: #4d4d4d;

  --on-accent: #000000;
  --on-status: #000000;
  --bar-line: #000000;
  --bar-hover: rgba(0, 0, 0, 0.15);
  --info: #66ccff;
  --warning: #ffbf33;
  --link: #66ccff;
  --customer-tint: #002a4d;
  --control-border: #ffffff;
  --control-mark: #ffffff;
  --selected: #ff9f1a;
  --hover: #333333;
  --form-band: #141414;
  --macro-block: #0d0d0d;
  --greyed: #1a1a1a;
  --disabled-ink: #bfbfbf;
  --disabled-bg: #1a1a1a;
  --arrive: #4d4d00;
  --backdrop: rgba(0, 0, 0, 0.75);

  --shadow: none;
  --dialog-shadow: none;

  color-scheme: dark;
}
/* With no shadows, cards and dialogs need a border to stand out from the black page. */
[data-theme="contrast"] :is(.level-card, .bubble, .score-card, .leaderboard, .admin-card, .join-form,
  .canvas-form, .form-view, .shift-log, .business-brief, .loading, .load-error) { outline: 1px solid var(--line); }
[data-theme="contrast"] .app-bar { border-bottom: 2px solid var(--line); }
[data-theme="contrast"] a, [data-theme="contrast"] .app-name { text-decoration: underline; }

/* The Theme list in the app bar */
.theme-picker { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.theme-picker select { border: 1px solid var(--bar-line); border-radius: var(--radius); background: var(--access); color: var(--on-accent); padding: 2px 6px; }
.theme-picker select option { background: var(--paper); color: var(--ink); }
.board-page .theme-picker { font-size: 18px; }

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
}

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.2; }

[hidden] { display: none !important; }

/* ------------------------------------------------------------------ app bar */

.app-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 44px;
  padding: 0 16px;
  background: var(--access);
  color: var(--on-accent);
}
.app-name { color: var(--on-accent); font-weight: 600; text-decoration: none; font-size: 18px; }
.app-name:hover { text-decoration: underline; }
.crumbs { font-size: 15px; opacity: 0.95; }

main { height: calc(100vh - 44px); overflow: auto; }

.loading, .load-error { max-width: 640px; margin: 48px auto; background: var(--paper); padding: 24px; border-radius: var(--radius); }

/* ------------------------------------------------------------------ buttons */

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
}
.button:hover:not([disabled]) { background: var(--ribbon); }
.button.primary { background: var(--access); border-color: var(--access-dark); color: var(--on-accent); }
.button.primary:hover:not([disabled]) { background: var(--access-dark); }
.button.small { min-height: 28px; padding: 2px 10px; font-size: 15px; }
.button.active, .button[aria-pressed="true"] { background: var(--access-tint); border-color: var(--access); }
.button[disabled] { opacity: 0.55; cursor: not-allowed; }

.note { color: var(--ink-soft); font-size: 15px; }

/* ------------------------------------------------------------------ welcome */

.welcome { max-width: 920px; margin: 0 auto; padding: 24px 16px 48px; }
.welcome h1 { font-size: 32px; margin: 8px 0; color: var(--access-ink); }
.lead { font-size: 18px; }
.business-brief { background: var(--paper); border-left: 4px solid var(--access); padding: 12px 20px; border-radius: var(--radius); }
.business-brief h2 { margin: 4px 0; font-size: 20px; }
.level-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.level-card { display: flex; align-items: center; gap: 16px; background: var(--paper); padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.level-card.locked { opacity: 0.75; box-shadow: none; }
.level-number { width: 40px; height: 40px; border-radius: 50%; background: var(--access); color: var(--on-accent); display: grid; place-items: center; font-weight: 600; flex: none; }
.level-info { flex: 1; }
.level-info h3 { margin: 0; font-size: 18px; }
.level-info p { margin: 2px 0; color: var(--ink-soft); }
.level-info .best { color: var(--good); font-weight: 600; }
.coming { color: var(--ink-soft); font-style: italic; }

/* ------------------------------------------------------------------ dialogs */

dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; background: var(--paper); color: var(--ink); box-shadow: var(--dialog-shadow); max-width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: var(--backdrop); }
.msgbox { width: 440px; }
.msgbox-title, .panel-title { padding: 8px 14px; background: var(--ribbon); border-bottom: 1px solid var(--line-soft); font-size: 15px; }
.msgbox-body { display: flex; gap: 14px; align-items: flex-start; padding: 18px 18px 6px; }
.msgbox-text { margin: 4px 0; white-space: pre-wrap; }
.msgbox-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--on-status); font-weight: 700; font-size: 18px; }
.msgbox-icon-error { background: var(--bad); }
.msgbox-icon-warning { background: var(--warning); }
.msgbox-icon-question, .msgbox-icon-information { background: var(--info); }
.msgbox-buttons, .dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; }
.msgbox-buttons .button { min-width: 84px; justify-content: center; }
.button.pressed { background: var(--access-dark); color: var(--on-accent); }
.panel-dialog { width: 640px; }
.panel-dialog > div:not(.panel-title) { padding: 4px 18px 0; }
.brief-scene { font-size: 17px; background: var(--access-tint); padding: 10px 14px; border-radius: var(--radius); }
.tips { margin: 0; }
.tips dt { font-weight: 600; margin-top: 8px; }
.tips dd { margin: 2px 0 0 0; }
.brief-scroll { max-height: 65vh; overflow: auto; padding-right: 8px; }

/* Macro Builder (editable) */
.macro-builder-dialog { width: min(980px, calc(100vw - 32px)); }
.mb-toolbar { display: flex; gap: 8px; align-items: center; padding: 8px 0; flex-wrap: wrap; }
.mb-editable { max-height: 62vh; }
.mb-list { display: grid; gap: 6px; }
.mb-add { justify-self: start; padding: 3px 6px; border: 1px dashed var(--line); background: var(--paper); color: var(--ink-soft); min-width: 220px; }
.mb-action-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mb-tools { display: inline-flex; gap: 2px; }
.mb-tool { border: 1px solid transparent; background: transparent; cursor: pointer; padding: 0 6px; border-radius: 2px; color: var(--ink-soft); }
.mb-tool:hover:not([disabled]) { border-color: var(--line); background: var(--paper); color: var(--ink); }
.mb-tool[disabled] { opacity: 0.35; cursor: default; }
.mb-delete:hover:not([disabled]) { color: var(--bad); }
.mb-args { display: grid; gap: 3px; margin-top: 4px; }
.mb-args .mb-arg { align-items: center; }
.mb-args input, .mb-args select { flex: 1; max-width: 520px; padding: 2px 6px; border: 1px solid var(--line); background: var(--paper); }
.mb-noargs { color: var(--ink-soft); font-style: italic; margin: 2px 0; }
.mb-if { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 6px 10px; background: var(--macro-block); }
.mb-if-line { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.mb-condition { flex: 1; font-family: var(--mono); padding: 3px 6px; border: 1px solid var(--line); }
.mb-condition[aria-invalid="true"] { border-color: var(--bad); }
.mb-problem { color: var(--bad); margin: 0 0 4px 34px; font-size: 14px; }
.mb-problem:empty { display: none; }
.mb-if-links { display: flex; gap: 16px; justify-content: flex-end; margin: 4px 0; }
.expression-dialog { width: min(760px, calc(100vw - 32px)); }
.eb-body { display: grid; gap: 4px; margin: 8px 0; }
.eb-body textarea { width: 100%; font-family: var(--mono); font-size: 15px; padding: 6px; border: 1px solid var(--line); }
.eb-preview { background: var(--ribbon); border-radius: var(--radius); padding: 8px 12px; margin-top: 8px; }
.eb-expression { word-break: break-all; }
.eb-result { margin: 6px 0 0; font-weight: 600; color: var(--good); }
.eb-result.bad { color: var(--bad); }
.dc-sub-title { font-weight: 600; }
.dc-subform { flex-direction: column; justify-content: center; }
.tab-order-list { padding-left: 28px; }
.tab-order-list li { margin: 4px 0; }
.tab-order-name { display: inline-block; min-width: 200px; font-family: var(--mono); }

/* wizards */
.wizard-step { color: var(--ink-soft); font-size: 14px; margin: 10px 0 4px; }
.wizard-question { font-weight: 600; margin-bottom: 12px; }
.wizard-body { min-height: 260px; }
.wizard-choice { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.wizard-field { display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.wizard-field label { min-width: 90px; }
.wizard-field input, .wizard-field select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 2px; min-width: 220px; }
.wizard-list { border: 1px solid var(--line-soft); padding: 8px 12px; max-height: 220px; overflow: auto; }
.wizard-preview { border: 1px solid var(--line); background: var(--paper); padding: 6px 10px; font-family: var(--mono); font-size: 15px; margin-top: 10px; }

/* macro builder (read-only view) */
.macro-dialog { width: 720px; }
.mb-note { background: var(--note-tint); padding: 8px 12px; border-radius: var(--radius); }
.mb-canvas { background: var(--paper); border: 1px solid var(--line); padding: 12px; max-height: 420px; overflow: auto; }
.mb-keyword { color: var(--info); font-weight: 600; }
.mb-if-line { margin: 4px 0; }
.mb-indent { margin-left: 24px; border-left: 2px solid var(--line-soft); padding-left: 12px; }
.mb-action { margin: 6px 0; padding: 6px 10px; background: var(--ribbon); border-radius: var(--radius); }
.mb-action-name { font-weight: 600; }
.mb-arg { display: flex; gap: 12px; font-size: 15px; }
.mb-arg-name { min-width: 110px; color: var(--ink-soft); }
code { font-family: var(--mono); }

/* ------------------------------------------------------------------ Design View */

.design-screen { display: grid; grid-template-rows: auto auto 1fr auto; height: 100%; }

.ribbon { display: flex; gap: 2px; align-items: stretch; padding: 4px 8px 0; background: var(--ribbon); border-bottom: 1px solid var(--line); overflow-x: auto; }
.ribbon-group { display: flex; flex-direction: column; padding: 0 8px; border-right: 1px solid var(--line-soft); }
.ribbon-buttons { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; max-width: 560px; }
.ribbon-group-name { text-align: center; font-size: 13px; color: var(--ink-soft); padding: 2px 0 4px; }
.ribbon-button { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 2px 8px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; cursor: pointer; font-size: 15px; }
.ribbon-button:hover:not([disabled]) { background: var(--hover); border-color: var(--line-soft); }
.ribbon-button[aria-pressed="true"], .ribbon-button.active { background: var(--access-tint); border-color: var(--access); }
.ribbon-button[disabled] { opacity: 0.45; cursor: not-allowed; }
.rb-icon { font-size: 14px; min-width: 18px; text-align: center; }
.ribbon-check { display: inline-flex; gap: 6px; align-items: center; font-size: 15px; padding: 0 8px; }
.ribbon-shift { margin-left: auto; border-right: none; justify-content: center; }
.start-shift { font-weight: 600; }

.goal-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 16px; background: var(--access-tint); border-bottom: 1px solid var(--line); }
.goal-text { max-width: 1100px; }

.workspace { display: flex; min-height: 0; }
.canvas-scroll { flex: 1; overflow: auto; padding: 16px; }
.side-pane { width: 360px; flex: none; overflow: auto; background: var(--paper); border-left: 1px solid var(--line); }

.canvas-form { width: max-content; min-width: 640px; background: var(--paper); box-shadow: var(--shadow); }
.section-bar { background: var(--section-bar); font-size: 14px; padding: 2px 8px; border-top: 1px solid var(--line); user-select: none; }
.section-body {
  position: relative;
  width: 720px;
  background-color: var(--paper);
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: -8px -8px;
}
.canvas.placing .section-body { cursor: crosshair; }

.dc {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  font-size: 15px;
  overflow: hidden;
  white-space: nowrap;
  cursor: move;
  user-select: none;
  touch-action: none;
}
.dc-textbox, .dc-combobox { border: 1px solid var(--control-border); background: var(--paper); }
.dc-combobox .dc-source { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.dc-arrow { color: var(--ink-soft); }
.dc-label { background: transparent; }
.dc-commandbutton { justify-content: center; border: 1px solid var(--control-border); background: var(--ribbon); border-radius: 2px; }
.dc-checkbox { padding: 0; justify-content: center; }
.dc-check { width: 14px; height: 14px; border: 1px solid var(--control-mark); background: var(--paper); }
.dc-optiongroup { flex-direction: column; align-items: flex-start; justify-content: flex-start; border: 1px solid var(--control-border); padding: 8px; gap: 6px; }
.dc-option { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.dc-radio { width: 12px; height: 12px; border: 1px solid var(--control-mark); border-radius: 50%; }
.dc-subform { border: 1px dashed var(--control-border); justify-content: center; color: var(--ink-soft); }
.dc-hint { color: var(--ink-soft); font-style: italic; }
.dc-source { color: var(--ink); }
.dc.selected { outline: 2px solid var(--selected); outline-offset: 0; overflow: visible; z-index: 2; }
.dc:focus-visible { outline: 3px solid var(--focus); }
.dc-move { position: absolute; top: -6px; left: -6px; width: 9px; height: 9px; background: var(--control-mark); }
.dc-resize { position: absolute; bottom: -5px; right: -5px; width: 9px; height: 9px; background: var(--selected); border: 1px solid var(--paper); cursor: nwse-resize; }

.pane-title { font-weight: 600; padding: 8px 12px; background: var(--ribbon); border-bottom: 1px solid var(--line-soft); }
.field-list { border-bottom: 1px solid var(--line); }
.checklist { border-bottom: 1px solid var(--line); }
.cl-fields { list-style: none; margin: 0; padding: 4px 8px 8px; }
.cl-field { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; align-items: center; padding: 2px 6px; font-size: 15px; }
.cl-mark { color: var(--ink-soft); text-align: center; }
.cl-field.placed .cl-mark { color: var(--good); font-weight: 700; }
.cl-state { color: var(--ink-soft); font-size: 14px; }
.cl-field.placed .cl-state { color: var(--ink); }
.fl-table { font-size: 14px; color: var(--ink-soft); padding: 6px 12px 0; }
.fl-fields { list-style: none; margin: 0; padding: 4px 8px 8px; }
.fl-field { display: flex; justify-content: space-between; width: 100%; padding: 3px 6px; border: none; background: transparent; text-align: left; cursor: grab; border-radius: 2px; }
.fl-field:hover { background: var(--access-tint); }
.fl-type { color: var(--ink-soft); font-size: 13px; }

.ps-selection { padding: 6px 12px 2px; font-size: 15px; }
.ps-chooser { margin: 4px 12px 8px; width: calc(100% - 24px); padding: 3px; border: 1px solid var(--line); }
.ps-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.ps-tab { border: 1px solid transparent; border-bottom: none; background: transparent; padding: 4px 9px; cursor: pointer; font-size: 15px; }
.ps-tab.active { background: var(--paper); border-color: var(--line); margin-bottom: -1px; font-weight: 600; }
.ps-grid { width: 100%; border-collapse: collapse; font-size: 15px; }
.ps-grid th { text-align: left; font-weight: 400; padding: 2px 8px; width: 46%; border-bottom: 1px solid var(--line-soft); }
.ps-grid td { padding: 1px 4px; border-bottom: 1px solid var(--line-soft); }
.ps-grid input, .ps-grid select { width: 100%; border: 1px solid transparent; padding: 2px 4px; background: transparent; }
.ps-grid input:hover:not([disabled]), .ps-grid select:hover { border-color: var(--line); }
.ps-grid tr.greyed th, .ps-grid input[disabled] { color: var(--disabled-ink); }
.ps-grid tr.greyed { background: var(--greyed); }
.ps-event { display: flex; }
.ps-builder { border: 1px solid var(--line); background: var(--ribbon); cursor: pointer; padding: 0 8px; }
.ps-builder[disabled] { opacity: 0.45; cursor: not-allowed; }
.ps-with-list { display: block; }

.status-bar { padding: 4px 16px; background: var(--ribbon); border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-soft); }

.workspace.previewing .canvas-scroll { display: flex; flex-direction: column; align-items: flex-start; }
.preview-note { background: var(--note-tint); padding: 8px 12px; border-radius: var(--radius); max-width: 760px; }

/* ------------------------------------------------------------------ Form View */

.form-view { background: var(--paper); box-shadow: var(--shadow); width: max-content; min-width: 560px; }
.fv-caption { background: var(--ribbon); padding: 4px 10px; font-size: 14px; border-bottom: 1px solid var(--line); }
.fv-section { position: relative; width: 720px; }
.fv-form-header { background: var(--form-band); border-bottom: 1px solid var(--line-soft); }
.fv-form-footer { background: var(--form-band); border-top: 1px solid var(--line-soft); }
.fv-control { position: absolute; display: flex; align-items: center; }
.fv-label { font-size: 15px; white-space: nowrap; }
.fv-form-header .fv-label { font-size: 20px; font-weight: 600; color: var(--access-ink); }
.fv-input { width: 100%; height: 100%; border: 1px solid var(--control-border); padding: 0 4px; background: var(--paper); font-size: 15px; }
.fv-input:disabled { background: var(--disabled-bg); color: var(--disabled-ink); }
.fv-checkbox input { width: 18px; height: 18px; }
.fv-optiongroup { border: 1px solid var(--control-border); align-items: flex-start; padding: 8px; }
.fv-options { display: flex; flex-direction: column; gap: 4px; }
.fv-option { display: flex; gap: 6px; align-items: center; font-size: 15px; }
.fv-button { justify-content: center; border: 1px solid var(--control-border); border-radius: 2px; background: var(--ribbon); cursor: pointer; }
.fv-button:hover:not([disabled]) { background: var(--hover); }
.fv-subform { border: 1px solid var(--control-border); flex-direction: column; align-items: stretch; background: var(--paper); overflow: hidden; }
.fv-subform-caption { font-size: 13px; color: var(--ink-soft); padding: 2px 6px; background: var(--ribbon); border-bottom: 1px solid var(--line-soft); }
.fv-subform-scroll { overflow: auto; flex: 1; }
.fv-subform .datasheet { font-size: 13px; }
.fv-subform-error { color: var(--bad); padding: 8px; margin: 0; font-size: 14px; }
.fv-status { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-soft); padding: 4px 10px; border-top: 1px solid var(--line-soft); }
.fv-nav { display: inline-flex; gap: 2px; }
.fv-nav-button { border: 1px solid var(--line); background: var(--paper); cursor: pointer; padding: 0 8px; font-size: 13px; }
.fv-nav-button:hover { background: var(--ribbon); }
.fv-active { outline: 3px solid var(--selected); outline-offset: 1px; border-radius: 2px; }
.fv-pressed { background: var(--access-tint) !important; outline: 3px solid var(--access); }

/* ------------------------------------------------------------------ the shift */

.shift-screen { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.shift-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 16px; background: var(--ribbon); border-bottom: 1px solid var(--line); }
.shift-toolbar h2 { font-size: 18px; margin: 0; }
.shift-counter { background: var(--access); color: var(--on-accent); padding: 2px 10px; border-radius: 12px; font-size: 15px; }
.spacer { flex: 1; }
.speed { display: flex; gap: 4px; }
.shift-columns { display: grid; grid-template-columns: minmax(280px, 1fr) auto minmax(300px, 1.1fr); gap: 16px; padding: 16px; min-height: 0; }
.shift-columns > section { min-height: 0; overflow: auto; }
.customer, .temp { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; }
.customer-avatar { background: var(--customer-tint); color: var(--link); font-size: 28px; }
.temp-avatar { background: var(--access); color: var(--on-accent); font-size: 14px; }
.bubble { position: relative; background: var(--paper); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); flex: 1; }
.bubble-text { margin: 0; font-size: 17px; }
.temp-line { margin: 12px 0 0; font-style: italic; color: var(--ink-soft); }
.shift-people h3, .shift-table h3 { font-size: 16px; margin: 8px 0; }
.shift-log { margin: 0; padding: 8px 8px 8px 28px; background: var(--paper); border-radius: var(--radius); max-height: 46vh; overflow: auto; font-size: 15px; }
.shift-log li { margin: 2px 0; }
.shift-log .log-customer { font-weight: 600; margin-top: 8px; }
.shift-log .log-problem { color: var(--bad); }
.shift-log .log-saved { color: var(--good); }
.shift-log .log-message { color: var(--link); }

.datasheet-scroll { overflow: auto; max-width: 100%; background: var(--paper); border: 1px solid var(--line); }
.datasheet { border-collapse: collapse; font-size: 14px; width: 100%; }
.datasheet th { background: var(--ribbon); font-weight: 600; text-align: left; padding: 4px 8px; border: 1px solid var(--line-soft); white-space: nowrap; }
.datasheet td { padding: 3px 8px; border: 1px solid var(--line-soft); white-space: nowrap; }
.datasheet td.wrap { white-space: normal; min-width: 260px; }
.shift-table .datasheet td.wrap { min-width: 120px; }
.bubble-reply { margin-top: 6px; font-style: italic; color: var(--access-ink); }
.bubble-reply:empty { display: none; }
.datasheet tr.arrived td { animation: arrive 1.2s ease-out; }
.datasheet tr.changed td { background: var(--note-tint); }
.empty { color: var(--ink-soft); font-style: italic; }
@keyframes arrive { from { background: var(--arrive); } to { background: transparent; } }

/* ------------------------------------------------------------------ debrief */

.debrief { max-width: 1400px; margin: 0 auto; padding: 16px 16px 48px; }
.debrief h2 { margin: 8px 0 12px; }
.score-cards { display: flex; flex-wrap: wrap; gap: 12px; }
.score-card { background: var(--paper); border-radius: var(--radius); padding: 10px 18px; box-shadow: var(--shadow); min-width: 140px; }
.score-card.total { border-top: 4px solid var(--access); }
.score-label { color: var(--ink-soft); font-size: 15px; }
.score-value { font-size: 30px; font-weight: 600; }
.score-value span { font-size: 18px; color: var(--ink-soft); font-weight: 400; }
.score-value.small { font-size: 22px; }
.debrief-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0; }
.debrief-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; }
.debrief section { margin-bottom: 20px; }
.debrief h3 { font-size: 18px; }
.verdicts, .checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.verdict, .check { display: flex; gap: 10px; background: var(--paper); padding: 8px 12px; border-radius: var(--radius); border-left: 4px solid var(--line); }
.v-good { border-left-color: var(--good); }
.v-bad { border-left-color: var(--bad); background: var(--bad-tint); }
.v-note { border-left-color: var(--note); background: var(--note-tint); }
.verdict-outcome, .check-label { font-weight: 600; }
.verdict-quote { color: var(--ink-soft); font-style: italic; font-size: 15px; }
.verdict-why { margin-top: 2px; }
.tag { margin-left: 8px; font-size: 13px; font-weight: 400; padding: 1px 8px; border-radius: 10px; background: var(--ribbon); border: 1px solid var(--line-soft); }
.points { font-weight: 400; color: var(--ink-soft); margin-left: 6px; }
.mark { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: var(--on-status); font-weight: 700; font-size: 14px; }
.mark-good { background: var(--good); }
.mark-bad { background: var(--bad); }
.mark-note { background: var(--note); }
.row-status { display: flex; gap: 6px; align-items: center; }
.row-status .mark { width: 20px; height: 20px; font-size: 12px; }
tr.row-bad td { background: var(--bad-tint); }
tr.row-note td { background: var(--note-tint); }
td.cell-bad { font-weight: 700; color: var(--bad); text-decoration: underline wavy; }

/* ------------------------------------------------------------------ app bar extras, join screen */

.app-bar .spacer { flex: 1; }
.player-info { font-size: 15px; }
.player-name { font-weight: 600; }
.app-bar-button { border: 1px solid var(--bar-line); background: transparent; color: var(--on-accent); border-radius: var(--radius); padding: 3px 12px; cursor: pointer; }
.app-bar-button:hover { background: var(--bar-hover); }

.link-button { border: none; background: none; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; }
.notice { background: var(--note-tint); border-left: 4px solid var(--note); padding: 8px 12px; border-radius: var(--radius); }

.join { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
.join h1 { font-size: 32px; margin: 8px 0; color: var(--access-ink); }
.join-form { background: var(--paper); padding: 20px 24px; border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 8px; justify-items: start; }
.join-label { font-size: 18px; font-weight: 600; margin: 8px 0 0; }
.join-code { font-size: 24px; letter-spacing: 2px; text-transform: uppercase; width: 200px; padding: 6px 10px; border: 1px solid var(--control-border); border-radius: var(--radius); }
.nickname-choices { display: grid; gap: 6px; width: 100%; }
.nickname-choice { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--line-soft); border-radius: var(--radius); }
.nickname-choice:has(input:checked) { border-color: var(--access); background: var(--access-tint); }
.nickname-choice label { font-size: 18px; flex: 1; cursor: pointer; }
.nickname-choice input { width: 18px; height: 18px; }
.join-error { color: var(--bad); font-weight: 600; margin: 4px 0; min-height: 1.4em; }
.button.big { font-size: 18px; padding: 6px 28px; }
.privacy { background: var(--paper); padding: 10px 14px; border-radius: var(--radius); border-left: 4px solid var(--info); }
.score-status { font-weight: 600; margin: 0 0 12px; }

/* ------------------------------------------------------------------ leaderboard */

.leaderboard-screen { max-width: 900px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; justify-items: start; }
.leaderboard-holder { width: 100%; }
.leaderboard { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 20px 20px; }
.lb-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 16px; justify-content: space-between; }
.lb-header h2 { margin: 6px 0; }
.lb-status { margin: 0; color: var(--ink-soft); }
.lb-live::before { content: "● "; color: var(--good); }
.lb-offline { color: var(--bad); font-weight: 600; }
.leaderboard.frozen .lb-status { color: var(--access-ink); font-size: 1.2em; }
.leaderboard.frozen .lb-status::before { content: none; }
.lb-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 0; }
.lb-tab { border: 1px solid transparent; border-bottom: none; background: transparent; padding: 6px 14px; cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; }
.lb-tab.active { border-color: var(--line); background: var(--paper); margin-bottom: -1px; font-weight: 600; }
.lb-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.lb-table caption { text-align: left; font-weight: 600; padding: 6px 0; }
.lb-table th { text-align: left; border-bottom: 2px solid var(--line); padding: 6px 10px; }
.lb-table td { border-bottom: 1px solid var(--line-soft); padding: 6px 10px; }
.lb-rank, .lb-score, .lb-time { font-variant-numeric: tabular-nums; }
.lb-table tr.lb-mine td { background: var(--access-tint); font-weight: 700; }
.lb-table tr.lb-mine td:first-child { box-shadow: inset 4px 0 0 var(--access); }
.lb-you { font-weight: 400; }

.board-page main { padding: 16px 24px; }
.board-page .app-bar { height: 64px; }
.board-page .app-bar .crumbs { font-size: 24px; }
.leaderboard.big { font-size: 26px; max-width: 1600px; margin: 0 auto; }
.leaderboard.big h2 { font-size: 34px; }
.leaderboard.big .lb-table td, .leaderboard.big .lb-table th { padding: 10px 16px; }

/* ------------------------------------------------------------------ teacher dashboard */

.admin-narrow { max-width: 520px; margin: 0 auto; padding: 24px 16px; }
.admin-wide { max-width: 1500px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; justify-items: stretch; }
.admin-wide > .button { justify-self: start; }
.admin-card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 20px 16px; margin-bottom: 16px; }
.admin-card h2 { margin: 4px 0 10px; font-size: 20px; }
.admin-card h3 { font-size: 16px; margin: 12px 0 4px; }
.admin-columns { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; }
.admin-fieldset { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 6px 12px 10px; min-width: 260px; }
.admin-fieldset legend { font-weight: 600; padding: 0 4px; }
.admin-check { display: block; margin: 4px 0; cursor: pointer; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.admin-table th { text-align: left; border-bottom: 2px solid var(--line); padding: 4px 8px; white-space: nowrap; }
.admin-table td { border-bottom: 1px solid var(--line-soft); padding: 4px 8px; }
.admin-table tr.counts td { background: var(--good-tint); }
.counts-tag { color: var(--good); font-size: 13px; }
.admin-scroll { max-height: 420px; overflow: auto; }
.row-actions { display: flex; gap: 6px; }
.room-code-cell { font-weight: 700; letter-spacing: 1px; }
.room-header { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-end; }
.room-header h1 { margin: 0; }
.room-code-big { letter-spacing: 3px; color: var(--access-ink); }
.room-status { margin: 4px 0 0; font-weight: 600; }
.room-frozen { color: var(--access-ink); }
.room-closed { color: var(--ink-soft); }
.room-actions { display: flex; flex-wrap: wrap; gap: 8px; }
a.button { text-decoration: none; color: inherit; }
a.button.primary { color: var(--on-accent); }
.admin-room-columns { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.mistake-list { margin: 0; padding-left: 24px; }
.mistake-list li { margin: 3px 0; }

/* ------------------------------------------------------------------ smaller screens (down to 1366 x 768) */

@media (max-width: 1500px) {
  .side-pane { width: 320px; }
  .shift-columns { grid-template-columns: minmax(240px, 0.9fr) auto minmax(260px, 1fr); gap: 12px; padding: 12px; }
  .ribbon-buttons { max-width: 470px; }
}

@media (max-width: 1100px) {
  .shift-columns, .debrief-columns, .admin-room-columns { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
