:root {
  color-scheme: light;
  --ink: #25211d;
  --muted: #6f655c;
  --line: #e8d8b5;
  --background: #fffdf9;
  --surface: #ffffff;
  --cream: #faf1d1;
  --primary: #f4520d;
  --primary-strong: #c93d08;
  --sky: #1387c0;
  --sky-soft: #e7f5fb;
  --amber: #f4520d;
  --coral: #c93d08;
  --mint: #faf1d1;
  --danger: #a83212;
  --shadow: 0 10px 28px rgba(82, 55, 26, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--background);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
  color: var(--ink);
}

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

button,
label,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

.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;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--background);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: max(18px, env(safe-area-inset-top)) 18px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand-home-link {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.brand-home-link::before {
  content: "←";
  margin-right: 6px;
}

.brand-home-link:hover {
  color: var(--primary);
}

.title-row,
.section-title,
.field-meta,
.student-summary,
.media-heading,
.review-heading,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 5px;
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.icon-button {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--sky);
}

#installBtn {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.session-fields {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 10px;
  margin-top: 16px;
}

.session-fields label,
.field {
  display: grid;
  gap: 7px;
}

.session-fields span,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.session-fields input,
.text-input,
.select-input,
.text-area {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.session-fields input {
  height: 44px;
  min-width: 0;
  padding: 0 11px;
  font-size: 14px;
}

.text-input,
.select-input {
  height: 50px;
  padding: 0 13px;
  font-size: 16px;
}

.text-area {
  min-height: 104px;
  padding: 12px 13px;
  font-size: 15px;
  line-height: 1.55;
  resize: vertical;
}

.text-area.tall {
  min-height: 124px;
}

.session-fields input:focus,
.text-input:focus,
.select-input:focus,
.text-area:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(244, 82, 13, 0.14);
}

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

.save-status svg {
  width: 14px;
  height: 14px;
}

.student-tracker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.student-slot.add-student {
  border-style: dashed;
  color: var(--sky);
}

.student-slot {
  min-width: 0;
  min-height: 50px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: left;
}

.student-slot strong,
.student-slot span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-slot strong {
  color: inherit;
  font-size: 13px;
}

.student-slot span {
  margin-top: 3px;
  font-size: 10px;
}

.student-slot.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.student-slot.complete:not(.active) {
  border-color: #8bc9e7;
  background: var(--sky-soft);
  color: #0b6896;
}

.step-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 12px;
}

.step-segment {
  height: 4px;
  border-radius: 4px;
  background: #eadfca;
}

.step-segment.active {
  background: var(--primary);
}

.step-segment.complete {
  background: var(--sky);
}

#appMain {
  padding: 22px 18px 152px;
  outline: none;
}

.page-intro {
  margin: -22px -18px 20px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
}

.page-intro p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.step-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--sky);
  font-size: 12px;
  font-weight: 800;
}

.form-section {
  margin-bottom: 22px;
}

.form-section + .form-section {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.field + .field {
  margin-top: 16px;
}

.required {
  color: var(--coral);
}

.helper,
.field-error,
.media-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-error {
  color: var(--danger);
}

.rating-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.rating-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) auto;
  align-items: center;
  min-height: 58px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.rating-label {
  font-size: 14px;
  font-weight: 700;
}

.star-group {
  display: grid;
  grid-template-columns: repeat(5, 44px);
  width: 220px;
  height: 44px;
}

.star-button {
  display: inline-flex;
  width: 44px;
  height: 44px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #cfd6dd;
}

.star-button svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
  stroke: currentColor;
}

.star-button.filled {
  color: var(--amber);
}

.star-button:focus-visible {
  border-radius: 6px;
  outline: 2px solid var(--primary);
  outline-offset: -3px;
}

.rating-score {
  grid-column: 1 / -1;
  min-height: 16px;
  margin: -2px 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.upload-zone {
  display: grid;
  min-height: 112px;
  padding: 18px;
  place-items: center;
  border: 1px dashed #75b9da;
  border-radius: 8px;
  background: #f4fbfe;
  color: var(--muted);
  text-align: center;
}

.upload-zone:hover {
  border-color: var(--sky);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-zone svg {
  width: 25px;
  height: 25px;
  margin-bottom: 8px;
  color: var(--sky);
}

.upload-zone strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.upload-zone span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.media-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
}

.remove-student {
  margin-top: 12px;
  color: var(--danger);
}

.media-footer span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button,
.link-button {
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--sky);
  font-size: 12px;
  font-weight: 800;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f1e7d3;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: inline-flex;
  width: 28px;
  height: 28px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(23, 32, 51, 0.78);
  color: #ffffff;
}

.photo-remove svg {
  width: 15px;
  height: 15px;
}

.student-summary {
  margin-bottom: 20px;
  padding: 13px 14px;
  border-left: 3px solid var(--sky);
  background: var(--sky-soft);
}

.student-summary strong,
.student-summary span {
  display: block;
}

.student-summary span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.review-list {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.review-section {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.review-heading h3 {
  font-size: 14px;
}

.review-grid {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 8px 12px;
  margin-top: 11px;
  font-size: 13px;
  line-height: 1.5;
}

.review-grid dt {
  color: var(--muted);
}

.review-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.review-stars {
  color: var(--amber);
  letter-spacing: 0;
}

.completion-note {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding: 13px;
  border: 1px solid #8bc9e7;
  border-radius: 8px;
  background: var(--sky-soft);
  color: #0b6896;
  font-size: 13px;
  line-height: 1.5;
}

.completion-note svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: grid;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 12px 18px max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  gap: 9px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 9px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 50px;
  padding: 0 14px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--sky);
}

.primary-button svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 112px;
  left: 16px;
  z-index: 80;
  max-width: 520px;
  margin: 0 auto;
  padding: 11px 14px;
  border-radius: 8px;
  background: #25211d;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(37, 33, 29, 0.38);
}

.busy-overlay[hidden] {
  display: none;
}

.busy-panel {
  width: min(100%, 310px);
  padding: 24px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.busy-panel strong {
  display: block;
  margin-top: 13px;
}

.busy-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid #eadfca;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .rating-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .star-group {
    justify-self: start;
  }

  .rating-score {
    text-align: left;
  }

  .review-grid {
    grid-template-columns: 100px minmax(0, 1fr);
  }
}

@media print {
  .app-header,
  .action-bar,
  .toast,
  .busy-overlay {
    display: none !important;
  }
}
