:root {
  --ink: #0b0b0b;
  --paper: #f4f1e9;
  --paper2: #ebe7dc;
  --white: #fffdf8;
  --gold: #f9aa24;
  --line: #d5d0c5;
  --muted: #726e65;
  --danger: #b3261e;
  --success: #18794e;
  font-family: Arial, Helvetica, sans-serif
}

* {
  box-sizing: border-box
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--ink)
}

body {
  color: var(--ink);
  -webkit-font-smoothing: antialiased
}

button,
input,
textarea,
select {
  font: inherit
}

button {
  cursor: pointer
}

.is-hidden {
  display: none !important
}

.device-shell {
  width: 100%;
  max-width: 820px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
  overflow: hidden
}

.brand-header,
.chat-header,
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between
}

.brand-header {
  padding: max(24px, env(safe-area-inset-top)) 22px 18px
}

.brand-logo {
  display: block;
  width: 118px;
  height: auto
}

.demo-pill,
.code-badge {
  border: 1px solid rgba(11, 11, 11, .18);
  padding: 7px 9px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em
}

.demo-pill.inverse {
  color: var(--gold);
  border-color: rgba(249, 170, 36, .45)
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 11px;
  line-height: 1;
  letter-spacing: .16em;
  font-weight: 800
}

.eyebrow.gold {
  color: var(--gold)
}

.access-hero {
  padding: 44px 22px 28px
}

.access-hero h1,
.login-copy h1,
.dashboard-header h1 {
  margin: 0;
  font-size: clamp(46px, 13vw, 78px);
  line-height: .92;
  letter-spacing: -.055em;
  font-weight: 800
}

.access-hero .lead {
  max-width: 390px;
  margin: 22px 0 0;
  font-size: 17px;
  line-height: 1.42;
  color: var(--muted)
}

.code-form {
  padding: 22px;
  border-top: 1px solid var(--line)
}

.field-label {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase
}

.field-label.light {
  color: var(--white)
}

.code-input,
.text-input {
  width: 100%;
  border: 1px solid var(--ink);
  background: transparent;
  outline: none
}

.code-input {
  height: 72px;
  padding: 0 16px;
  font: 800 28px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
  border-width: 0 0 2px;
  border-radius: 0
}

.code-input:focus {
  border-color: var(--gold);
  box-shadow: inset 0 -2px var(--gold)
}

.field-hint {
  margin: 9px 0 22px;
  color: var(--muted);
  font-size: 12px
}

.primary-btn {
  width: 100%;
  min-height: 58px;
  border: 0;
  background: var(--gold);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-weight: 800;
  font-size: 15px
}

.dark-btn {
  background: var(--ink);
  color: var(--white)
}

.form-error {
  min-height: 19px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.35;
  margin: 12px 0 0
}

.access-footer {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: max(18px, env(safe-area-inset-bottom));
  font-size: 11px;
  color: var(--muted)
}

.student-shell {
  background: var(--white)
}

.chat-view {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--white)
}

.chat-header {
  padding: max(14px, env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, .96);
  z-index: 2;
  gap: 10px
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0
}

.chat-brand-logo {
  width: 72px
}

.chat-heading {
  min-width: 0
}

.chat-title {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30vw
}

.chat-status {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success)
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px
}

.code-badge {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .06em
}

.chat-exit-btn {
  height: 34px;
  border: 1px solid var(--ink);
  background: transparent;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 14px 20px;
  scroll-behavior: smooth
}

.message-row {
  display: flex;
  margin: 0 0 14px
}

.message-row.user {
  justify-content: flex-end
}

.message-bubble {
  max-width: 88%;
  padding: 13px 14px;
  font-size: 15.5px;
  line-height: 1.48;
  word-break: break-word
}

.message-row.assistant .message-bubble {
  background: var(--paper2);
  border-radius: 2px 18px 18px 18px
}

.message-row.user .message-bubble {
  background: var(--ink);
  color: var(--white);
  border-radius: 18px 2px 18px 18px
}

.message-row.user .message-content {
  white-space: pre-wrap
}

.message-meta {
  font-size: 10px;
  margin-top: 6px;
  opacity: .55
}

.message-content.markdown>:first-child {
  margin-top: 0
}

.message-content.markdown>:last-child {
  margin-bottom: 0
}

.message-content.markdown p {
  margin: 0 0 10px
}

