:root {
  --grass: #7AB648;
  --deep-green: #5A9E3A;
  --sun: #F5C842;
  --sky: #6BB8E0;
  --cream: #FAF6EE;
  --pink: #FFF0F5;
  --red: #E84040;
  --brown: #3D2B1F;
  --leaf-border: #C8E6A0;
  --shadow: 0 4px 16px rgba(122, 182, 72, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--brown);
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 16px;
  background:
    radial-gradient(circle at 88% 8%, rgba(245, 200, 66, 0.22), transparent 18rem),
    radial-gradient(circle at 78% 86%, rgba(107, 184, 224, 0.18), transparent 22rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.5), rgba(250, 246, 238, 0.8)),
    var(--cream);
}

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

button {
  cursor: pointer;
}

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

h1,
h2,
h3 {
  margin: 0;
  font-family: "M PLUS Rounded 1c", "Nunito", sans-serif;
  line-height: 1.2;
}

p {
  margin: 0;
  color: rgba(61, 43, 31, 0.72);
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 14px;
  color: white;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 42%),
    var(--grass);
  overflow: hidden;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: auto -30px 16px auto;
  width: 140px;
  height: 140px;
  border: 14px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  pointer-events: none;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--grass);
  background: white;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(61, 43, 31, 0.18);
}

.brand strong,
.student-chip strong {
  display: block;
  font-weight: 700;
}

.brand small,
.student-chip small {
  display: block;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.78rem;
}

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

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  color: white;
  font-weight: 700;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 14px;
  transition: background 0.18s ease, transform 0.18s ease;
}

.nav-item:hover,
.nav-item.active {
  background: var(--deep-green);
}

.nav-item:hover {
  transform: translateY(-1px);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  width: 4px;
  height: 28px;
  background: white;
  border-radius: 999px;
}

.student-chip {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  background: rgba(90, 158, 58, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 18px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 50%;
}

.main-area {
  min-width: 0;
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding: 26px 30px 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin-bottom: 4px;
  font-weight: 700;
  color: var(--deep-green);
}

.topbar h1 {
  font-size: 2rem;
}

.top-actions,
.toolbar,
.week-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.top-actions {
  justify-content: flex-end;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 9px 15px;
  color: var(--brown);
  font-weight: 800;
  background: var(--sun);
  border: 1.5px solid rgba(61, 43, 31, 0.08);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(245, 200, 66, 0.24);
}

.flame.milestone {
  animation: flameBlink 0.8s ease-in-out infinite;
}

.content-view {
  display: grid;
  gap: 18px;
}

.fade-in {
  animation: fadeIn 0.2s ease both;
}

.card,
.empty-card {
  background: var(--pink);
  border: 1.5px solid var(--leaf-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.card {
  padding: 18px;
}

.empty-card {
  padding: 24px;
  color: rgba(61, 43, 31, 0.72);
  text-align: center;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 16px;
  font-family: "Nunito", sans-serif;
  font-weight: 600;
  border-radius: 999px;
  border: 1.5px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, color 0.18s ease;
}

.button.primary {
  color: white;
  background: var(--grass);
}

.button.primary:hover {
  background: var(--deep-green);
  transform: translateY(-1px);
}

.button.secondary {
  color: var(--grass);
  background: transparent;
  border-color: var(--grass);
}

.button.secondary:hover {
  color: white;
  background: var(--grass);
  transform: translateY(-1px);
}

.danger-outline {
  color: var(--red);
  border-color: var(--red);
}

.danger-outline:hover {
  background: var(--red);
}

.icon-button,
.lock-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--grass);
  background: rgba(255, 255, 255, 0.58);
  border: 1.5px solid var(--leaf-border);
  border-radius: 50%;
  font-weight: 800;
  transition: transform 0.18s ease, background 0.18s ease;
}

.icon-button:hover,
.lock-button:hover {
  background: white;
  transform: translateY(-1px);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  color: var(--brown);
  background: rgba(255, 255, 255, 0.8);
  border: 1.5px solid var(--leaf-border);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--grass);
  box-shadow: 0 0 0 3px rgba(122, 182, 72, 0.2);
}

label {
  display: grid;
  gap: 6px;
  color: rgba(61, 43, 31, 0.78);
  font-weight: 700;
}

.inline-form,
.form-grid,
.score-subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}

