:root {
  color-scheme: light;
  --paper: #fffefa;
  --canvas: #f2f4ef;
  --ink: #202822;
  --muted: #69746b;
  --line: #dce2da;
  --green: #17644f;
  --green-dark: #104c3b;
  --green-pale: #e5f1e9;
  --coral: #c84f3a;
  --coral-pale: #fbeae5;
  --blue: #456f7b;
  --shadow: 0 12px 34px rgb(32 40 34 / 7%);
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px;
  color: #fffefa;
  background: var(--green-dark);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 4px;
  color: #fffefa;
  font-family: Georgia, serif;
  font-size: 23px;
}
.eyebrow { margin: 0 0 4px; color: #a9cfc0; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.brand h1 { margin: 0; font-family: Georgia, serif; font-size: 23px; font-weight: 400; }
.top-actions, .editor-actions { display: flex; align-items: center; gap: 9px; }
.button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.button:active { transform: translateY(1px); }
.button-primary { color: var(--green-dark); background: #f2c970; }
.button-primary:hover { background: #ffda82; }
.button-secondary { border-color: #adc7bb; color: #fffefa; background: transparent; }
.button-secondary:hover { background: rgb(255 255 255 / 10%); }
.button-icon { width: 38px; padding: 0; font-size: 20px; }
.button-add { width: 42px; padding: 0; color: #fff; background: var(--green); font-size: 23px; font-weight: 400; }
.button-add:hover { background: var(--green-dark); }
.button-danger { border-color: #e4b4a9; color: #a13b2a; background: var(--coral-pale); }
.button-danger:hover { background: #f5d6ce; }
.button-text { min-height: 30px; padding: 0 8px; color: var(--green); background: transparent; }
.button-text:hover { text-decoration: underline; }

.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 88px); }
.sidebar { display: flex; flex-direction: column; padding: 25px 20px 18px; border-right: 1px solid var(--line); background: #f8faf6; }
.settings-block { padding: 0 0 22px; border-bottom: 1px solid var(--line); }
.config-backdrop { position: fixed; z-index: 20; inset: 0; border: 0; background: rgb(20 30 24 / 35%); }
.config-drawer { position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(410px, 100vw); overflow-y: auto; padding: 25px 22px; border-left: 1px solid var(--line); background: #f8faf6; box-shadow: var(--shadow); }
.config-drawer[hidden], .config-backdrop[hidden] { display: none; }
.config-backdrop { z-index: 40; }
.config-drawer-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 19px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.config-drawer-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 20px; font-weight: 400; }
.config-close { width: 34px; height: 34px; padding: 0; font-size: 22px; }
.config-textarea { width: 100%; min-height: 66px; margin-bottom: 12px; padding: 8px 9px; border: 1px solid #cbd5cb; border-radius: 3px; color: var(--ink); background: var(--paper); font: inherit; font-size: 11px; line-height: 1.4; resize: vertical; }
.logo-config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 3px; }
.logo-config-item { display: grid; align-content: start; gap: 6px; min-width: 0; }
.logo-preview { width: 100%; height: 54px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); object-fit: contain; }
.button-logo { display: grid; min-height: 31px; place-items: center; padding: 0 6px; border: 1px solid #cbd5cb; border-radius: 3px; color: var(--green); background: var(--paper); font-size: 10px; font-weight: 700; cursor: pointer; }
.button-logo:hover { background: var(--green-pale); }
.logo-remove { justify-self: center; }
.reconnect-button:not([hidden]) { justify-self: start; }
.print-heading { display: flex; align-items: center; justify-content: space-between; gap: 3mm; margin-bottom: 4mm; border-bottom: 1px solid #111; padding-bottom: 2mm; }
.print-heading-left { display: flex; flex: 1 1 auto; align-items: center; gap: 3mm; min-width: 0; }
.print-heading-text { min-width: 0; }
.print-heading-right { display: flex; flex: 0 0 auto; align-items: center; gap: 3mm; }
.print-logo { width: 16mm; height: 14mm; flex: 0 0 auto; object-fit: contain; }
.field-label { display: block; margin-bottom: 8px; color: #344239; font-size: 12px; font-weight: 700; }
.date-input, .input-action-row input, .rename-form input, .student-name {
  min-width: 0;
  border: 1px solid #cbd5cb;
  border-radius: 3px;
  color: var(--ink);
  background: var(--paper);
}
.date-input { width: 100%; min-height: 40px; padding: 0 10px; font-weight: 700; }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.class-section { padding-top: 20px; }
.section-heading, .roster-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2, .roster-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 17px; font-weight: 400; }
.count-pill { min-width: 25px; padding: 4px 7px; border-radius: 20px; color: var(--green-dark); background: var(--green-pale); text-align: center; font-size: 11px; font-weight: 700; }
.new-class-form { margin-top: 16px; }
.input-action-row { display: flex; gap: 7px; }
.input-action-row input { width: 100%; min-height: 40px; padding: 0 10px; font-size: 12px; }
input:focus-visible, button:focus-visible { outline: 3px solid #edc45f; outline-offset: 2px; }
.class-list { display: grid; gap: 5px; margin: 18px 0 0; padding: 0; list-style: none; }
.class-list button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 10px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 2px;
  color: #36453a;
  background: transparent;
  text-align: left;
  font-size: 12px;
}
.class-list button:hover { background: #edf3ed; }
.class-list button[aria-current="true"] { border-left-color: var(--coral); color: var(--green-dark); background: var(--green-pale); font-weight: 700; }
.class-name-in-nav { overflow-wrap: anywhere; }
.class-student-count { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.empty-list { color: var(--muted); font-size: 12px; }
.sidebar-footer { display: grid; gap: 6px; margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }
.save-indicator { color: var(--green); font-size: 11px; font-weight: 700; }
.local-note { color: var(--muted); font-size: 10px; }

.editor { min-width: 0; padding: 28px clamp(20px, 4vw, 56px); }
.editor-empty { max-width: 540px; margin: 13vh auto 0; padding: 24px; text-align: center; animation: arrive 280ms ease-out both; }
.empty-symbol { width: 50px; height: 50px; display: grid; place-items: center; margin: 0 auto 17px; border-radius: 50%; color: var(--green); background: var(--green-pale); font-size: 24px; }
.editor-empty h2 { margin: 0; font-family: Georgia, serif; font-size: 23px; font-weight: 400; }
.editor-empty p { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.class-editor { max-width: 1120px; margin: 0 auto; animation: arrive 220ms ease-out both; }
.editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 21px; border-bottom: 1px solid var(--line); }
.editor-heading .eyebrow { color: var(--coral); }
.rename-form { display: flex; align-items: center; gap: 8px; }
.rename-form input { width: min(58vw, 520px); min-height: 42px; padding: 0 10px; border-color: transparent; background: transparent; font-family: Georgia, serif; font-size: 25px; }
.rename-form input:hover, .rename-form input:focus { border-color: #cbd5cb; background: var(--paper); }
.roster-summary { margin: 4px 0 0 10px; color: var(--muted); font-size: 11px; }
.editor-actions { flex: 0 0 auto; padding-top: 15px; }
.editor-actions .button-secondary { border-color: var(--green); color: var(--green); }
.editor-actions .button-secondary:hover { color: #fff; background: var(--green); }
.add-student-form { max-width: 600px; margin: 23px 0 25px; }
.roster-heading { justify-content: flex-start; margin-bottom: 12px; }
.roster-heading .field-help { margin: 0; }
.student-list { display: grid; gap: 6px; }
.student-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 82px; align-items: center; gap: 10px; min-height: 45px; padding: 4px 7px; border-bottom: 1px solid #e8ece6; }
.student-number { color: var(--muted); text-align: center; font-size: 11px; }
.student-name { width: 100%; min-height: 35px; padding: 0 9px; font-size: 12px; }
.remove-student { min-height: 30px; border: 0; border-radius: 3px; color: #a13b2a; background: transparent; font-size: 11px; }
.remove-student:hover { background: var(--coral-pale); }
.empty-roster { padding: 18px; border: 1px dashed #b8c6b9; color: var(--muted); text-align: center; font-size: 12px; }

@keyframes arrive { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

#print-root { display: none; }
.print-page { width: 100%; color: #111; background: #fff; font-family: "Times New Roman", serif; }
.print-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 4mm; border-bottom: 1px solid #111; padding-bottom: 2mm; }
.print-institution { margin-bottom: 1mm; font-size: 8pt; font-weight: 700; line-height: 1.25; }
.print-meta { text-align: right; font-size: 8pt; }
.print-title { margin: 0 0 1mm; font-size: 15pt; }
.attendance-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.attendance-table th, .attendance-table td { border: .25mm solid #555; }
.attendance-table thead th { height: 11mm; padding: 1mm .3mm; font-size: 8pt; text-align: center; }
.attendance-table .number-column { width: 7mm; }
.attendance-table .name-column { width: 51mm; }
.attendance-table .name-cell { max-width: 0; padding: 0 1.5mm; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.attendance-table .number-cell { text-align: center; font-size: 8pt; }
.attendance-table .day-number { display: block; font-size: 8pt; }
.attendance-table .weekday { display: block; margin-top: .5mm; font-size: 6pt; font-weight: 400; }
.attendance-table .weekend { background: #d8d8d8; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.attendance-table tbody td { padding: 0; }
.attendance-table .student-row-print { break-inside: avoid; }
.print-foot { display: flex; justify-content: space-between; margin-top: 2mm; color: #444; font-size: 7pt; }
.print-legal-footer { margin-top: 1mm; color: #333; text-align: center; font-size: 6pt; line-height: 1.2; }

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 17px 20px; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .workspace { grid-template-columns: 250px minmax(0, 1fr); }
  .editor-heading { flex-direction: column; }
  .editor-actions { padding-top: 0; }
}

@media (max-width: 640px) {
  .workspace { display: flex; flex-direction: column; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .class-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logo-config-grid { gap: 6px; }
  .sidebar-footer { margin-top: 20px; }
  .editor { padding: 22px 15px; }
  .top-actions .button { flex: 1 1 auto; }
  .rename-form { align-items: flex-start; flex-direction: column; }
  .rename-form input { width: 100%; font-size: 21px; }
  .student-row { grid-template-columns: 25px minmax(0, 1fr) 70px; gap: 5px; }
}

@media print {
  @page { size: A4 landscape; margin: 6mm; }
  html, body { width: 285mm; margin: 0; background: #fff; }
  .app-shell, .topbar, .workspace { display: none !important; }
  #print-root { display: block !important; }
  .print-page { width: 285mm; height: 198mm; overflow: hidden; page-break-after: always; break-after: page; }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
  .attendance-table { height: auto; }
  .attendance-table .student-row-print td { height: var(--print-row-height); }
  .attendance-table th, .attendance-table td { border-color: #333; }
  .print-heading { margin-bottom: 3mm; }
  .print-title { font-size: 14pt; }
  .print-foot { margin-top: 1mm; }
  .print-legal-footer { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}