.message-content.markdown h2,
.message-content.markdown h3,
.message-content.markdown h4,
.message-content.markdown h5 {
  margin: 14px 0 7px;
  line-height: 1.2
}

.message-content.markdown h2 {
  font-size: 20px
}

.message-content.markdown h3 {
  font-size: 18px
}

.message-content.markdown h4,
.message-content.markdown h5 {
  font-size: 16px
}

.message-content.markdown ul,
.message-content.markdown ol {
  margin: 7px 0 11px;
  padding-left: 22px
}

.message-content.markdown li {
  margin: 4px 0
}

.message-content.markdown blockquote {
  margin: 9px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--gold);
  background: rgba(255, 255, 255, .48);
  color: #4d4942
}

.message-content.markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .9em;
  background: rgba(11, 11, 11, .08);
  padding: 1px 4px;
  border-radius: 4px
}

.message-content.markdown pre {
  margin: 9px 0 11px;
  padding: 11px 12px;
  overflow-x: auto;
  background: var(--ink);
  color: var(--white);
  border-radius: 8px
}

.message-content.markdown pre code {
  display: block;
  min-width: max-content;
  padding: 0;
  background: transparent;
  color: inherit;
  white-space: pre;
  font-size: 12.5px;
  line-height: 1.5
}

.message-content.markdown a {
  color: inherit;
  font-weight: 700
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 18px
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite
}

.typing i:nth-child(2) {
  animation-delay: .16s
}

.typing i:nth-child(3) {
  animation-delay: .32s
}

@keyframes blink {

  0%,
  80%,
  100% {
    opacity: .25
  }

  40% {
    opacity: 1;
    transform: translateY(-2px)
  }
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
  align-items: end;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--white);
  z-index: 2
}

.composer textarea {
  resize: none;
  max-height: 160px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  outline: none;
  padding: 13px 14px;
  line-height: 1.35
}

.composer button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--gold);
  color: var(--ink);
  font-size: 24px;
  font-weight: 700
}

.completion-card {
  position: relative;
  z-index: 2;
  background: var(--gold);
  padding: 16px 18px max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 13px;
  align-items: center;
  border-top: 1px solid rgba(11, 11, 11, .18);
  box-shadow: none
}

.completion-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 900
}

.completion-card h2 {
  margin: 0 0 6px;
  font-size: 24px
}

.completion-card p:last-child {
  margin: 0;
  font-size: 13px
}

.completion-card .eyebrow {
  margin-bottom: 7px
}

.trainer-login {
  min-height: 100dvh;
  background: var(--ink);
  color: var(--white);
  position: relative
}

.dark-header {
  background: var(--ink)
}

.login-copy {
  padding: 52px 22px 26px
}

.login-copy p:last-child {
  color: #aaa79f;
  line-height: 1.5;
  font-size: 16px;
  max-width: 460px
}

.login-form {
  padding: 26px 22px max(28px, env(safe-area-inset-bottom));
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid #31312f
}

.text-input {
  height: 56px;
  padding: 0 14px;
  margin-bottom: 16px
}

.dark-input {
  color: var(--white);
  border-color: #4a4945;
  background: #161616
}

.light-error {
  color: #ff9a94
}

.dashboard {
  min-height: 100dvh;
  padding-bottom: max(32px, env(safe-area-inset-bottom))
}

.dashboard-header {
  background: var(--ink);
  color: var(--white);
  padding: max(28px, env(safe-area-inset-top)) 22px 26px;
  align-items: flex-end
}

.dashboard-header h1 {
  font-size: clamp(42px, 10vw, 70px)
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid #4b4a46;
  color: var(--white);
  background: transparent;
  font-size: 20px
}

.create-panel {
  background: var(--gold);
  padding: 21px 22px 22px
}

.section-kicker {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  margin-bottom: 14px
}

.counter-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between
}

.counter-value {
  font-size: 66px;
  line-height: .9;
  font-weight: 800;
  letter-spacing: -.06em
}

.counter-label {
  margin-top: 8px;
  font-size: 13px
}

.stepper {
  display: flex;
  gap: 7px
}

.stepper button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(11, 11, 11, .65);
  background: transparent;
  font-size: 25px
}

.create-panel input[type=range] {
  width: 100%;
  margin: 25px 0 22px;
  accent-color: var(--ink)
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line)
}

.stat-card {
  min-height: 118px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between
}