.score-subject-grid {
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

.inline-form.compact {
  grid-template-columns: minmax(140px, 1fr) 90px auto;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.planner-quick-add {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) 2.2fr;
  gap: 18px;
  align-items: start;
}

.flexible-slot-card {
  display: grid;
  gap: 16px;
}

.custom-slot-list,
.ai-import-list {
  display: grid;
  gap: 8px;
}

.custom-slot-row,
.ai-import-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.62);
  border-radius: 14px;
}

.custom-slot-row span,
.custom-slot-row small,
.ai-import-row span,
.ai-import-row small {
  display: block;
}

.custom-slot-row small,
.ai-import-row small {
  margin-top: 3px;
  color: rgba(61, 43, 31, 0.6);
  font-size: 0.78rem;
}

.progress-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.progress-card .progress-wrap {
  grid-column: 1 / -1;
}

.celebration-preview {
  justify-self: start;
  margin-top: 8px;
}

.perfect-preview {
  margin-left: 6px;
  color: #8a5d00;
  border-color: rgba(245, 200, 66, 0.8);
  background: linear-gradient(135deg, rgba(255, 250, 184, 0.78), rgba(245, 200, 66, 0.28));
}

.progress-wrap {
  height: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(122, 182, 72, 0.24);
  border-radius: 999px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--grass), var(--deep-green));
  border-radius: inherit;
  transition: width 0.2s ease;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--leaf-border);
  border-radius: 999px;
}

.segmented button {
  min-height: 34px;
  padding: 6px 14px;
  color: var(--brown);
  font-weight: 800;
  background: transparent;
  border: 0;
  border-radius: 999px;
}

.segmented button.selected {
  color: white;
  background: var(--grass);
}

.planner-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.day-column {
  min-width: 150px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.62);
  border: 1.5px solid var(--leaf-border);
  border-radius: 20px;
}

.day-column > header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.day-column > header span {
  color: var(--deep-green);
  font-weight: 800;
}

.slot-block {
  display: grid;
  gap: 8px;
  min-height: 92px;
  margin-bottom: 10px;
  padding: 10px;
  background: rgba(255, 240, 245, 0.82);
  border: 1px dashed rgba(122, 182, 72, 0.5);
  border-radius: 16px;
}

.slot-block.locked {
  background: repeating-linear-gradient(135deg, #eeeeee, #eeeeee 8px, #e2e2e2 8px, #e2e2e2 16px);
  border-color: #c9c9c9;
}

.invalid-task-notice {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  color: rgba(61, 43, 31, 0.78);
  background: rgba(245, 200, 66, 0.14);
  border: 1px dashed rgba(179, 122, 76, 0.55);
  border-radius: 16px;
}

.invalid-task-notice > small {
  font-size: 0.76rem;
  line-height: 1.4;
}

.invalid-task-group {
  display: grid;
  gap: 6px;
}

.invalid-task-group > b {
  font-size: 0.78rem;
}

.slot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 800;
}

.lock-button {
  width: 30px;
  height: 30px;
  font-size: 0.86rem;
}

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

.task-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: white;
  border-left: 4px solid var(--subject);
  border-radius: 12px;
}

.task-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--grass);
}

.task-row strong,
.task-row small {
  display: block;
}

.task-row strong {
  overflow-wrap: anywhere;
}

.task-row small {
  color: rgba(61, 43, 31, 0.6);
  font-size: 0.78rem;
}

.study-mode {
  display: inline-block;
  margin-left: 3px;
  padding: 2px 6px;
  color: var(--deep-green);
  background: rgba(122, 182, 72, 0.14);
  border-radius: 999px;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 800;
}

.task-icon {
  display: none;
}

.task-row .text-danger {
  grid-column: 2;
  justify-self: start;
  padding: 0;
}

.text-danger {
  color: var(--red);
  background: transparent;
  border: 0;
  font-size: 0.78rem;
  font-weight: 800;
}

.empty-task,
.locked-note {
  color: rgba(61, 43, 31, 0.58);
  font-size: 0.85rem;
  font-weight: 700;
}

.month-grid,
.goal-grid,
.exam-list,
.score-list,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.month-overview {
  display: grid;
  gap: 14px;
}

.month-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 10px;
}

.month-stats span {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.62);
  border-radius: 14px;
}

.month-stats strong {
  color: var(--deep-green);
  font-size: 1.25rem;
}

.month-stats small {
  color: rgba(61, 43, 31, 0.62);
  font-weight: 800;
}

