:root {
  color-scheme: dark;
  --background: #11100f;
  --surface: #1b1815;
  --surface-light: #241e17;
  --border: #3a3022;
  --border-strong: #6e5230;
  --gold: #f0c574;
  --ink: #f6eee1;
  --muted: #bdb09f;
  --gutter: clamp(16px, 4vw, 48px);
  font: 16px/1.45 system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 0, #302318, transparent 39rem), var(--background);
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input { font: inherit; }
button, summary { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

h1, h2 {
  margin: 0;
  color: var(--ink);
  font: 600 clamp(1.875rem, 4.6vw, 3.5rem)/1.05 Georgia, serif;
  overflow-wrap: anywhere;
}
h2 { font-size: clamp(1.375rem, 3vw, 1.85rem); }
p { margin: .875rem 0 0; }
.sr-only {
  position: absolute;
  inset-inline-start: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.frame {
  width: min(100%, 1240px);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: .55rem .925rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  font-weight: 680;
  text-align: center;
  text-decoration: none;
}
.primary {
  border-color: #f6d18f;
  background: linear-gradient(180deg, #f5d18e, #d9a34f);
  color: #221507;
  box-shadow: inset 0 1px #fff7, 0 .25rem .55rem #0004;
}
.primary:hover { background: #f7d99c; }
.secondary { border-color: var(--border); color: var(--ink); background: #1a1713; }
.secondary:is(:hover, [aria-current]) { border-color: var(--border-strong); color: var(--gold); }

.login-page {
  display: grid;
  min-height: 100dvh;
  padding: var(--gutter);
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 25%, #42301d 0, transparent 50%),
    radial-gradient(ellipse at 20% 100%, #24190e 0, transparent 32%), #100e0c;
}
.login-card {
  width: min(100%, 26rem);
  padding: clamp(1.25rem, 5.5vw, 2.75rem);
  border: 1px solid var(--border-strong);
  border-radius: 1rem;
  background: linear-gradient(155deg, #241c15, #141211 80%);
  box-shadow: inset 0 1px #f1ce7c25, 0 1.75rem 5rem #0008;
}
.login-logo {
  width: min(100%, 17rem);
  height: auto;
  max-height: 11rem;
  object-fit: contain;
  margin: 0 auto 2rem;
  filter: drop-shadow(0 .3rem .5rem #0008);
}
.form-stack { display: grid; gap: .45rem; }
.form-stack label { color: var(--ink); font-size: .92rem; font-weight: 650; }
.form-stack input:not([type="hidden"]) {
  width: 100%;
  min-height: 45px;
  margin-bottom: .65rem;
  padding: .625rem .75rem;
  border: 1px solid var(--border-strong);
  border-radius: .5rem;
  background: #100e0d;
  color: var(--ink);
}
.form-stack .primary { margin-top: .35rem; min-height: 45px; }
.feedback {
  padding: .65rem .8rem;
  border: 1px solid;
  border-radius: .5rem;
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
}
.form-stack .feedback { margin: 0; }
.feedback.error { color: #ffcbba; background: #4a241a; border-color: #a4543f; }
.feedback.success { color: #e0f1d0; background: #263420; border-color: #4b713c; }

.site-header { border-bottom: 1px solid var(--border-strong); background: #17130fe6; }
.header-bar {
  display: flex;
  gap: 1rem;
  min-height: 5.4rem;
  align-items: center;
  justify-content: space-between;
  padding-block: .75rem;
}
.brand { flex: 0 1 auto; min-width: 0; }
.brand img { width: 132px; max-height: 68px; object-fit: contain; }
.account-bar { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.account-name { padding-inline: .25rem; color: var(--muted); overflow-wrap: anywhere; }
.class-nav { padding-block: .8rem 1.2rem; }
.class-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: .45rem;
  margin: 0;
  padding: 0;
  list-style-type: none;
}
.class-link {
  display: flex;
  height: 100%;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: .4rem;
  padding: .65rem .15rem;
  border: 1px solid var(--border);
  border-radius: .62rem;
  background: linear-gradient(150deg, #272019, #1b1813);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 670;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.class-link img {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: .44rem;
  object-fit: contain;
  background: #100d0a;
}
.class-link:is(:hover, [aria-current]) { border-color: var(--class-accent, var(--gold)); color: var(--ink); }
.class-link[aria-current] { box-shadow: inset 0 -2px var(--class-accent, var(--gold)); }
.main-content { padding-block: clamp(1.5rem, 5vw, 4rem); }
.panel {
  border: 1px solid var(--border);
  border-radius: .9rem;
  background: linear-gradient(125deg, var(--surface-light), var(--surface) 72%);
  box-shadow: 0 .7rem 2.2rem #0002;
}
.select-panel, .class-panel, .admin-panel { padding: clamp(1.15rem, 4vw, 2.25rem); }
.select-panel p, .class-panel p { color: var(--muted); }
.class-heading { display: flex; align-items: center; gap: .95rem; }
.class-heading img {
  width: clamp(46px, 7vw, 66px);
  height: auto;
  border: 1px solid var(--border-strong);
  border-radius: .6rem;
}
.subnav { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.35rem; }
.subnav a {
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: .45rem;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}
.subnav a:is(:hover, [aria-current]) { border-color: var(--border-strong); color: var(--gold); }
.subnav a[aria-current] { background: #17130f; }
.class-content { margin-top: 1.25rem; }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  align-items: start;
  gap: 1rem;
  margin-top: 1.5rem;
}
.add-panel h2 { margin-bottom: 1.1rem; }
.user-list { margin: .6rem 0 0; padding: 0; list-style: none; }
.user-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: .4rem 1rem;
  padding: .85rem 0;
  border-bottom: 1px solid var(--border);
}
.user-entry:last-child { border-bottom: 0; padding-bottom: 0; }
.user-entry:has(details[open]) { grid-template-columns: minmax(0, 1fr); }
.user-identity { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; overflow-wrap: anywhere; }
.user-identity span { color: var(--gold); font-size: .8rem; }
.user-entry summary { position: relative; color: var(--gold); font-size: .9rem; }
.reset-form { margin-top: .75rem; max-width: 24rem; }

@media (max-width: 850px) {
  .class-list { grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); }
}
@media (max-width: 650px) {
  .header-bar { gap: .45rem; }
  .brand img { width: 102px; }
  .account-name { display: none; }
  .account-bar .button { font-size: .82rem; padding-inline: .6rem; }
  .class-nav { padding-top: .45rem; }
  .class-list { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); }
  .class-link img { width: 35px; height: 35px; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 410px) {
  .class-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 370px) {
  .user-entry { grid-template-columns: minmax(0, 1fr); }
}
