@import "https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap";

:root {
  color-scheme: dark;
  --bg: #020612;
  --bg-soft: #040c1e;
  --panel: #061127;
  --panel-strong: #0a1b38;
  --panel-soft: #0e244b;
  --panel-hover: #122b59;
  --ink: #eef4ff;
  --ink-2: #cddbf4;
  --muted: #839bc4;
  --muted-2: #5b7299;
  --line: #94a3b814;
  --line-mid: #94a3b82a;
  --line-strong: #7dd3fc3d;
  
  /* Sinai University theme colors (Deep Royal Blue & Cyan) */
  --brand: #0088ff;
  --brand-strong: #33a2ff;
  --brand-dim: #0088ff1a;
  --brand-glow: #0088ff26;
  
  --success: #10b981;
  --success-dim: #10b98114;
  --warning: #f59e0b;
  --warning-dim: #f59e0b12;
  --danger: #ef4444;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 0 3px rgba(0, 136, 255, 0.2);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  font-feature-settings: "kern" 1;
  font-family: Cairo, Segoe UI, Tahoma, Arial, sans-serif;
}

*, :before, :after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0, 136, 255, 0.08) 0%, transparent 65%), 
              radial-gradient(ellipse 50% 30% at 80% 0%, rgba(16, 185, 129, 0.03) 0%, transparent 55%), 
              var(--bg);
  margin: 0;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(4px);
  background: linear-gradient(rgba(4, 12, 30, 0.7), transparent);
  grid-template-columns: minmax(260px, 0.8fr) minmax(500px, 1.2fr);
  align-items: center;
  gap: 32px;
  padding: 36px clamp(18px, 4vw, 60px) 30px;
  display: grid;
}

.header-copy {
  min-width: 0;
}

.eyebrow {
  color: var(--brand-strong);
  letter-spacing: 0.01em;
  background: rgba(0, 136, 255, 0.08);
  border: 1px solid rgba(0, 136, 255, 0.22);
  border-radius: 999px;
  align-items: center;
  gap: 7px;
  margin: 0 0 14px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 800;
  display: inline-flex;
}

.eyebrow:before {
  content: "";
  background: var(--brand);
  width: 6px;
  height: 6px;
  box-shadow: 0 0 6px var(--brand);
  border-radius: 50%;
}

h1 {
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 900;
  line-height: 1.15;
}

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

.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  min-height: 126px;
  box-shadow: var(--shadow-sm);
  padding: 18px 17px 16px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.summary-card:before {
  content: "";
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, transparent 60%);
  position: absolute;
  inset: 0;
}

.summary-card:hover {
  border-color: var(--line-mid);
  box-shadow: var(--shadow-md);
  background: var(--panel-hover);
}

/* GPA Card Accent */
.summary-card.gpa-card {
  border-color: rgba(245, 158, 11, 0.2);
}

.summary-card.gpa-card:hover {
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 8px 28px rgba(245, 158, 11, 0.1);
}

.summary-card.gpa-card strong {
  color: #f59e0b;
}

.summary-card.gpa-card .summary-note {
  color: #fbbf24;
}

.summary-label, .field-label, label {
  color: var(--muted);
  letter-spacing: 0.02em;
  font-size: 0.8rem;
  font-weight: 700;
  display: block;
}

.summary-card strong {
  color: var(--ink);
  align-items: baseline;
  gap: 6px;
  margin-top: 10px;
  font-weight: 900;
  line-height: 1.1;
  display: flex;
}

.summary-card strong span {
  letter-spacing: -0.02em;
  direction: ltr;
  font-family: JetBrains Mono, Cairo, monospace;
  font-size: clamp(1.7rem, 2.8vw, 2.4rem);
}

.summary-card strong small {
  color: var(--muted-2);
  font-family: Cairo, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
}

.summary-note {
  min-height: 18px;
  color: var(--warning);
  margin-top: 14px;
  font-size: 0.8rem;
  font-weight: 700;
  display: block;
}