.month-mode-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.month-mode-summary span {
  padding: 5px 9px;
  color: var(--deep-green);
  background: rgba(122, 182, 72, 0.12);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.calendar-card {
  padding: 14px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(100px, 1fr));
  gap: 7px;
}

.calendar-weekdays {
  margin-bottom: 7px;
}

.calendar-weekdays span {
  padding: 7px;
  color: var(--deep-green);
  text-align: center;
  font-weight: 800;
}

.calendar-day {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 108px;
  padding: 10px;
  color: var(--brown);
  text-align: left;
  background: rgba(255, 255, 255, 0.68);
  border: 1.5px solid var(--leaf-border);
  border-radius: 14px;
  cursor: pointer;
}

.calendar-day:hover {
  background: white;
  transform: translateY(-1px);
}

.calendar-day.outside {
  opacity: 0.42;
}

.calendar-day.today {
  border-color: var(--grass);
  box-shadow: inset 0 0 0 2px rgba(122, 182, 72, 0.2);
}

.calendar-day.done {
  background: rgba(122, 182, 72, 0.12);
}

.calendar-date {
  font-size: 1.05rem;
  font-weight: 900;
}

.calendar-count {
  color: rgba(61, 43, 31, 0.62);
  font-size: 0.78rem;
  font-weight: 800;
}

.calendar-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: auto;
}

.calendar-dots i {
  width: 9px;
  height: 9px;
  background: #9aa09c;
  border-radius: 50%;
}

.calendar-dots i.exam {
  background: #e45a4f;
}

.calendar-dots i.review {
  background: #7ab648;
}

.calendar-dots i.preview {
  background: #6bb8e0;
}

.calendar-dots i.daily {
  background: #f5c842;
}

