:root {
  --canvas: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --ink: #17233a;
  --muted: #6d7a90;
  --line: #e2e8f1;
  --line-strong: #cad5e4;
  --navy: #1d3154;
  --accent: #de704a;
  --accent-dark: #bc5334;
  --accent-soft: #fff0ea;
  --success: #287454;
  --success-soft: #e2f4eb;
  --shadow: 0 18px 46px rgba(35, 57, 92, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  background:
    radial-gradient(circle at 88% 0%, rgba(255, 220, 158, 0.34), transparent 25rem),
    linear-gradient(135deg, #f9fbff 0%, var(--canvas) 56%, #eef4fb 100%);
}

button, input, select { font: inherit; }

button {
  border: 0;
  border-radius: 11px;
  padding: 12px 15px;
  color: white;
  font-weight: 800;
  cursor: pointer;
  background: var(--accent);
  box-shadow: 0 8px 16px rgba(188, 83, 52, 0.2);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

button:hover:not(:disabled), button:focus-visible:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 12px 20px rgba(188, 83, 52, 0.25);
  transform: translateY(-1px);
}

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

input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

input:focus, select:focus {
  border-color: #7898c2;
  outline: 3px solid rgba(120, 152, 194, 0.18);
}

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 48px; }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 42px; padding: 0 4px 26px; }

.brand-line { display: flex; align-items: center; flex: 0 0 auto; gap: 9px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  font-family: "Palatino Linotype", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--navy);
  border-radius: 10px 10px 4px 10px;
  box-shadow: 4px 4px 0 #f5c65b;
}

.brand-name { margin: 0; color: var(--navy); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }

.hero-content { display: flex; align-items: end; justify-content: space-between; width: 100%; gap: 36px; }