.meter {
  background: rgba(148, 163, 184, 0.1);
  border-radius: 999px;
  height: 5px;
  margin-top: 18px;
  overflow: hidden;
}

.meter span {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-strong) 100%);
  width: 0%;
  height: 100%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
  box-shadow: 0 0 8px rgba(0, 136, 255, 0.4);
}

.app-layout {
  grid-template-columns: minmax(240px, 290px) minmax(0, 1fr);
  align-items: start;
  gap: 22px;
  padding: 28px clamp(18px, 4vw, 60px) 56px;
  display: grid;
}

.control-panel {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  gap: 16px;
  padding: 18px 16px;
  display: grid;
  position: sticky;
  top: 20px;
}

.field {
  gap: 7px;
  display: grid;
}

input[type=search], input[type=url], select {
  border: 1px solid var(--line-mid);
  border-radius: var(--r-md);
  background: var(--panel-strong);
  width: 100%;
  min-height: 42px;
  color: var(--ink);
  appearance: none;
  outline: none;
  padding: 0 12px;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238196b4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-position: 12px;
  background-repeat: no-repeat;
  padding-left: 34px;
}

input[type=search]::placeholder, input[type=url]::placeholder {
  color: var(--muted-2);
}

input[type=search]:focus, input[type=url]:focus, select:focus {
  border-color: var(--brand);
  background: var(--panel-soft);
  box-shadow: var(--shadow-glow);
}

.segmented {
  border: 1px solid var(--line-mid);
  border-radius: var(--r-md);
  background: var(--panel-strong);
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 3px;
  display: grid;
}

.segmented button {
  border-radius: var(--r-sm);
  min-height: 36px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0 6px;
  font-size: 0.86rem;
  font-weight: 800;
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}

.segmented button:hover:not(.is-active) {
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.04);
}

.segmented button.is-active {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 136, 255, 0.35);
}

.course-area {
  min-width: 0;
}

.course-toolbar {
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  margin-bottom: 20px;
  display: flex;
}

.result-count {
  color: var(--ink);
  margin: 0;
  font-size: 1.1rem;
  font-weight: 900;
}

.filter-hint {
  min-height: 18px;
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 0.86rem;
}

.legend {
  color: var(--muted);
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
}

.legend span {
  align-items: center;
  gap: 6px;
  display: inline-flex;
}

.dot {
  border-radius: 50%;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
}

.dot.done {
  background: var(--success);
  box-shadow: 0 0 5px rgba(16, 185, 129, 0.5);
}

.dot.ready {
  background: var(--brand);
  box-shadow: 0 0 5px rgba(0, 136, 255, 0.5);
}

.dot.blocked {
  background: var(--warning);
  box-shadow: 0 0 5px rgba(245, 158, 11, 0.5);
}

.course-groups {
  gap: 30px;
  display: grid;
}

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

.group-title {
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  letter-spacing: 0;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  padding-bottom: 10px;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  font-weight: 900;
  display: flex;
}

.group-title span {
  color: var(--muted-2);
  font-family: JetBrains Mono, monospace;
  font-size: 0.8rem;
  font-weight: 500;
}

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

.course-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  border-right: 3px solid var(--brand);
  background: var(--panel);
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  min-height: 180px;
  padding: 14px 14px 14px 12px;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s, border-color 0.18s, background 0.18s;
  display: grid;
  position: relative;
  overflow: hidden;
}

.course-card:after {
  content: "";
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
  position: absolute;
  inset: 0;
}

.course-card:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
  transform: translateY(-3px);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 136, 255, 0.08);
}

.course-card.is-complete {
  border-right-color: var(--success);
  background: rgba(16, 185, 129, 0.05);
}

.course-card.is-complete:hover {
  border-color: rgba(16, 185, 129, 0.3);
}

.course-card.is-blocked:not(.is-complete) {
  border-right-color: var(--warning);
  background: rgba(245, 158, 11, 0.03);
}

