@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --muted-surface: #eef1f4;
  --border: #d6dbe1;
  --text: #1c1f24;
  --muted: #5a6677;
  --accent: #1e7ea6;
  --accent-strong: #166381;
  --shadow: 0 12px 30px rgba(23, 42, 66, 0.08);
  --radius: 16px;
}

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

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  margin: 0;
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg) 55%, #eef0f2 100%);
  color: var(--text);
  min-height: 100vh;
}

.center {
  text-align: center;
  padding: 72px 20px 40px;
}

.loading-screen {
  position: fixed;
  inset: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg) 55%, #eef0f2 100%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loader {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(30, 126, 166, 0.2);
  border-top-color: rgba(30, 126, 166, 0.85);
  animation: spin 0.9s linear infinite;
}

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

.hidden {
  display: none !important;
}

.title {
  margin: 0 0 6px;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 1rem;
}

#user {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 4px 0 0;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 18px 40px;
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.app-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.subjects {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 8px 4px 10px;
  gap: 10px;
  margin-bottom: 16px;
  scrollbar-width: thin;
}

.home-screen {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.home-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.subject-cards {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

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

.subject {
  border: 1px solid transparent;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--muted-surface);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.subject.active,
.subject:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 6px 14px rgba(30, 126, 166, 0.1);
}

.subject-card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid rgba(214, 219, 225, 0.7);
  padding: 14px 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.subject-card.active {
  border-color: rgba(30, 126, 166, 0.5);
  box-shadow: 0 12px 24px rgba(30, 126, 166, 0.16);
}

.subject-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.subject-card-grade {
  font-weight: 700;
  color: var(--text);
}

.subject-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.subject-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(30, 126, 166, 0.12);
  overflow: hidden;
}

.subject-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(30, 126, 166, 0.7), rgba(30, 126, 166, 0.2));
  border-radius: 999px;
  transition: width 0.2s ease;
}

#grades {
  display: grid;
  gap: 14px;
}

.summary-bar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(214, 219, 225, 0.7);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-bar.final {
  background: linear-gradient(120deg, rgba(30, 126, 166, 0.15), rgba(255, 255, 255, 0.85));
  border-color: rgba(30, 126, 166, 0.4);
}

.summary-bar.final .summary-label {
  color: var(--accent-strong);
  font-size: clamp(1.05rem, 2.6vw, 1.25rem);
}

.summary-bar.final .summary-value {
  color: var(--text);
  font-weight: 700;
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}


.summary-label {
  font-weight: 600;
}

.summary-value {
  color: var(--muted);
}

.card {
  background: var(--surface);
  padding: 16px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(214, 219, 225, 0.7);
  position: relative;
  overflow: hidden;
}

.card.perfect {
  border-color: rgba(166, 94, 255, 0.6);
  box-shadow:
    0 12px 30px rgba(23, 42, 66, 0.1),
    0 0 18px rgba(166, 94, 255, 0.3);
}

.card.perfect::after {
  content: "";
  position: absolute;
  inset: -30%;
  background: conic-gradient(
    from 0deg,
    rgba(255, 255, 255, 0.5),
    rgba(166, 94, 255, 0.2),
    rgba(255, 255, 255, 0.4),
    rgba(116, 56, 210, 0.2),
    rgba(255, 255, 255, 0.5)
  );
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.card.perfect:hover::after {
  opacity: 0.35;
  animation: halo-spin 3s linear infinite;
}

.card.perfect .status-chip.perfect {
  animation: chip-pulse 2.5s ease-in-out infinite;
}

@keyframes halo-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes chip-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}
.card-body {
  position: relative;
  z-index: 2;
}

.water {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.water-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  transition: height 0.25s ease;
  opacity: 0.25;
}

.water-fill.excellent {
  background: linear-gradient(180deg, rgba(30, 126, 166, 0.65), rgba(30, 126, 166, 0.2));
}

.water-fill.passing {
  background: linear-gradient(180deg, rgba(40, 158, 92, 0.6), rgba(40, 158, 92, 0.18));
}

.water-fill.failing {
  background: linear-gradient(180deg, rgba(204, 66, 66, 0.5), rgba(204, 66, 66, 0.16));
}

.water-fill.perfect {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.85), transparent 35%),
    radial-gradient(circle at 70% 35%, rgba(255, 255, 255, 0.7), transparent 40%),
    radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.7), transparent 40%),
    linear-gradient(180deg, rgba(166, 94, 255, 0.7), rgba(116, 56, 210, 0.35));
  position: relative;
  overflow: hidden;
}

.water-fill.perfect::before,
.water-fill.perfect::after {
  content: "";
  position: absolute;
  inset: -50%;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(255, 255, 255, 0.7) 0 1.5px, transparent 3px),
    radial-gradient(circle, rgba(255, 255, 255, 0.8) 0 1px, transparent 2px);
  background-size: 120px 120px, 90px 90px, 60px 60px;
  opacity: 0.45;
  transform: translateY(0);
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.water-fill.perfect::after {
  opacity: 0.2;
  background-size: 160px 160px, 120px 120px, 80px 80px;
  animation-delay: 0.2s;
}

.card:hover .water-fill.perfect::before,
.card:hover .water-fill.perfect::after {
  animation: sparkle-move 2.4s linear infinite;
  opacity: 0.7;
}

