:root {
  --ink: #14212b;
  --muted: #5e6b76;
  --line: #d7dee4;
  --panel: #ffffff;
  --page: #f4f7f8;
  --navy: #183247;
  --teal: #117c72;
  --teal-dark: #0b5f57;
  --gold: #c8922e;
  --red: #b94242;
  --green: #21845a;
  --shadow: 0 18px 50px rgba(20, 33, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 750;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hidden {
  display: none !important;
}

.view {
  min-height: calc(100vh - 64px);
}

.login-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 32px;
  align-items: center;
}

.brand-block h1,
.top-row h1,
.practice-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.top-row h1,
.practice-header h1 {
  font-size: clamp(1.75rem, 3vw, 3rem);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.55;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.login-panel {
  display: grid;
  gap: 10px;
}

.code-entry {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

label {
  font-weight: 750;
}

input[type="email"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}

.inline-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.inline-entry button,
.primary-button {
  color: #fff;
  background: var(--teal);
}

.primary-button:hover,
.inline-entry button:hover {
  background: var(--teal-dark);
}

.ghost-button {
  color: var(--navy);
  background: #e6edf2;
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.success-button {
  color: #fff;
  background: var(--green);
}

.danger-outline-button {
  color: var(--red);
  background: #faeaea;
}

.small-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.install-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.top-row,
.practice-header,
.action-bar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.section-head {
  margin-bottom: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.button-pair {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.slider {
  width: 100%;
  accent-color: var(--teal);
}

output {
  color: var(--teal);
  font-weight: 850;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.check-card,
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.check-card input,
.toggle-row input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.toggle-row span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
}

.toggle-row small {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.length-button {
  background: #e6edf2;
  color: var(--navy);
}

.length-button.selected {
  color: #fff;
  background: var(--navy);
}

.action-bar {
  padding-top: 8px;
}

.practice-view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
}

.flashcard {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(300px, 1fr);
  gap: 24px;
  align-items: center;
}

.photo-wrap {
  overflow: hidden;
  aspect-ratio: 4 / 5;
  max-height: 68vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dce4ea;
  box-shadow: var(--shadow);
}

.photo-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-details {
  min-height: 280px;
  display: grid;
  align-content: center;
  gap: 14px;
}

.timer-text {
  color: var(--gold);
  font-size: 1.25rem;
  font-weight: 850;
}

.student-name {
  font-size: clamp(2.5rem, 6vw, 5rem);
  line-height: 1;
  font-weight: 900;
}

.student-info {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
}

.answer-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.answer-controls button {
  min-height: 62px;
  font-size: 1.2rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.summary-grid.compact {
  margin-top: 0;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

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

.admin-grid .student-list {
  max-height: 520px;
  overflow: auto;
  padding-right: 6px;
}

.student-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.student-row:last-child {
  border-bottom: 0;
}

.student-row span {
  color: var(--muted);
}

.student-row-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.student-row-text {
  display: grid;
  gap: 2px;
}

.student-thumb {
  width: 54px;
  height: 66px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dce4ea;
}

.table-student {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-thumb {
  width: 38px;
  height: 46px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #dce4ea;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.admin-wide {
  grid-column: 1 / -1;
}

.compact-table {
  max-height: 300px;
}

.table-wrap {
  max-height: 58vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  color: #fff;
  background: var(--navy);
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 16px, 1120px);
    padding: 10px 0 18px;
  }

  .login-view,
  .settings-grid,
  .flashcard,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .brand-block h1,
  .top-row h1,
  .practice-header h1 {
    font-size: 2rem;
  }

  .panel {
    padding: 16px;
  }

  .settings-grid {
    gap: 12px;
    margin: 16px 0;
  }

  .top-row,
  .action-bar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .practice-header {
    align-items: center;
    flex-direction: row;
  }

  .practice-header h1 {
    font-size: 1.5rem;
  }

  .inline-entry,
  .segmented {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-card strong {
    font-size: 1.7rem;
  }

  .checkbox-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .check-card,
  .toggle-row {
    min-height: 48px;
    padding: 10px;
  }

  .button-pair {
    justify-content: stretch;
  }

  .button-pair button {
    flex: 1 1 auto;
  }

  .practice-view {
    min-height: calc(100vh - 20px);
    gap: 10px;
  }

  .flashcard {
    gap: 10px;
    align-content: start;
  }

  .photo-wrap {
    width: 100%;
    max-height: 54vh;
    margin: 0 auto;
  }

  .card-details {
    min-height: 96px;
    align-content: center;
    text-align: center;
  }

  .timer-text {
    font-size: 1rem;
  }

  .student-name {
    font-size: 2rem;
  }

  .student-info {
    font-size: 0.95rem;
  }

  .answer-controls {
    position: sticky;
    bottom: 8px;
    padding-top: 8px;
    background: var(--page);
  }

  .answer-controls button {
    min-height: 56px;
  }

  .table-wrap {
    max-height: 62vh;
  }

  th,
  td {
    padding: 9px 10px;
  }

  .student-row {
    align-items: stretch;
    flex-direction: column;
  }

  .student-row-main {
    align-items: center;
  }
}

@media (max-width: 420px) {
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .photo-wrap {
    max-height: 50vh;
  }

  .student-thumb {
    width: 48px;
    height: 58px;
  }

  .table-thumb {
    width: 34px;
    height: 42px;
  }
}
