:root {
  --ink: #15131c;
  --muted: #6f6a7a;
  --accent: #3a5b6d;
  --accent-strong: #1f3f4c;
  --peach: #f6d7b0;
  --mint: #c6e6d1;
  --paper: #fefbf7;
  --shadow: 0 20px 40px rgba(20, 18, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #f8f5f1;
}

.bg-layer {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 20% 0%, #fff2da 0%, transparent 60%),
    radial-gradient(1000px 700px at 90% 20%, #d7eff2 0%, transparent 55%),
    linear-gradient(120deg, #f7efe2, #f5f0ea 60%, #f0f4f6);
  z-index: -2;
}

.grain {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  z-index: -1;
  pointer-events: none;
}

.app {
  max-width: 1100px;
  margin: 40px auto 80px;
  padding: 0 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero {
  padding: 30px 30px 20px;
  background: var(--paper);
  border-radius: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.7s ease both;
}

.hero h1 {
  margin: 12px 0 8px;
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  font-size: clamp(26px, 4vw, 38px);
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--accent-strong);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.status {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 16px;
  background: #f3f1ea;
  color: var(--accent-strong);
  font-weight: 600;
}

.status-school {
  font-weight: 700;
  margin-bottom: 6px;
}

.status-text {
  color: var(--accent-strong);
}

.error-text {
  color: #b42318;
  font-size: 12px;
  margin-top: 4px;
}

.error-text:empty {
  display: none;
}

.panel {
  background: var(--paper);
  border-radius: 24px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.7s ease both;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.field label {
  font-weight: 600;
}

.field input,
.field select {
  border-radius: 12px;
  border: 1px solid #e2ddcf;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

.inline {
  display: flex;
  gap: 10px;
}

.inline input {
  flex: 1;
}

.grade-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.grade-options button {
  border: 1px solid #d7d0c1;
  background: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.grade-options button.active {
  background: var(--peach);
  border-color: var(--peach);
}

.schedule-body {
  display: grid;
  gap: 14px;
}

.day-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed #eadfce;
}

.day-row:last-child {
  border-bottom: none;
}

.day-label {
  font-weight: 700;
  color: var(--accent-strong);
}

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

.course-card {
  border: 1px solid #d7dbe2;
  background: #eef1f5;
  border-radius: 14px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #243041;
}

.course-card:hover {
  box-shadow: 0 8px 16px rgba(31, 63, 76, 0.08);
}

.course-card.course-option {
  background: #f2f4f7;
}

.course-card.passive-option {
  background: #d6dae0;
  border-color: #c4cbd5;
  color: #3a4658;
}

.course-card.selected {
  background: #239a3b;
  border-color: #239a3b;
  color: #fff;
}

.course-card.selected .course-brief {
  color: rgba(255, 255, 255, 0.94);
}

.course-card.selected .course-thumb {
  border-color: rgba(255, 255, 255, 0.55);
}

.course-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.course-brief {
  font-size: 12px;
  color: #445468;
  min-height: 34px;
  line-height: 1.4;
}

.course-thumb {
  margin-top: 8px;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #ced5df;
  background: #ecf0f4;
}

.course-thumb:focus {
  outline: 2px solid #1f3f4c;
  outline-offset: 2px;
}

.course-thumb-empty {
  margin-top: 8px;
  border-radius: 10px;
  border: 1px dashed #c4ccd7;
  background: #edf1f6;
  color: #6a7688;
  font-size: 12px;
  text-align: center;
  padding: 16px 8px;
}

.course-card.selected .course-thumb-empty {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.9);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.field.full {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.primary {
  background: var(--accent-strong);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(31, 63, 76, 0.24);
}

.ghost {
  border: 1px solid #d7d0c1;
  background: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.action-left {
  color: var(--muted);
}

.result-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.result-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: #f6f2ea;
  border: 1px solid #ede3d3;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1f3f4c;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show {
  opacity: 1;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.modal-open {
  overflow: hidden;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
}

.image-modal[hidden] {
  display: none;
}

.image-mask {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.6);
}

.image-panel {
  position: relative;
  width: min(900px, calc(100vw - 24px));
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 24px 60px rgba(10, 10, 12, 0.45);
}

.image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

#coursePreviewImage {
  width: 100%;
  border-radius: 12px;
  max-height: min(78vh, 820px);
  object-fit: contain;
  background: #f3f5f8;
}

@media (max-width: 720px) {
  .hero {
    padding: 24px;
  }
  .day-row {
    grid-template-columns: 1fr;
  }
  .course-options {
    grid-template-columns: 1fr;
  }
  .actions {
    flex-direction: column;
    align-items: flex-start;
  }
  .image-panel {
    width: calc(100vw - 16px);
    padding: 10px;
  }
}