@keyframes sparkle-move {
  0% {
    transform: translateY(0) translateX(0);
  }
  100% {
    transform: translateY(-20%) translateX(10%);
  }
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.card p {
  margin: 4px 0;
  color: var(--muted);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 8px;
}

.status-chip.excellent {
  background: rgba(30, 126, 166, 0.15);
  color: #166381;
}

.status-chip.passing {
  background: rgba(40, 158, 92, 0.15);
  color: #1f7b49;
}

.status-chip.failing {
  background: rgba(204, 66, 66, 0.15);
  color: #b43838;
}

.status-chip.perfect {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.7), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.6), transparent 40%),
    linear-gradient(90deg, rgba(166, 94, 255, 0.35), rgba(116, 56, 210, 0.2));
  color: #3b1f6b;
}

.status-chip.perfect::after {
  content: "✦";
  margin-left: 4px;
  font-size: 0.8rem;
}

.unsaved-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #8a6a00;
  background: rgba(234, 179, 8, 0.16);
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.unsaved-indicator.show {
  display: inline-flex;
}

.input-help {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: #b43838;
}

input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fbfcfd;
  font-size: 1rem;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  min-width: 0;
}

.score-row input {
  margin-top: 0;
  flex: 1 1 55%;
  width: auto;
  min-width: 6.5ch;
  max-width: 35%;
  text-align: center;
}

.perfect-pill {
  min-width: 72px;
  text-align: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f1f3f6;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
}

button {
  font: inherit;
}

.primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 20px rgba(30, 126, 166, 0.25);
}

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

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}


.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #2b2f33;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(23, 42, 66, 0.08);
}

.google-btn:hover {
  border-color: #c3c9d1;
  box-shadow: 0 12px 22px rgba(23, 42, 66, 0.12);
}

.google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #e2e6ea;
}

.helper-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.helper-text.muted {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #7a8796;
}


.save-banner {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(214, 219, 225, 0.7);
  box-shadow: 0 -8px 20px rgba(23, 42, 66, 0.08);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 15;
  width: min(100%, 980px);
  margin: 0 auto;
}

.save-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
}

#save-status {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (min-width: 720px) {
  .save-banner {
    padding: 14px 24px;
    border-radius: 16px 16px 0 0;
    gap: 32px;
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 28, 38, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.modal-card {
  background: var(--surface);
  width: min(640px, 92vw);
  max-height: 85vh;
  overflow: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(214, 219, 225, 0.7);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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


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

.summary-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-section + .summary-section {
  margin-top: 16px;
}

.summary-section h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}

.summary-item {
  background: #fbfcfd;
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(214, 219, 225, 0.7);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.missing-chip {
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(234, 179, 8, 0.4);
  background: rgba(234, 179, 8, 0.12);
  color: #8a6a00;
}


.summary-item .summary-score {
  font-weight: 600;
  color: var(--text);
}

.summary-item strong {
  font-size: 1rem;
}

.summary-averages {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.summary-average-card {
  background: rgba(30, 126, 166, 0.08);
  border: 1px solid rgba(30, 126, 166, 0.2);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-average-card h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.summary-average-score {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.parent-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.parent-form input {
  flex: 1 1 220px;
}

.parent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.invite-code {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(214, 219, 225, 0.7);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invite-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.invite-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px dashed rgba(30, 126, 166, 0.5);
  color: var(--accent-strong);
  font-weight: 700;
  background: rgba(30, 126, 166, 0.08);
}

.parent-chip {
  background: #fbfcfd;
  border: 1px solid rgba(214, 219, 225, 0.7);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.parent-remove {
  border: none;
  background: transparent;
  color: #b43838;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
}

.parent-remove:disabled {
  color: #a7b0bc;
  cursor: not-allowed;
}

.chatbot {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 25;
}

.chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(30, 126, 166, 0.25);
}

.chat-toggle-icon {
  font-size: 1.1rem;
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 60px;
  width: min(360px, 90vw);
  max-height: 70vh;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(214, 219, 225, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(214, 219, 225, 0.7);
}

.chat-header .helper-text {
  margin: 2px 0 0;
}

.chat-messages {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 46vh;
}

.chat-message {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  max-width: 90%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.chat-message.bot {
  background: #f1f4f8;
  color: var(--text);
  align-self: flex-start;
}

.chat-message.user {
  background: rgba(30, 126, 166, 0.18);
  color: var(--text);
  align-self: flex-end;
}

.chat-options {
  padding: 10px 14px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid rgba(214, 219, 225, 0.5);
  background: #fbfcfd;
}

.chat-option {
  border: 1px solid rgba(214, 219, 225, 0.8);
  background: #ffffff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-option.primary {
  border-color: rgba(30, 126, 166, 0.5);
  background: rgba(30, 126, 166, 0.12);
}

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

.typing-dot {
  width: 6px;
  height: 6px;
  background: #8b97a6;
  border-radius: 50%;
  animation: typing-bounce 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.chat-cards {
  display: grid;
  gap: 8px;
}

.chat-card {
  background: #ffffff;
  border: 1px solid rgba(214, 219, 225, 0.7);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-card strong {
  font-size: 0.95rem;
}

.card.focus-card {
  border-color: rgba(30, 126, 166, 0.6);
  box-shadow: 0 12px 24px rgba(30, 126, 166, 0.18);
}

@media (min-width: 720px) {
  .subject-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (min-width: 720px) {
  .app-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  #grades {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .subject-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #grades {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