.stat-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em
}

.stat-card strong {
  font-size: 36px;
  letter-spacing: -.05em
}

.gold-card {
  background: var(--gold)
}

.gold-card span {
  color: var(--ink)
}

.batch-section {
  padding: 26px 16px 32px
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px
}

.section-head h2 {
  margin: 0;
  font-size: 29px;
  letter-spacing: -.045em
}

.section-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end
}

.text-btn {
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  padding: 0 0 3px;
  font-size: 12px;
  font-weight: 700
}

.text-btn:disabled {
  opacity: .35
}

.batch-select {
  width: 100%;
  margin: 18px 0 8px;
  height: 45px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  padding: 0 11px
}

.mode-note {
  color: var(--muted);
  font-size: 11px;
  margin: 8px 0 14px;
  word-break: break-word
}

.participants-list {
  border-top: 1px solid var(--ink)
}

.participant-row {
  display: grid;
  grid-template-columns: minmax(95px, .9fr) 1.2fr auto;
  gap: 10px;
  align-items: center;
  min-height: 78px;
  border-bottom: 1px solid var(--line)
}

.participant-code {
  font: 800 18px/1 ui-monospace, monospace;
  letter-spacing: .08em
}

.participant-status {
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px
}

.participant-detail {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.row-actions {
  display: flex;
  gap: 5px
}

.mini-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--white);
  font-size: 15px
}

.status-new {
  color: var(--muted)
}

.status-active {
  color: #9b6b00
}

.status-done {
  color: var(--success)
}

.empty-state {
  padding: 30px 2px;
  color: var(--muted);
  line-height: 1.5
}

.modal-open {
  overflow: hidden
}

.codes-modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  background: rgba(11, 11, 11, .55)
}

.codes-modal-panel {
  height: 100dvh;
  background: var(--paper);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto
}

.codes-modal-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: max(24px, env(safe-area-inset-top)) 18px 18px;
  background: var(--ink);
  color: var(--white)
}

.codes-modal-header .section-kicker {
  color: var(--gold);
  margin-bottom: 9px
}

.codes-modal-header h2 {
  margin: 0;
  font-size: 34px
}

.modal-close-btn {
  width: 44px;
  height: 44px;
  border: 1px solid #4b4a46;
  background: transparent;
  color: var(--white);
  font-size: 28px
}

.codes-modal-meta {
  margin: 0;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px
}

.codes-grid {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  padding: 12px 12px 20px
}

.code-tile {
  min-width: 0;
  min-height: 92px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--white);
  padding: 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between
}

.code-tile.is-copied {
  border-color: var(--ink);
  background: var(--gold)
}

.code-index {
  font-size: 9px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: .12em
}

.code-tile strong {
  font: 800 18px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: .08em
}

.code-copy-state {
  font-size: 9px;
  color: var(--muted)
}

.codes-modal-footer {
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper)
}

@media(min-width:600px) {
  .codes-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr))
  }
}

@media(min-width:900px) {
  body {
    padding: 20px 0
  }

  .device-shell {
    min-height: calc(100dvh - 40px);
    max-height: calc(100dvh - 40px);
    border-radius: 18px
  }

  .chat-view,
  .trainer-login {
    height: calc(100dvh - 40px);
    min-height: calc(100dvh - 40px)
  }

  .codes-modal {
    top: 20px;
    bottom: 20px;
    height: calc(100dvh - 40px);
    border-radius: 18px;
    overflow: hidden
  }

  .codes-modal-panel {
    height: calc(100dvh - 40px)
  }
}

@media(max-width:380px) {

  .access-hero h1,
  .login-copy h1 {
    font-size: 44px
  }

  .participant-row {
    grid-template-columns: 95px 1fr auto
  }

  .participant-code {
    font-size: 16px
  }

  .chat-brand-logo {
    width: 62px
  }

  .chat-title {
    max-width: 25vw;
    font-size: 12px
  }

  .code-badge {
    padding: 7px 5px;
    font-size: 8px
  }

  .chat-exit-btn {
    padding: 0 7px
  }

  .section-actions {
    gap: 8px
  }
}

/* Trainer ranking */
.ranking-section {
  padding: 26px 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--white)
}

.ranking-head {
  align-items: flex-end
}

.ranking-note {
  max-width: 120px;
  text-align: right;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35
}

.ranking-table-wrap {
  margin-top: 18px;
  border-top: 1px solid var(--ink);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px
}

