:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #595959;
  --border: #8c8c8c;
  --accent: #0b5cad;
  --accent-text: #ffffff;
  --error: #a4161a;
  --error-bg: #fdecea;
  --notice: #14532d;
  --notice-bg: #e3f6e8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --text: #f2f2f2;
    --muted: #b3b3b3;
    --border: #808080;
    --accent: #6cb2f5;
    --accent-text: #0d1a26;
    --error: #ffb3ad;
    --error-bg: #3d1614;
    --notice: #b7efc5;
    --notice-bg: #12331f;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
}

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

label {
  font-weight: 600;
}

input,
button {
  min-height: 44px;
  font: inherit;
  border-radius: 6px;
}

input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

button {
  min-width: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stack button {
  margin-top: 0.5rem;
}

.narrow {
  max-width: 24rem;
}

.error {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: var(--error-bg);
  color: var(--error);
}

h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 1.5rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}

.notice {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: var(--notice-bg);
  color: var(--notice);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.site-header h1 {
  margin: 0;
}

.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  flex-shrink: 0;
}

.empty {
  text-align: center;
  margin: 3rem 0;
  color: var(--muted);
}

.schedule {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.schedule-link {
  display: block;
  width: 100%;
}

.schedule-image {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  max-height: 80vh;
  max-height: 80dvh;
  object-fit: contain;
}

.viewer {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: auto;
  background: #000;
}

.viewer[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer::backdrop {
  background: #000;
}

.viewer-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
}

.viewer.zoomed[open] {
  display: block;
}

.viewer.zoomed .viewer-image {
  max-width: none;
  max-height: none;
  margin: auto;
  cursor: zoom-out;
}

.viewer-close {
  position: fixed;
  top: calc(0.5rem + env(safe-area-inset-top, 0px));
  right: calc(0.5rem + env(safe-area-inset-right, 0px));
  z-index: 1;
  border-color: #fff;
  background: #000;
  color: #fff;
}

.secondary {
  border-color: var(--border);
  background: transparent;
  color: var(--text);
}

.hint,
.muted {
  color: var(--muted);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.5rem;
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  font-weight: 700;
  border-bottom: 3px solid var(--accent);
}

.tabs-logout {
  margin-left: auto;
}

.dashboard-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
}

.dashboard-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

select {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-weight: 400;
}

.check input {
  width: 22px;
  min-height: 22px;
  height: 22px;
}

.panel {
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.panel summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.panel summary::before {
  content: "\25B8";
}

.panel[open] summary::before {
  content: "\25BE";
}

.panel summary span:not(.row-title) {
  font-weight: 400;
}

.panel form {
  padding: 0 0.75rem 0.75rem;
}

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.row-title {
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.tag {
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
}

.panel-link {
  margin: 0;
  padding: 0 0.75rem 0.5rem;
}

.panel-link a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.secondary-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.5rem 1rem;
}

.day-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.day-form {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.5rem;
}

.day-form input {
  flex: 1 1 auto;
  min-width: 0;
}

.copy-week button {
  margin-top: 0;
}

.copy-week .hint {
  margin: 0;
}

.day-label {
  margin: 0.5rem 0 1rem;
  font-weight: 600;
}

.day-label a {
  margin-left: 0.5rem;
  font-weight: 400;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.chip[aria-current="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.summary {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.roster {
  margin-bottom: 1rem;
}

.roster-row {
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.roster-name {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.status-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.status {
  min-height: 48px;
  padding: 0.25rem;
  border-color: var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 500;
}

.status[aria-pressed="true"] {
  font-weight: 700;
  color: #fff;
}

.status[aria-pressed="true"]::before {
  content: "\2713\00A0";
}

.status-present[aria-pressed="true"] {
  border-color: #14662e;
  background: #14662e;
}

.status-absent[aria-pressed="true"] {
  border-color: #a4161a;
  background: #a4161a;
}

.status-excused[aria-pressed="true"] {
  border-color: #7a4a00;
  background: #7a4a00;
}

.panel form + form {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.danger {
  border-color: var(--error);
  background: var(--error);
  color: var(--bg);
}

.student-title {
  overflow-wrap: anywhere;
}

.student-balance {
  font-size: 1.1rem;
}

.balance-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.balance-name {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.balance-amounts {
  flex: 1 1 10rem;
  display: flex;
  flex-direction: column;
}

.owed {
  color: var(--error);
  font-weight: 700;
}

.credit {
  font-weight: 600;
}

.history li {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.history-title {
  font-weight: 600;
}

.history .voided {
  color: var(--muted);
}

.history .voided > :not(.muted) {
  text-decoration: line-through;
}

.void summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--error);
  cursor: pointer;
}

.confirm {
  margin-top: 1rem;
}

.narrow select,
.narrow input {
  max-width: 100%;
}