.course-card.is-blocked:not(.is-complete):hover {
  border-color: rgba(245, 158, 11, 0.2);
}

.course-toggle {
  justify-content: center;
  align-items: flex-start;
  padding-top: 3px;
  display: flex;
}

.course-toggle input {
  clip: rect(0, 0, 0, 0);
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
}

.fake-check {
  border-radius: var(--r-sm);
  background: var(--panel-strong);
  border: 1.5px solid rgba(148, 163, 184, 0.3);
  place-items: center;
  width: 28px;
  height: 28px;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s, transform 0.12s;
  display: grid;
}

.fake-check:after {
  content: "";
  opacity: 0;
  border: 2.5px solid #020612;
  border-width: 0 2.5px 2.5px 0;
  width: 6px;
  height: 11px;
  transition: opacity 0.14s;
  transform: rotate(45deg) translateY(-1px);
}

.course-toggle input:checked + .fake-check {
  border-color: var(--success);
  background: var(--success);
  transform: scale(1.05);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.course-toggle input:checked + .fake-check:after {
  opacity: 1;
}

.course-toggle input:focus-visible + .fake-check {
  box-shadow: var(--shadow-glow);
}

.course-body {
  min-width: 0;
}

.course-head {
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  display: flex;
}

.head-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.course-code {
  border-radius: var(--r-sm);
  background: var(--brand-dim);
  min-height: 28px;
  color: var(--brand-strong);
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid rgba(51, 162, 255, 0.15);
  align-items: center;
  padding: 0 9px;
  font-family: JetBrains Mono, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
}

.credit-badge {
  color: var(--muted-2);
  flex: none;
  font-family: JetBrains Mono, monospace;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Dynamic Grade Select Dropdown */
.grade-select-wrapper {
  position: relative;
  display: inline-flex;
}

.grade-select {
  border: 1px solid var(--line-mid);
  border-radius: var(--r-sm);
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  min-height: 28px;
  height: 28px;
  padding: 0 8px 0 22px; /* space for arrow on left since RTL layout */
  outline: none;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, opacity 0.18s;
  appearance: none;
  
  /* Styled arrow icon */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23839bc4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-position: 6px center;
  background-repeat: no-repeat;
  background-size: 8px;
}

.grade-select:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  background-color: transparent;
  border-color: var(--line);
  color: var(--muted-2);
  background-image: none;
  padding-left: 8px; /* remove arrow padding when disabled */
}

.grade-select:focus:not(:disabled) {
  border-color: var(--brand);
  background-color: var(--panel-soft);
  box-shadow: 0 0 0 2px rgba(0, 85, 255, 0.15);
}

.course-card h3 {
  color: var(--ink);
  letter-spacing: 0;
  overflow-wrap: anywhere;
  margin: 12px 0 6px;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.5;
}

.english-name {
  min-height: 34px;
  color: var(--muted);
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.course-meta {
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  display: flex;
}

.tag {
  border: 1px solid var(--line-mid);
  min-height: 24px;
  color: var(--muted);
  letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  justify-content: center;
  align-items: center;
  padding: 0 9px;
  font-size: 0.74rem;
  font-weight: 800;
  transition: border-color 0.16s;
  display: inline-flex;
}

.tag.required {
  color: var(--brand-strong);
  background: var(--brand-dim);
  border-color: rgba(0, 136, 255, 0.15);
}

.tag.warning {
  background: var(--warning-dim);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.25);
}

.tag.ready {
  color: var(--success);
  background: var(--success-dim);
  border-color: rgba(16, 185, 129, 0.2);
}

.empty-state {
  border: 1px dashed var(--line-mid);
  border-radius: var(--r-lg);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  padding: 40px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.7;
}

.sr-only {
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  position: absolute;
  overflow: hidden;
}

body:before {
  content: "";
  background: linear-gradient(90deg, transparent, var(--brand), var(--success), transparent);
  opacity: 0.6;
  z-index: 100;
  pointer-events: none;
  height: 2px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

/* ── Moodle Integration ─────────────────────────────────────── */
.moodle-settings-field {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.moodle-input-wrapper {
  position: relative;
}

.moodle-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  border-radius: var(--r-sm);
  border: 0;
  color: #fff;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.16s, box-shadow 0.16s;
  flex: 1;
  text-align: center;
}

.btn-primary {
  background: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-strong);
  box-shadow: 0 4px 14px rgba(0, 136, 255, 0.35);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #ff5555;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.moodle-status {
  margin: 6px 0 0;
  font-size: 0.78rem;
  font-weight: 700;
}

.moodle-status.success {
  color: var(--success);
}

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

.moodle-status.loading {
  color: var(--brand-strong);
}

.moodle-instruction-link {
  background: transparent;
  border: 0;
  color: var(--brand-strong);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: right;
  padding: 4px 0;
  margin-top: 6px;
  text-decoration: underline;
}

.moodle-instruction-link:hover {
  color: #fff;
}

.moodle-instructions {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  margin-top: 8px;
  font-size: 0.76rem;
  line-height: 1.6;
}

.moodle-instructions h4 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 0.8rem;
}