.ranking-table th {
  padding: 9px 6px;
  text-align: left;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line)
}

.ranking-table td {
  padding: 11px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle
}

.ranking-table th:nth-child(1),
.ranking-table td:nth-child(1) {
  width: 30px;
  text-align: center
}

.ranking-table th:nth-child(2),
.ranking-table td:nth-child(2) {
  width: 92px
}

.ranking-table th:nth-child(3),
.ranking-table td:nth-child(3) {
  width: 70px
}

.ranking-table th:nth-child(4),
.ranking-table td:nth-child(4) {
  width: 48px;
  text-align: center
}

.ranking-table th:nth-child(5),
.ranking-table td:nth-child(5) {
  width: 66px;
  text-align: right
}

.rank-place {
  font-weight: 900
}

.ranking-code {
  font: 800 12px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: .05em
}

.ranking-table tr.rank-1 {
  background: rgba(249, 170, 36, .2)
}

.ranking-table tr.rank-1 .rank-place {
  font-size: 17px
}

.ranking-dialog-btn {
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  padding: 2px 0;
  font-size: 10px;
  font-weight: 800
}

.ranking-empty {
  padding: 22px 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45
}

.mini-btn:disabled {
  opacity: .25;
  cursor: default
}

/* Trainer dialog viewer */
.dialog-modal {
  position: fixed;
  z-index: 55;
  inset: 0;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  background: rgba(11, 11, 11, .55)
}

.dialog-modal-panel {
  height: 100dvh;
  background: var(--paper);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr)
}

.dialog-modal-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: max(24px, env(safe-area-inset-top)) 18px 18px;
  background: var(--ink);
  color: var(--white)
}

.dialog-modal-header .section-kicker {
  color: var(--gold);
  margin-bottom: 9px
}

.dialog-modal-header h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -.04em
}

.dialog-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--white)
}

.dialog-summary>div {
  min-width: 0;
  padding: 11px 10px;
  border-right: 1px solid var(--line)
}

.dialog-summary>div:last-child {
  border-right: 0
}

.dialog-summary span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 5px
}

.dialog-summary strong {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.trainer-dialog-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 12px max(24px, env(safe-area-inset-bottom));
  overscroll-behavior: contain;
  background: var(--paper)
}

.dialog-loading {
  padding: 24px 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center
}

.trainer-dialog-row {
  margin: 0 0 16px
}

.trainer-dialog-label {
  margin: 0 0 5px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted)
}

.trainer-dialog-row.user .trainer-dialog-label {
  text-align: right
}

.trainer-dialog-bubble {
  max-width: 90%;
  padding: 12px 13px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word
}

.trainer-dialog-row.assistant .trainer-dialog-bubble {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 2px 16px 16px 16px
}

.trainer-dialog-row.user .trainer-dialog-bubble {
  margin-left: auto;
  background: var(--ink);
  color: var(--white);
  border-radius: 16px 2px 16px 16px
}

.trainer-dialog-bubble .plain-text {
  white-space: pre-wrap
}

.trainer-dialog-time {
  margin-top: 7px;
  font-size: 9px;
  opacity: .5
}

@media(min-width:900px) {
  .dialog-modal {
    top: 20px;
    bottom: 20px;
    height: calc(100dvh - 40px);
    border-radius: 18px;
    overflow: hidden
  }

  .dialog-modal-panel {
    height: calc(100dvh - 40px)
  }
}

@media(max-width:380px) {
  .ranking-section {
    padding-left: 12px;
    padding-right: 12px
  }

  .ranking-table {
    font-size: 11px
  }

  .ranking-table th,
  .ranking-table td {
    padding-left: 4px;
    padding-right: 4px
  }

  .ranking-table th:nth-child(2),
  .ranking-table td:nth-child(2) {
    width: 82px
  }

  .ranking-table th:nth-child(5),
  .ranking-table td:nth-child(5) {
    width: 58px
  }

  .ranking-dialog-btn {
    font-size: 9px
  }

  .dialog-summary strong {
    font-size: 11px
  }
}

.retry-card {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 14px 12px max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center
}

.retry-card .eyebrow {
  margin-bottom: 6px
}

.retry-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px
}

.retry-card p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4
}

.retry-card button {
  min-width: 94px;
  height: 42px;
  border: 0;
  background: var(--gold);
  font-weight: 800;
  padding: 0 12px
}