.score-list {
  grid-template-columns: 1fr;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.score-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--cream);
  border: 1.5px solid var(--leaf-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.score-tabs button {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 8px 18px;
  color: var(--brown);
  font-weight: 800;
  font-size: 0.95rem;
  white-space: nowrap;
  background: transparent;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.score-tabs button.selected {
  color: white;
  background: var(--grass);
  box-shadow: 0 4px 12px rgba(122, 182, 72, 0.28);
}

.score-tab-panel {
  display: grid;
  gap: 18px;
}

.score-semester-group {
  display: grid;
  gap: 12px;
}

.score-semester-group h3 {
  margin: 0;
  color: var(--brown);
  font-family: "M PLUS Rounded 1c", "Nunito", sans-serif;
  font-size: 1.25rem;
}

.score-semester-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.mini-week header,
.exam-card header,
.score-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.mini-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.mini-days span {
  display: grid;
  place-items: center;
  min-height: 48px;
  color: rgba(61, 43, 31, 0.7);
  background: rgba(255, 255, 255, 0.62);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 800;
}

.mini-days span.done {
  color: white;
  background: var(--grass);
}

.mini-days small {
  display: block;
  font-size: 0.68rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.badge.blue {
  color: white;
  background: var(--sky);
}

.badge.yellow {
  color: var(--brown);
  background: var(--sun);
}

.badge.red {
  color: white;
  background: var(--red);
}

.goal-card {
  display: grid;
  gap: 12px;
}

.roadmap-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.roadmap-form label:last-of-type,
.roadmap-form button,
.admission-hint {
  grid-column: 1 / -1;
}

.admission-hint {
  display: grid;
  gap: 6px;
  padding: 12px;
  color: var(--brown);
  background: rgba(245, 200, 66, 0.2);
  border: 1.5px solid rgba(245, 200, 66, 0.58);
  border-radius: 14px;
  font-weight: 800;
}

.admission-hint span,
.admission-hint small {
  font-weight: 700;
}

.admission-hint small {
  color: rgba(61, 43, 31, 0.72);
}

.admission-hint a {
  color: var(--deep-green);
  text-decoration: none;
}

.goal-numbers {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.goal-numbers strong {
  color: var(--deep-green);
  font-size: 2rem;
}

.goal-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.exam-form,
.score-form {
  display: grid;
  gap: 14px;
}

.exam-subject-list {
  display: grid;
  gap: 10px;
}

.scope-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 130px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
}

.scope-tags,
.suggestion-list,
.score-chips,
.subject-manager {
  display: grid;
  gap: 10px;
}

.scope-tags {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.scope-tags span,
.score-chip {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.68);
  border-radius: 12px;
  font-weight: 800;
}

.ai-row {
  display: grid;
  grid-template-columns: 110px 80px auto minmax(160px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.62);
  border-radius: 14px;
}

.prompt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.prompt-box {
  min-height: 280px;
  margin: 10px 0 12px;
  font-family: "Nunito", "Microsoft JhengHei", sans-serif;
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.78);
}

.ai-import-panel {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1.5px dashed var(--leaf-border);
}

.ai-response-box {
  min-height: 180px;
}

.ai-import-row {
  align-items: start;
}

.ai-import-row > span:first-child {
  min-width: 210px;
}

.import-message {
  margin: 10px 0;
  padding: 10px 12px;
  background: rgba(107, 184, 224, 0.15);
  border-radius: 12px;
  font-weight: 700;
}

.import-message.error {
  color: var(--red);
  background: rgba(232, 64, 64, 0.1);
}

.import-message.success {
  color: var(--deep-green);
  background: rgba(122, 182, 72, 0.15);
}

.import-skipped {
  margin-top: 10px;
  color: rgba(61, 43, 31, 0.72);
}

.week-coverage {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: rgba(122, 182, 72, 0.1);
  border: 1px solid rgba(122, 182, 72, 0.28);
  border-radius: 14px;
}

.week-coverage.has-warning {
  background: rgba(245, 200, 66, 0.12);
  border-color: rgba(179, 122, 76, 0.35);
}

.week-coverage-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.week-coverage-grid span {
  padding: 5px 8px;
  background: white;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.week-coverage-grid span.missing {
  color: var(--red);
  background: rgba(232, 64, 64, 0.08);
}

.week-coverage p {
  margin: 0;
  color: rgba(61, 43, 31, 0.68);
  font-size: 0.84rem;
}

.score-input-card {
  display: grid;
  grid-template-columns: minmax(82px, 0.7fr) repeat(3, minmax(92px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: rgba(255, 255, 255, 0.62);
  border-radius: 16px;
}

.score-input-card > * {
  min-width: 0;
}

.score-input-card strong {
  align-self: center;
  line-height: 1.25;
  word-break: keep-all;
}

.score-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.score-pr-editor {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.58);
  border: 1.5px dashed rgba(122, 182, 72, 0.42);
  border-radius: 16px;
}

.score-pr-editor[hidden] {
  display: none;
}

.pr-rank-grid,
.pr-subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.chart-card {
  min-height: 0;
}

.chart-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0 14px;
}

.chart-filter {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  color: rgba(61, 43, 31, 0.76);
  background: rgba(255, 255, 255, 0.62);
  border: 1.5px solid rgba(122, 182, 72, 0.22);
  border-radius: 999px;
  font: 800 0.92rem "Nunito", sans-serif;
  cursor: pointer;
}

.chart-filter span {
  width: 20px;
  height: 10px;
  background: var(--filter-color);
  border: 2px var(--filter-border, solid) var(--filter-color);
  border-radius: 999px;
}

.chart-filter.selected {
  color: white;
  background: var(--grass);
  border-color: var(--grass);
}

.rank-chart-stack {
  display: grid;
  gap: 18px;
}

.rank-chart-panel {
  display: grid;
  gap: 8px;
}

.rank-chart-panel h3 {
  margin: 0;
  color: var(--brown);
  font-family: "M PLUS Rounded 1c", "Nunito", sans-serif;
  font-size: 1.05rem;
}

.chart-canvas-frame {
  position: relative;
  width: 100%;
  height: 260px;
  max-height: 260px;
  overflow: hidden;
}

.chart-canvas-frame.rank {
  height: 180px;
  max-height: 180px;
}

.chart-card canvas {
  display: block;
  width: 100%;
  height: 100% !important;
  max-height: 100% !important;
}

.rank-chart-panel canvas {
  height: 100% !important;
}

.score-chip {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  border-left: 4px solid var(--subject);
}

.cycle-summary {
  margin-top: 12px;
  padding: 12px;
  background: rgba(107, 184, 224, 0.16);
  border-radius: 14px;
}

.cycle-summary strong {
  display: block;
  margin-bottom: 4px;
}

.relation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.relation-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.64);
  border-radius: 14px;
}

.score-chip small {
  color: rgba(61, 43, 31, 0.62);
}

.up {
  color: var(--deep-green);
}

.down {
  color: var(--red);
}

.star-label {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 8px;
  color: var(--brown);
  background: var(--sun);
  border-radius: 999px;
  font-family: "Nunito", sans-serif;
  font-size: 0.78rem;
}

.star-label.low {
  color: white;
  background: var(--red);
}

.subject-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.62);
  border-radius: 14px;
}

