:root {
  --ink: #333333;
  --muted: #68625f;
  --paper: #f5f5ed;
  --card: #ffffff;
  --accent: #b11a16;
  --accent-dark: #8f1512;
  --charcoal: #433e3f;
  --forest: var(--accent);
  --forest-dark: var(--accent-dark);
  --gold: var(--accent);
  --line: #deddd3;
  --danger: #8f1512;
  --shadow: 0 8px 24px rgba(67, 62, 63, .08);
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Georgia, Neuton, "Times New Roman", serif; line-height: 1.55; letter-spacing: .01em; }
a { color: var(--forest); text-underline-offset: .18em; }
a:hover { color: var(--forest-dark); }
h1, h2, h3 { line-height: 1.15; margin-top: 0; color: var(--accent); font-family: Georgia, Neuton, "Times New Roman", serif; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin-bottom: .4rem; }
h2 { font-size: clamp(1.35rem, 3vw, 2rem); }
p { margin-top: 0; }

.skip-link { position: absolute; left: -9999px; top: .5rem; padding: .7rem 1rem; background: white; z-index: 10; }
.skip-link:focus { left: .5rem; }
.environment-banner { padding: .45rem 1rem; color: white; background: var(--accent); font: 700 .78rem/1.4 system-ui, sans-serif; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.site-header { min-height: 158px; display: flex; align-items: center; justify-content: center; padding: .6rem clamp(1rem, 4vw, 3rem); background: white; }
.brand { display: block; width: min(841px, 100%); text-decoration: none; }
.brand-masthead { display: block; width: 100%; height: auto; }
.site-navigation { color: white; background: var(--charcoal); }
.site-navigation-inner { width: min(1140px, calc(100% - 2rem)); min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 auto; }
.site-navigation a, .site-navigation .link-button { color: white; font-family: Georgia, Neuton, serif; font-size: .89rem; letter-spacing: .075em; text-decoration: none; text-transform: uppercase; }
.site-navigation a:hover, .site-navigation .link-button:hover { color: white; background: rgba(255, 255, 255, .1); }
.portal-home, .site-navigation nav > a, .site-navigation .link-button { display: inline-flex; min-height: 48px; align-items: center; padding: .65rem .8rem; }
.site-navigation nav { display: flex; align-items: center; gap: .25rem; }
.site-navigation form { display: inline; margin: 0; }
.signed-in-as { padding: 0 .65rem; color: #e6e1df; font-family: Georgia, Neuton, serif; font-size: .86rem; }
.link-button { border: 0; padding: 0; color: white; background: transparent; font: inherit; text-decoration: underline; cursor: pointer; }
.page-shell { width: min(1140px, calc(100% - 2rem)); min-height: calc(100vh - 300px); margin: 0 auto; padding: clamp(1.5rem, 5vw, 4rem) 0; }
.site-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.6rem max(clamp(1rem, 4vw, 3rem), calc((100vw - 1140px) / 2)); color: white; background: var(--charcoal); font-size: .88rem; }

.flash { margin: 0 0 1.4rem; padding: 1rem 1.2rem; border-radius: 6px; font-weight: 650; }
.flash.notice { color: #183d2c; background: #dcecdf; border: 1px solid #aac9b2; }
.flash.alert { color: #6a1e1e; background: #f4dddd; border: 1px solid #d4aaaa; }
.eyebrow { margin-bottom: .45rem; color: var(--accent); font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.lead { max-width: 700px; color: var(--muted); font-size: 1.12rem; }
.page-heading { margin-bottom: 2rem; }

.auth-card { width: min(620px, 100%); margin: clamp(1rem, 6vw, 5rem) auto; padding: clamp(1.4rem, 5vw, 3rem); background: var(--card); border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--shadow); }
.stacked-form { display: grid; gap: 1.15rem; margin-top: 1.8rem; }
.stacked-form label { display: block; margin-bottom: .4rem; font-weight: 750; }
.stacked-form input:not([type="checkbox"]), .stacked-form select, .stacked-form textarea { width: 100%; min-height: 52px; padding: .7rem .85rem; border: 2px solid #aaa39f; border-radius: 3px; background: white; color: var(--ink); font: inherit; }
.stacked-form input:focus, .stacked-form select:focus, .stacked-form textarea:focus { outline: 3px solid rgba(177, 26, 22, .2); border-color: var(--accent); }
.code-input { letter-spacing: .12em; text-transform: uppercase; font-family: ui-monospace, monospace !important; font-size: 1.15rem !important; }
.field-hint, .help-copy { margin: .45rem 0 0; color: var(--muted); font-size: .9rem; }
.help-copy { margin-top: 1.6rem; }
.primary-button, .watch-button, input.primary-button { display: inline-flex; min-height: 50px; align-items: center; justify-content: center; padding: .7rem 1.25rem; border: 0; border-radius: 3px; color: white; background: var(--accent); font-family: Georgia, Neuton, serif; font-size: 1rem; font-weight: 700; text-decoration: none; cursor: pointer; }
.primary-button:hover, .watch-button:hover { color: white; background: var(--forest-dark); }

.class-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); gap: 1.25rem; }
.class-card { display: flex; min-height: 250px; flex-direction: column; justify-content: space-between; padding: 1.6rem; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--accent); border-radius: 3px; box-shadow: var(--shadow); text-decoration: none; }
.class-card:hover { color: var(--ink); border-color: var(--gold); transform: translateY(-2px); }
.class-card p { color: var(--muted); }
.kind-label { color: var(--forest); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.class-card-footer { display: flex; justify-content: space-between; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .84rem; }
.empty-state { padding: 2rem; background: var(--card); border: 1px solid var(--line); border-radius: 3px; text-align: center; }

.back-link { display: inline-block; margin-bottom: 1.4rem; font-weight: 700; }
.class-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 1.4rem; }
.access-date { flex: 0 0 auto; color: var(--muted); text-align: right; }
.player-section { padding: clamp(.5rem, 2vw, 1rem); background: #171515; border-radius: 3px; color: white; box-shadow: var(--shadow); }
.player-section h2 { margin: 1rem .6rem .3rem; color: white; font-family: Georgia, Neuton, serif; font-size: 1.15rem; }
.video-frame { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: black; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.recording-list { margin-top: 2rem; }
.recording-list ol { padding: 0; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 3px; list-style: none; }
.recording-list li { display: grid; grid-template-columns: 2.2rem 1fr auto auto; align-items: center; gap: 1rem; min-height: 76px; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.recording-list li:last-child { border-bottom: 0; }
.recording-list li.currently-playing { background: #f7eeee; box-shadow: inset 5px 0 var(--accent); }
.recording-number, .duration { color: var(--muted); }
.recording-title { font-weight: 750; }
.playing-label { color: var(--forest); font-size: .85rem; font-weight: 800; }
.watch-button { min-height: 44px; padding: .5rem 1rem; }

.admin-nav { display: flex; gap: .4rem; margin-bottom: 2.5rem; padding-bottom: .8rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.admin-nav a { flex: 0 0 auto; padding: .55rem .8rem; border-radius: 3px; font-weight: 700; text-decoration: none; }
.admin-nav a:hover { color: white; background: var(--forest); }
.admin-heading, .section-heading, .button-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.admin-heading { align-items: flex-end; margin-bottom: 2rem; }
.button-row { justify-content: flex-start; flex-wrap: wrap; }
.button-row form { margin: 0; }
.secondary-button, .danger-button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: .6rem 1rem; border: 1px solid var(--accent); border-radius: 3px; color: var(--accent); background: transparent; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.danger-button { color: var(--danger); border-color: var(--danger); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2rem; }
.stat-grid > div { padding: 1.3rem; background: var(--card); border: 1px solid var(--line); border-radius: 3px; }
.stat-grid strong { display: block; font-family: Georgia, serif; font-size: 2.2rem; }
.stat-grid span { color: var(--muted); }
.admin-section { margin-top: 2.2rem; padding: 1.5rem; background: var(--card); border: 1px solid var(--line); border-radius: 3px; }
.section-heading { align-items: flex-start; margin-bottom: 1rem; }
.section-heading h2, .section-heading p { margin-bottom: .25rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; }
td small { color: var(--muted); }
.status { display: inline-block; padding: .25rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.status.good { color: #174329; background: #dcecdf; }
.status.bad { color: #6a1e1e; background: #f4dddd; }
.status.neutral { color: #514b43; background: #e9e5dd; }
.admin-form { max-width: 850px; padding: 1.5rem; background: var(--card); border: 1px solid var(--line); border-radius: 3px; }
.form-columns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.check-label { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.check-label input { width: 22px; height: 22px; }
.inline-form { display: flex; align-items: end; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; }
.inline-form > div { flex: 1 1 220px; }
.inline-form label { display: block; margin-bottom: .35rem; font-weight: 700; }
.inline-form input, .inline-form select, .compact-form input { width: 100%; min-height: 46px; padding: .55rem .7rem; border: 1px solid #aaa397; border-radius: 5px; background: white; font: inherit; }
.compact-form { display: flex; min-width: 235px; gap: .4rem; }
.compact-form input[type="submit"] { width: auto; cursor: pointer; }
.issued-code { margin: 1.5rem 0; padding: 1.5rem; color: white; background: var(--charcoal); border: 3px solid var(--accent); border-radius: 3px; text-align: center; }
.issued-code p { margin-bottom: .5rem; }
.issued-code strong { font-family: ui-monospace, monospace; font-size: clamp(1.4rem, 5vw, 2.4rem); letter-spacing: .12em; }
.danger-zone { border-color: #d4aaaa; }

@media (max-width: 680px) {
  html { font-size: 17px; }
  .site-header { min-height: 0; padding: .55rem .75rem; }
  .site-navigation-inner, .class-heading, .site-footer { align-items: flex-start; flex-direction: column; }
  .site-navigation-inner { gap: 0; padding: .35rem 0; }
  .site-navigation nav { width: 100%; flex-wrap: wrap; }
  .portal-home { min-height: 42px; }
  .signed-in-as { display: none; }
  .access-date { text-align: left; }
  .recording-list li { grid-template-columns: 1.8rem 1fr auto; gap: .6rem; }
  .duration { display: none; }
  .playing-label, .watch-button { grid-column: 3; }
  .class-card-footer { flex-direction: column; }
  .admin-heading, .section-heading { align-items: flex-start; flex-direction: column; }
  .stat-grid, .form-columns { grid-template-columns: 1fr; }
}