.retry-card button:disabled {
  opacity: .55
}

.dialog-modal-panel {
  grid-template-rows: auto auto auto minmax(0, 1fr)
}

.judge-diagnostics {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff8dd;
  font-size: 11px;
  line-height: 1.45
}

.judge-diagnostics summary {
  cursor: pointer;
  font-weight: 900;
  letter-spacing: .03em
}

.judge-diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin-top: 9px
}

.judge-check {
  display: flex;
  justify-content: space-between;
  gap: 8px
}

.judge-check span:first-child {
  color: var(--muted)
}

.judge-ok {
  color: var(--success);
  font-weight: 800
}

.judge-fail {
  color: #9b2c2c;
  font-weight: 800
}

.judge-meta {
  margin-top: 8px;
  color: var(--muted);
  word-break: break-word
}

.judge-error {
  margin-top: 7px;
  color: #9b2c2c;
  word-break: break-word
}


/* v11.2 trainer batch navigation */
.batch-picker-section {
  padding: 24px 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper)
}

.batch-picker-section .section-head {
  align-items: flex-end
}

.batch-picker-section .section-head h2 {
  margin: 0;
  font-size: 29px;
  letter-spacing: -.045em
}

.batch-picker-section .batch-select {
  margin: 14px 0 8px
}

.batch-picker-section .mode-note {
  margin-bottom: 0
}

.batch-section {
  background: var(--paper)
}

.ranking-section {
  border-top: 1px solid var(--line);
  border-bottom: 0
}

.batch-section+.ranking-section {
  margin-top: 0
}

@media(max-width:380px) {
  .batch-picker-section {
    padding-left: 12px;
    padding-right: 12px
  }

  .batch-picker-section .section-head h2 {
    font-size: 26px
  }
}



/* v11.7 iOS chat viewport */
html.student-page {
  --student-safe-bottom: env(safe-area-inset-bottom, 0px);
  min-height: 100%;
  background: #f7f5ee
}

html.student-page body {
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  background: #f7f5ee
}

/* Login is a normal document. Safari may scroll/pan it to keep the focused code input visible. */
html.student-page:not(.student-chat-active),
html.student-page:not(.student-chat-active) body {
  height: auto;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior-y: auto
}

html.student-page:not(.student-chat-active) #loginScreen {
  height: auto;
  min-height: 100dvh;
  max-height: none;
  box-sizing: border-box;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px)
}

/* Only the authenticated chat behaves like a fixed mobile app shell. */
html.student-page.student-chat-active {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none
}

html.student-page.student-chat-active body {
  width: 100%;
  height: var(--student-chat-height, 100dvh);
  min-height: 0;
  max-height: var(--student-chat-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none
}

html.student-page.student-chat-active #chatScreen {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px)
}

html.student-page.student-chat-active #messages {
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch
}

html.student-page.student-chat-active #composer,
html.student-page.student-chat-active #retryCard,
html.student-page.student-chat-active #completionCard {
  padding-bottom: max(12px, var(--student-safe-bottom))
}

html.student-page.student-chat-active.student-keyboard-open {
  --student-safe-bottom: 0px
}

@supports not (height:100dvh) {
  html.student-page body {
    min-height: 100%
  }

  html.student-page:not(.student-chat-active) #loginScreen {
    min-height: 100%
  }

  html.student-page.student-chat-active body {
    height: var(--student-chat-height, 100%);
    max-height: var(--student-chat-height, 100%)
  }
}

/* Student-only control normalization. DO NOT target generic .logout-button:
   the trainer cabinet uses shared CSS and v12.1 accidentally recolored its exit icon. */
#studentLogoutButton.student-exit-btn {
  -webkit-appearance: none;
  appearance: none;
  color: inherit;
  -webkit-text-fill-color: currentColor;
  text-decoration: none;
  font: inherit;
  opacity: 1;
}

.primary-btn,
#sendButton {
  -webkit-appearance: none;
  appearance: none;
  font: inherit
}

.button-arrow-icon,
.send-arrow-icon {
  display: block;
  flex: 0 0 auto;
  color: currentColor;
  pointer-events: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round
}

.button-arrow-icon {
  width: 1.35em;
  height: 1.35em;
  margin-left: auto
}

.send-arrow-icon {
  width: 1.55em;
  height: 1.55em;
  margin: auto
}