.subject-manage-row > span {
  border-left: 5px solid var(--subject);
  padding-left: 8px;
  font-weight: 800;
}

.subject-manage-row div {
  display: flex;
  gap: 6px;
}

.toggle-row {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--grass);
}

.helper-text {
  padding: 10px;
  color: var(--brown);
  background: rgba(107, 184, 224, 0.2);
  border-radius: 12px;
  font-size: 0.9rem;
}

.sync-status {
  margin: 0;
  padding: 10px 12px;
  color: rgba(61, 43, 31, 0.72);
  background: rgba(255, 255, 255, 0.62);
  border: 1.5px solid rgba(122, 182, 72, 0.24);
  border-radius: 14px;
  font-weight: 800;
}

.sync-status.ok {
  color: var(--deep-green);
  border-color: var(--grass);
}

.sync-status.error {
  color: var(--red);
  border-color: rgba(232, 64, 64, 0.45);
}

.benchmark-card {
  grid-column: 1 / -1;
}

.benchmark-json {
  min-height: 320px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

.admission-json {
  min-height: 260px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.star-burst {
  position: absolute;
  inset: 50% auto auto 26px;
  pointer-events: none;
}

.star-burst i {
  position: absolute;
  color: var(--sun);
  font-style: normal;
  font-size: 0.92rem;
  text-shadow: 0 1px 0 white;
  animation: starPop 0.8s ease-out forwards;
  transform: rotate(calc(var(--i) * 24deg));
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  color: white;
  background: var(--deep-green);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(61, 43, 31, 0.18);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

.pokemon-celebration {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(255, 250, 184, 0.35), transparent 52%), rgba(61, 43, 31, 0.55);
  animation: celebrationBackdrop 0.35s ease-out both;
}

.pokemon-celebration.closing {
  animation: celebrationClose 0.26s ease-in both;
}

.pokemon-celebration.perfect {
  background:
    radial-gradient(circle at center, rgba(255, 246, 130, 0.65), transparent 48%),
    linear-gradient(145deg, rgba(40, 25, 65, 0.82), rgba(90, 55, 22, 0.78));
}

.pokemon-celebration.perfect .pokemon-celebration-card {
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.98), transparent 32%),
    linear-gradient(155deg, #fff9bf, #ffd85a 52%, #f2a93b);
  box-shadow:
    0 0 0 7px rgba(255, 242, 153, 0.86),
    0 0 55px rgba(255, 215, 70, 0.85),
    0 28px 80px rgba(24, 15, 38, 0.55);
  animation: perfectCardEntrance 0.85s cubic-bezier(0.2, 1.5, 0.4, 1) both, perfectCardShine 1.8s ease-in-out infinite alternate 0.9s;
}

.pokemon-celebration.perfect .celebration-kicker {
  color: #745000;
  background: linear-gradient(135deg, #fffce5, #ffe26e);
  box-shadow: 0 0 18px rgba(255, 231, 118, 0.8);
}

.pokemon-celebration.perfect .celebration-score {
  color: #b66d00;
  text-shadow: 0 3px 0 white, 0 0 18px rgba(255, 236, 121, 0.95);
  animation: perfectScorePulse 0.85s ease-in-out infinite alternate;
}

.pokemon-celebration.perfect .pokemon-stage img {
  animation: legendaryFloat 1.7s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(255, 244, 163, 0.95)) drop-shadow(0 16px 9px rgba(87, 54, 0, 0.32));
}

.pokemon-celebration.perfect .pokemon-glow {
  width: 215px;
  height: 55px;
  background: rgba(255, 234, 97, 0.78);
  animation: legendaryGlow 0.8s ease-in-out infinite alternate;
}

.celebration-fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.celebration-fireworks i {
  position: absolute;
  left: calc(12% + var(--i) * 15%);
  top: calc(12% + var(--i) * 9%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow:
    0 -55px 0 #ffe66f,
    38px -38px 0 #ff9f43,
    55px 0 0 #fff4a8,
    38px 38px 0 #ffcd3c,
    0 55px 0 #fff4a8,
    -38px 38px 0 #ff9f43,
    -55px 0 0 #ffe66f,
    -38px -38px 0 #fff4a8;
  animation: fireworkBurst 1.4s ease-out infinite;
  animation-delay: calc(var(--i) * -0.23s);
}

.pokemon-celebration-card {
  position: relative;
  z-index: 3;
  width: min(520px, 100%);
  padding: 24px 26px 28px;
  text-align: center;
  background: radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.95), transparent 36%), linear-gradient(160deg, #fffbe0, #fff2a8 58%, #ffd96a);
  border: 4px solid white;
  border-radius: 30px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--pokemon-accent, #f5c842) 65%, transparent), 0 24px 70px rgba(61, 43, 31, 0.35);
  animation: celebrationCardPop 0.65s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.pokemon-celebration-card h2 {
  margin: 4px 0 2px;
  color: #8a5d00;
  font-size: clamp(1.65rem, 5vw, 2.25rem);
}

.pokemon-celebration-card p {
  margin: 9px auto;
  max-width: 410px;
  line-height: 1.55;
}

.celebration-kicker {
  display: inline-block;
  padding: 5px 12px;
  color: #8a5d00;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.celebration-score {
  display: block;
  margin: 2px 0 4px;
  color: var(--red);
  font-size: clamp(2rem, 7vw, 3.2rem);
  line-height: 1;
  text-shadow: 0 3px 0 white;
}

.celebration-quote {
  color: #7c6107;
  font-weight: 900;
}

.celebration-close,
.celebration-sound {
  position: absolute;
  top: 12px;
  width: 36px;
  height: 36px;
  color: #8a5d00;
  background: rgba(255, 255, 255, 0.74);
  border: 0;
  border-radius: 50%;
  font-size: 1.15rem;
  font-weight: 900;
}

.celebration-close {
  right: 12px;
  font-size: 1.5rem;
}

.celebration-sound {
  left: 12px;
}

.celebration-ok {
  margin-top: 8px;
}

.pokemon-stage {
  position: relative;
  display: grid;
  place-items: end center;
  width: 220px;
  height: 190px;
  margin: 0 auto;
}

.pokemon-stage img {
  position: relative;
  z-index: 3;
  width: 190px;
  height: 190px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 12px 8px rgba(138, 93, 0, 0.2));
  animation: pokemonVictory 1.1s ease-in-out infinite;
}

.pokemon-fallback {
  position: absolute;
  z-index: 2;
  inset: 46px auto auto 50%;
  font-size: 5rem;
  transform: translateX(-50%);
  animation: fallbackSpark 0.8s ease-in-out infinite alternate;
}

.pokemon-glow {
  position: absolute;
  z-index: 1;
  bottom: 12px;
  width: 180px;
  height: 40px;
  background: color-mix(in srgb, var(--pokemon-accent, #f5c842) 58%, transparent);
  border-radius: 50%;
  filter: blur(8px);
  animation: pokemonGlow 1s ease-in-out infinite alternate;
}

.celebration-confetti,
.celebration-flashes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.celebration-confetti i {
  position: absolute;
  left: calc(var(--i) * 3.1%);
  top: -20px;
  width: 10px;
  height: 18px;
  background: hsl(calc(var(--i) * 47deg) 82% 58%);
  border-radius: 3px;
  animation: confettiFall calc(2.4s + var(--i) * 0.03s) linear infinite;
  animation-delay: calc(var(--i) * -0.06s);
}

.celebration-flashes i {
  position: absolute;
  left: calc(8% + (var(--i) * 12%));
  top: calc(12% + var(--i) * 7%);
  color: #ffdb3c;
  font-style: normal;
  font-size: clamp(1.8rem, 6vw, 4rem);
  text-shadow: 0 0 16px white;
  animation: lightningFlash 0.9s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.13s);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(61, 43, 31, 0.28);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(440px, 100%);
  padding: 22px;
  background: var(--pink);
  border: 1.5px solid var(--leaf-border);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(61, 43, 31, 0.18);
}

.modal-card p {
  margin: 12px 0 18px;
}

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

@keyframes celebrationBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes celebrationClose {
  to {
    opacity: 0;
    transform: scale(1.04);
  }
}

@keyframes celebrationCardPop {
  0% {
    opacity: 0;
    transform: translateY(50px) scale(0.65) rotate(-3deg);
  }
  70% {
    transform: translateY(-8px) scale(1.04) rotate(1deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0);
  }
}

@keyframes perfectCardEntrance {
  0% {
    opacity: 0;
    transform: scale(0.35) rotate(-12deg);
  }
  62% {
    transform: scale(1.12) rotate(3deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes perfectCardShine {
  from { filter: brightness(1); }
  to { filter: brightness(1.08) saturate(1.12); }
}

@keyframes perfectScorePulse {
  from { transform: scale(1); }
  to { transform: scale(1.09); }
}

@keyframes legendaryFloat {
  0%,
  100% { transform: translateY(3px) scale(0.98); }
  50% { transform: translateY(-18px) scale(1.08); }
}

@keyframes legendaryGlow {
  from { opacity: 0.58; transform: scale(0.72); }
  to { opacity: 1; transform: scale(1.28); }
}

@keyframes fireworkBurst {
  0% {
    opacity: 0;
    transform: scale(0.08);
  }
  35% { opacity: 1; }
  100% {
    opacity: 0;
    transform: scale(1.15);
  }
}

@keyframes pokemonVictory {
  0%,
  100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-14px) rotate(3deg); }
}

@keyframes fallbackSpark {
  from { transform: translateX(-50%) scale(0.85) rotate(-8deg); }
  to { transform: translateX(-50%) scale(1.15) rotate(8deg); }
}

@keyframes pokemonGlow {
  from { opacity: 0.45; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.15); }
}

@keyframes confettiFall {
  to {
    top: 110%;
    transform: translateX(calc((var(--i) - 16) * 3px)) rotate(calc(var(--i) * 70deg));
  }
}

@keyframes lightningFlash {
  0%,
  100% { opacity: 0.2; transform: scale(0.75) rotate(-8deg); }
  50% { opacity: 1; transform: scale(1.1) rotate(7deg); }
}

@keyframes starPop {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.2);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(
        calc((var(--i) - 2) * 12px),
        calc(-22px - (var(--i) * 4px))
      )
      scale(1.2);
  }
}