.eyebrow, .section-label { margin: 0 0 8px; color: #7183a0; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.section-label { margin-bottom: 6px; }

.hero h1, .panel h2, .progress-summary h3 { font-family: "Palatino Linotype", Georgia, serif; }

.hero h1 { margin: 0; color: var(--navy); font-size: clamp(2.1rem, 4vw, 3.6rem); line-height: 0.96; letter-spacing: -0.05em; }
.hero-copy { max-width: 37ch; margin: 0 0 2px; color: var(--muted); font-size: 0.95rem; line-height: 1.55; }

.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: start; gap: 24px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.student-panel { padding: 22px 16px 16px; }
.panel-heading { padding: 0 6px; }

.panel-heading h2, .empty-state h2, .tracker-header h2 { margin: 0; color: var(--navy); font-size: 1.65rem; }
.panel-heading > p:last-child, .empty-state p, .help-text { color: var(--muted); }
.panel-heading > p:last-child { margin: 6px 0 0; font-size: 0.86rem; line-height: 1.45; }

.student-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin: 20px 0 18px; }
.student-form button { padding-inline: 13px; }
.sync-status { min-height: 1.25rem; margin: 10px 0 0; color: #7183a0; font-size: 0.78rem; }
.sync-status.is-error { color: #b42318; }

.student-list { display: grid; gap: 7px; max-height: 492px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.student-list > .help-text { margin: 14px 6px; font-size: 0.88rem; }
.student-row { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 6px; }

.student-item {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 9px;
  color: var(--ink);
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid transparent;
  box-shadow: none;
}

.student-item:hover:not(:disabled), .student-item:focus-visible:not(:disabled) { color: var(--ink); background: #f0f5fc; box-shadow: none; }
.student-item.active { background: #edf4ff; border-color: #b9cbe2; }

.student-initial { display: grid; flex: 0 0 auto; place-items: center; width: 31px; height: 31px; color: #365b8b; font-family: "Palatino Linotype", Georgia, serif; font-size: 0.96rem; font-weight: 700; background: #dceaff; border-radius: 9px; }
.student-details { display: grid; min-width: 0; gap: 2px; }
.student-name { overflow: hidden; font-size: 0.89rem; text-overflow: ellipsis; white-space: nowrap; }
.student-progress { color: var(--muted); font-size: 0.7rem; font-weight: 700; }

.delete-student-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: #b44e39; font-size: 1.32rem; font-weight: 400; line-height: 1; background: transparent; border: 1px solid transparent; box-shadow: none; }
.delete-student-btn:hover:not(:disabled), .delete-student-btn:focus-visible:not(:disabled) { color: #9f382b; background: var(--accent-soft); border-color: #f2cbc0; box-shadow: none; }

.tracker-panel { position: relative; min-height: 630px; padding: 28px; overflow: hidden; }
.tracker-panel::after { content: ""; position: absolute; right: -90px; bottom: -110px; width: 260px; height: 260px; border: 34px solid #f1f6fc; border-radius: 50%; pointer-events: none; }
.empty-state, .tracker-view { position: relative; z-index: 1; }
.empty-state { display: grid; place-items: center; min-height: 562px; padding: 32px; text-align: center; }
.empty-state h2 { max-width: 16ch; }
.empty-state p:last-child { max-width: 42ch; line-height: 1.55; }
.empty-kicker { color: var(--accent-dark) !important; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.hidden { display: none; }

.tracker-view { display: grid; gap: 18px; }
.tracker-header, .progress-summary, .actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.tracker-header { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.tracker-header h2 { font-size: 2rem; }
.status-pill { flex: 0 0 auto; padding: 8px 11px; color: var(--success); font-size: 0.76rem; font-weight: 800; background: var(--success-soft); border-radius: 999px; }

.plan-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 250px); column-gap: 20px; padding: 15px 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 14px; }
.plan-box .section-label, .plan-box label, .plan-box .help-text { grid-column: 1; }
.plan-box .section-label { align-self: end; }
.plan-box label { margin-bottom: 0; font-size: 0.96rem; font-weight: 800; }
.plan-box select { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.help-text { margin: 7px 0 0; font-size: 0.78rem; line-height: 1.45; }

.progress-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.82fr);
  grid-template-areas: "summary toy" "track toy";
  align-items: start;
  gap: 18px 34px;
  min-height: 354px;
  padding: 24px;
  background: #fcfdff;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.progress-summary { grid-area: summary; align-items: end; }
.progress-summary h3 { margin: 4px 0 0; color: var(--navy); font-size: clamp(2rem, 4vw, 2.65rem); line-height: 0.96; letter-spacing: -0.04em; }
.progress-track { grid-area: track; width: 100%; height: 10px; padding: 2px; background: #e7edf5; border-radius: 999px; }
.progress-bar { width: 0; height: 100%; background: linear-gradient(90deg, #efbf4c, var(--accent)); border-radius: inherit; transition: width 220ms ease; }

.stacking-toy { --tower-height: 232px; grid-area: toy; position: relative; display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-start; min-height: 302px; padding: 22px 0 42px; isolation: isolate; }
.stacking-toy__peg { position: absolute; z-index: -1; bottom: 36px; width: 42px; height: var(--tower-height); background: linear-gradient(90deg, #f8fafc, #e8edf3); border: 3px solid #cdd4df; border-bottom: 0; border-radius: 24px 24px 0 0; }
.ring-stack { display: flex; flex-direction: column-reverse; align-items: center; width: min(100%, 280px); }

.ring { --ring-color: #f06532; position: relative; width: calc(100% - (var(--ring-index) * 15px)); min-width: 125px; height: 34px; margin-bottom: -10px; background: #edf2f8; border: 1px solid #dbe3ed; border-radius: 50%; transition: background 260ms ease, box-shadow 260ms ease, transform 260ms ease; }
.ring.filled { z-index: 1; background: linear-gradient(180deg, color-mix(in srgb, var(--ring-color) 84%, white), var(--ring-color)); border-color: transparent; box-shadow: inset 0 5px 8px rgba(255, 255, 255, 0.35), 0 5px 8px rgba(45, 61, 89, 0.14); animation: ring-land 360ms ease-out both; }
.ring:nth-child(1) { --ring-color: #91d83a; }
.ring:nth-child(2) { --ring-color: #f2d745; }
.ring:nth-child(3) { --ring-color: #508ce0; }
.ring:nth-child(4) { --ring-color: #7b58df; }
.ring:nth-child(5) { --ring-color: #e96243; }
.ring:nth-child(6) { --ring-color: #eea131; }
.ring:nth-child(7) { --ring-color: #db6397; }
.ring:nth-child(8) { --ring-color: #50b8a8; }

.actions { justify-content: flex-end; }
.secondary-btn { padding: 9px 11px; color: var(--muted); font-size: 0.8rem; background: transparent; box-shadow: none; }
.secondary-btn:hover:not(:disabled), .secondary-btn:focus-visible:not(:disabled) { color: var(--ink); background: #eef3f9; box-shadow: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
:focus-visible { outline: 3px solid rgba(100, 139, 191, 0.45); outline-offset: 2px; }

@keyframes ring-land {
  from { opacity: 0; transform: translateY(-16px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 880px) {
  .hero, .hero-content { align-items: flex-start; flex-direction: column; gap: 16px; }
  .layout { grid-template-columns: 1fr; }
  .student-list { max-height: 280px; }
}

@media (max-width: 680px) {
  .page-shell { width: min(100% - 24px, 1180px); padding-top: 20px; }
  .hero { gap: 15px; padding-bottom: 20px; }
  .hero h1 { font-size: 2.35rem; }
  .tracker-panel { min-height: 0; padding: 20px; }
  .tracker-header, .progress-summary { align-items: stretch; flex-direction: column; }
  .plan-box { grid-template-columns: 1fr; row-gap: 8px; }
  .plan-box select { grid-column: 1; grid-row: auto; }
  .progress-card { grid-template-columns: 1fr; grid-template-areas: "summary" "track" "toy"; gap: 17px; min-height: 0; padding: 18px; }
  .stacking-toy { min-height: 260px; padding-bottom: 36px; }
  .stacking-toy__peg { bottom: 30px; }
  .actions { justify-content: stretch; }
  .actions button { width: 100%; }
}

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