:root {
  --ink: #171716;
  --ink-hover: #2b2b29;
  --muted: #74746f;
  --muted-strong: #5f5f5b;
  --paper: #fbfbf9;
  --surface: #ffffff;
  --line: #e6e6e1;
  --line-strong: #cecec7;
  --green: #176b59;
  --green-soft: #edf4f1;
  --green-line: #d8e8e1;
  --red: #9f302d;
  --red-soft: #f9eceb;
  --red-line: #edd7d5;
  --gray-soft: #f0f0ed;
  --focus: #1d7765;
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 14px;
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

[hidden]{display:none!important}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select { font: inherit; }

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

form[aria-busy="true"] { cursor: progress; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.site-header {
  position: relative;
  z-index: 2;
  min-height: 78px;
  padding: 0 clamp(20px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  animation: header-enter 420ms cubic-bezier(.22, 1, .36, 1) both;
}

.wordmark {
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -.055em;
  text-decoration: none;
}

.wordmark:hover { opacity: .68; }

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 720;
}

.profile-link,
.site-header > a:last-child {
  color: var(--ink);
  text-decoration: none;
}

.profile-link:hover,
.site-header > a:last-child:hover { color: var(--green); }

.profile form { margin: 0; }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
}

.page {
  width: min(1160px, calc(100% - 48px));
  margin: 0 auto;
  padding: clamp(72px, 8vw, 112px) 0 104px;
  animation: page-enter 520ms 70ms cubic-bezier(.22, 1, .36, 1) both;
}

.queue-page { padding-top: clamp(48px, 6vw, 88px); }

#queue-content {
  margin-top: clamp(48px, 6vw, 72px);
  view-transition-name: queue-content;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.page > h1,
.auth-panel h1 {
  margin: 0;
  font-size: clamp(54px, 8vw, 92px);
  font-weight: 850;
  line-height: .94;
  letter-spacing: -.065em;
}

.section-heading {
  min-height: 42px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 820;
  letter-spacing: -.03em;
}

.count {
  min-width: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  background: var(--surface);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.mine-section { margin-top: 64px; }

#queue-content > .mine-section { margin-top: 0; }

.add-button,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.add-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

.add-button:hover,
.icon-button:hover { background: var(--gray-soft); }

.add-button[aria-expanded="true"] {
  color: var(--surface);
  background: var(--ink);
  transform: rotate(45deg);
}

.add-form {
  margin-bottom: 14px;
  padding: 12px;
  display: flex;
  gap: 10px;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  border-radius: var(--radius-md);
  transform-origin: top;
  animation: reveal-form 180ms ease-out both;
}

.add-form label { flex: 1; }
.add-form input { width: 100%; }

.mine-list {
  display: grid;
  gap: 8px;
}

.mine-row {
  min-height: 100px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--green-line);
  border-radius: var(--radius-md);
  background: var(--green-soft);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.mine-row.state-red {
  border-color: var(--red-line);
  background: var(--red-soft);
}

.mine-lab,
.student {
  margin: 0;
  font-weight: 800;
  letter-spacing: -.025em;
}

.mine-lab {
  font-size: 22px;
  line-height: 1.15;
}

.mine-lab span {
  margin-left: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.meta,
.empty {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.empty {
  min-height: 76px;
  margin: 0;
  padding: 25px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.row-actions form { margin: 0; }

.action-note {
  max-width: 172px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.button {
  min-height: 42px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 760;
  cursor: pointer;
  transition: transform 130ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0) scale(.98); }

.button:disabled {
  cursor: not-allowed;
  opacity: .42;
  transform: none;
}

.button::after {
  width: 0;
  height: 14px;
  border: 0 solid currentColor;
  border-radius: 50%;
  content: "";
  opacity: 0;
  transition: width 160ms ease, opacity 160ms ease, border-width 160ms ease;
}

form[aria-busy="true"] .button:disabled { opacity: .72; }

form[aria-busy="true"] .button::after {
  width: 14px;
  border-width: 2px;
  border-right-color: transparent;
  opacity: .72;
  animation: button-spin 650ms linear infinite;
}

.button-primary {
  background: var(--ink);
  color: #fff;
}

.button-primary:hover:not(:disabled) { background: var(--ink-hover); }

.button-quiet {
  background: transparent;
  color: var(--red);
}

.button-quiet:hover:not(:disabled) {
  border-color: var(--red-line);
  background: rgba(255, 255, 255, .5);
}

.icon-button {
  min-width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 21px;
  line-height: 1;
}

.queue-section { margin-top: 58px; }

.queue-list {
  margin: 0;
  padding: 0;
  display: grid;
  list-style: none;
}

.queue-row {
  position: relative;
  min-height: 88px;
  padding: 16px 12px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 18px;
  border-top: 1px solid var(--line);
  transition: background-color 160ms ease;
}

.queue-row:nth-child(n + 12) {
  content-visibility: auto;
  contain-intrinsic-size: auto 88px;
}

.queue-row:last-child { border-bottom: 1px solid var(--line); }

.queue-row:hover { background: rgba(240, 240, 237, .55); }

.queue-row.state-red {
  border-color: var(--red-line);
  background: var(--red-soft);
}

.queue-row.state-red + .queue-row { border-top-color: transparent; }

.queue-row.state-gray {
  color: var(--muted-strong);
  background: var(--gray-soft);
}

.position {
  font-size: 25px;
  font-weight: 430;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.045em;
}

.student {
  overflow: hidden;
  font-size: 17px;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  justify-self: center;
  background: #d1d1cb;
}

.state-waiting .state-dot { background: var(--green); }
.state-red .state-dot { background: var(--red); }
.state-gray .state-dot { background: #959590; }

.queue-row:first-child.state-waiting .state-dot {
  box-shadow: 0 0 0 5px var(--green-soft);
  animation: current-pulse 2.4s ease-out infinite;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 10;
  width: max-content;
  max-width: min(520px, calc(100% - 32px));
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  transform: translateX(-50%);
  animation: toast-in 180ms ease-out both;
}

.auth-page {
  min-height: 100vh;
  background: var(--surface);
}

.auth-shell {
  width: min(620px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(80px, 15vh, 160px) 0 80px;
  animation: auth-enter 560ms cubic-bezier(.22, 1, .36, 1) both;
}

.auth-shell > .wordmark {
  display: block;
  margin-bottom: clamp(64px, 9vh, 96px);
}

.auth-panel {
  padding-top: 48px;
  border-top: 1px solid var(--line-strong);
}

.auth-panel h1 {
  margin-bottom: 38px;
  font-size: 64px;
}

.form {
  display: grid;
  gap: 22px;
}

.form-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form label {
  display: grid;
  gap: 9px;
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 700;
}

.form input,
.add-form input,
.row-actions input,
.admin-user select {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.form input:hover,
.add-form input:hover,
.row-actions input:hover,
.admin-user select:hover { border-color: #aaa9a2; }

.form input:focus,
.add-form input:focus,
.row-actions input:focus,
.admin-user select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(29, 119, 101, .12);
}

.form .button {
  min-height: 54px;
  margin-top: 8px;
}

.admin-user { grid-template-columns: 58px minmax(0, 1fr) auto; }

.admin-user .row-actions form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-user select {
  min-height: 40px;
  padding-right: 34px;
}

.link-list {
  margin: 10px 0 18px;
  display: grid;
  gap: 7px;
}

.link-list > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-list code {
  min-width: 0;
  padding: 12px 14px;
  flex: 1;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--green);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.invite-history { margin-top: 20px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes header-enter {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes auth-enter {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes reveal-form {
  from { opacity: 0; transform: translateY(-5px) scaleY(.97); }
  to { opacity: 1; transform: translateY(0) scaleY(1); }
}

@keyframes current-pulse {
  0%, 58%, 100% { box-shadow: 0 0 0 5px var(--green-soft); }
  74% { box-shadow: 0 0 0 9px rgba(237, 244, 241, 0); }
}

@keyframes button-spin { to { transform: rotate(1turn); } }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

::view-transition-old(root),
::view-transition-new(root) { animation: none; }

::view-transition-old(queue-content) {
  animation: queue-leave 120ms ease-in both;
}

::view-transition-new(queue-content) {
  animation: queue-enter 220ms cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes queue-leave {
  to { opacity: 0; transform: translateY(-3px); }
}

@keyframes queue-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .admin-user {
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: start;
  }

  .admin-user > .row-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .admin-user .row-actions,
  .admin-user .row-actions form { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .site-header {
    min-height: 66px;
    padding: 0 18px;
  }

  .profile { gap: 7px; }
  .profile > span:first-child { display: none; }

  .avatar {
    width: 36px;
    height: 36px;
  }

  .page {
    width: calc(100% - 28px);
    padding: 44px 0 64px;
  }

  .queue-page { padding-top: 24px; }
  .page > h1 { font-size: 58px; }
  .mine-section { margin-top: 42px; }
  #queue-content > .mine-section { margin-top: 0; }

  .section-heading { margin-bottom: 11px; }

  .mine-row {
    padding: 16px;
    align-items: flex-start;
  }

  .mine-lab { font-size: 19px; }

  .row-actions {
    max-width: 52%;
    flex-wrap: wrap;
  }

  .action-note { text-align: right; }

  .queue-section { margin-top: 44px; }

  .queue-row {
    min-height: 76px;
    padding: 13px 5px;
    grid-template-columns: 39px minmax(0, 1fr) 15px;
    gap: 10px;
  }

  .position { font-size: 19px; }
  .student { font-size: 15px; }
  .meta { font-size: 11px; }

  .add-form {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    margin: 0;
    padding: 18px max(18px, calc((100vw - 560px) / 2));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -18px 48px rgba(23, 23, 22, .12);
  }

  .add-form .button { padding-inline: 14px; }

  .form-pair { grid-template-columns: 1fr; }

  .auth-shell { padding-top: 10vh; }
  .auth-shell > .wordmark { margin-bottom: 64px; }
  .auth-panel { padding-top: 38px; }
  .auth-panel h1 { font-size: 54px; }
}

@media (max-width: 430px) {
  .mine-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .row-actions {
    width: 100%;
    max-width: none;
    justify-content: flex-start;
  }

  .action-note { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation-duration: .01ms !important; }
}