.moodle-instructions ol {
  margin: 0;
  padding-right: 16px;
  color: var(--muted);
}

.moodle-instructions li {
  margin-bottom: 6px;
}

.moodle-instructions a {
  color: var(--brand-strong);
  text-decoration: underline;
}

/* ── Moodle Tasks Widget ────────────────────────────────────── */
.moodle-tasks-section {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(0, 136, 255, 0.03) 0%, rgba(4, 12, 30, 0.5) 100%);
  border-right: 3px solid var(--brand);
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.moodle-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.moodle-section-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.moodle-section-header h3 i {
  color: var(--brand-strong);
  animation: pulseBell 2s infinite;
}

.tasks-count-badge {
  background: var(--brand-dim);
  color: var(--brand-strong);
  border: 1px solid rgba(51, 162, 255, 0.25);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-left: 4px; /* for scrollbar */
}

/* Custom scrollbar for task list */
.tasks-list::-webkit-scrollbar {
  width: 5px;
}

.tasks-list::-webkit-scrollbar-track {
  background: transparent;
}

.tasks-list::-webkit-scrollbar-thumb {
  background: var(--line-mid);
  border-radius: 999px;
}

.tasks-list::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
}

.task-item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  transition: border-color 0.16s, background 0.16s, opacity 0.2s, transform 0.16s;
  position: relative;
}

.task-item:hover {
  background: var(--panel-soft);
  transform: translateX(-2px);
}

.task-toggle-label {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 2px;
  cursor: pointer;
}

.task-toggle-label input {
  clip: rect(0, 0, 0, 0);
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
}

.fake-task-check {
  border-radius: 50%; /* circular checklist */
  background: var(--panel-strong);
  border: 1.5px solid rgba(148, 163, 184, 0.3);
  place-items: center;
  width: 22px;
  height: 22px;
  transition: border-color 0.16s, background 0.16s, transform 0.12s;
  display: grid;
}

.fake-task-check:after {
  content: "";
  opacity: 0;
  border: 2px solid #020612;
  border-width: 0 2px 2px 0;
  width: 4px;
  height: 8px;
  transition: opacity 0.14s;
  transform: rotate(45deg) translateY(-1px);
}

.task-toggle-label input:checked + .fake-task-check {
  border-color: var(--success);
  background: var(--success);
  transform: scale(1.05);
}

.task-toggle-label input:checked + .fake-task-check:after {
  opacity: 1;
}