@keyframes flameBlink {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(245, 200, 66, 0));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 8px rgba(245, 200, 66, 0.9));
    transform: scale(1.12);
  }
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .sidebar {
    padding: 16px 10px;
  }

  .brand div,
  .nav-item span:last-child,
  .student-chip div {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

  .student-chip {
    justify-content: center;
  }

  .planner-quick-add,
  .scope-row,
  .ai-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .brand div,
  .nav-item span:last-child,
  .student-chip div {
    display: block;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    min-height: 56px;
    padding: 8px;
    flex-direction: column;
    gap: 2px;
    font-size: 0.78rem;
  }

  .nav-item.active::before {
    inset: auto auto -5px 50%;
    width: 28px;
    height: 4px;
    transform: translateX(-50%);
  }

  .student-chip {
    margin-top: 12px;
  }

  .main-area {
    padding: 18px 14px 30px;
  }

  .topbar,
  .progress-card,
  .mini-week header,
  .exam-card header,
  .score-card header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 1.55rem;
  }

  .inline-form,
  .inline-form.compact,
  .form-grid,
  .score-subject-grid,
  .goal-actions,
  .score-input-card {
    grid-template-columns: 1fr;
  }

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

  .day-column {
    min-width: 0;
  }

  .month-grid,
  .goal-grid,
  .exam-list,
  .score-list,
  .settings-grid,
  .score-semester-row {
    grid-template-columns: 1fr;
  }

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

  .calendar-card {
    overflow-x: auto;
  }

  .calendar-weekdays,
  .calendar-grid {
    min-width: 760px;
  }
}

@media print {
  body {
    color: #111;
    background: white;
  }

  .sidebar,
  .top-actions,
  .planner-quick-add,
  .flexible-slot-card,
  .print-only-hide,
  .toast,
  .modal-backdrop,
  .button,
  .lock-button,
  .text-danger {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main-area {
    padding: 0;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .card,
  .empty-card,
  .day-column,
  .slot-block,
  .task-row {
    color: #111;
    background: white !important;
    border-color: #777 !important;
    box-shadow: none !important;
  }

  .planner-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    overflow: visible;
  }

  .day-column {
    min-width: 0;
    padding: 8px;
    page-break-inside: avoid;
  }

  .task-row {
    grid-template-columns: auto auto 1fr;
    padding: 6px;
  }

  @page {
    size: A4;
    margin: 12mm;
  }
}