.task-body {
  min-width: 0;
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.task-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.task-title-link {
  color: #38bdf8;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  transition: color 0.15s ease;
}

.task-title-link:hover {
  color: #7dd3fc;
  text-decoration: underline;
}

.task-course-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  min-height: 20px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-desc {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.74rem;
}

.task-date {
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-countdown {
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
}

/* Urgency States */
/* 1. Urgent (Under 24 hours) */
.task-item.is-urgent {
  border-right: 3px solid var(--danger);
}
.task-item.is-urgent .task-countdown {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.2);
}

/* 2. Soon (Under 3 days) */
.task-item.is-soon {
  border-right: 3px solid var(--warning);
}
.task-item.is-soon .task-countdown {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* 3. Future (Over 3 days) */
.task-item.is-future {
  border-right: 3px solid var(--brand);
}
.task-item.is-future .task-countdown {
  background: var(--brand-dim);
  color: var(--brand-strong);
  border: 1px solid rgba(51, 162, 255, 0.2);
}

/* 4. Completed */
.task-item.is-completed {
  opacity: 0.45;
  border-right: 3px solid var(--success);
}
.task-item.is-completed .task-title {
  text-decoration: line-through;
  color: var(--muted);
}
.task-item.is-completed .task-countdown {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ── Target GPA Simulator ────────────────────────────────────── */
.gpa-simulator-field {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.gpa-simulator-input-group {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.gpa-simulator-input-group input {
  flex: 2;
  outline: none;
}

.gpa-simulator-input-group button {
  flex: 1;
}

.gpa-simulator-result {
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: var(--r-md);
  line-height: 1.5;
}

.gpa-simulator-result.impossible {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.gpa-simulator-result.easy {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.gpa-simulator-result.normal {
  background: rgba(0, 136, 255, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(0, 136, 255, 0.2);
}

.gpa-simulator-result.warning {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ── Smart Registration Planner ────────────────────────────────────── */
.planner-section {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(4, 12, 30, 0.5) 100%);
  border-right: 3px solid #8b5cf6;
  padding: 18px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.planner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.planner-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.planner-header h3 i {
  color: #a78bfa;
}

.planner-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.planner-select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
}

.planner-select-wrapper select {
  padding: 6px 12px;
  font-size: 0.82rem;
  background: var(--panel-strong);
  border: 1px solid var(--line-mid);
  border-radius: var(--r-sm);
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

.planner-select-wrapper select:focus {
  border-color: #8b5cf6;
}

.planner-result {
  margin-top: 14px;
  animation: fadeIn 0.3s ease;
}

.planner-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 14px;
  border-radius: var(--r-md);
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

.planner-status-badge {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.planner-summary p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.5;
}

.planner-courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.planner-course-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.16s, border-color 0.16s;
}

.planner-course-card:hover {
  transform: translateY(-2px);
  border-color: #8b5cf6;
}

.planner-course-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.planner-course-code {
  font-family: monospace;
  font-size: 0.74rem;
  font-weight: 800;
  color: #a78bfa;
}

.planner-course-title {
  margin: 2px 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.planner-course-english {
  font-size: 0.76rem;
  color: var(--muted-2);
}

.planner-course-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.planner-course-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--r-sm);
}

.planner-course-badge.core {
  background: rgba(0, 136, 255, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(0, 136, 255, 0.2);
}

.planner-course-badge.filler {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.planner-course-badge.blocked {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.planner-course-credits {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
}

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

@keyframes pulseBell {
  0%, 100% {
    transform: rotate(0);
  }
  20%, 60% {
    transform: rotate(-10deg);
  }
  40%, 80% {
    transform: rotate(10deg);
  }
}

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: 1fr;
  }
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .control-panel {
    position: static;
  }
  .course-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: clamp(1.4rem, 6vw, 2.2rem);
  }
  .app-header {
    padding: 22px 14px 20px;
  }
  .app-layout {
    padding: 18px 14px 40px;
  }
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .summary-card {
    min-height: 100px;
    padding: 14px 13px 12px;
  }
  .course-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .legend {
    justify-content: flex-start;
  }
  .course-card {
    grid-template-columns: 36px minmax(0, 1fr);
    min-height: 0;
  }
}
