:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1c2635;
  --muted: #5b6576;
  --primary: #4b6bfb;
  --primary-strong: #3c57d8;
  --border: #d8deea;
  --chip: #eef1f8;
  --chip-active: #dbe3ff;
  --shadow: 0 12px 30px rgba(28, 38, 53, 0.08);
  font-family: "SF Pro Text", "Inter", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body.theme-dark {
  --bg: #0f172a;
  --card: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #7c9dff;
  --primary-strong: #6b87ff;
  --border: #1f2937;
  --chip: #111827;
  --chip-active: #1f2a52;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

body.theme-jungle {
  color-scheme: light;
  --bg: #eef6e6;
  --card: #f6faef;
  --text: #27351f;
  --muted: #4a5a3f;
  --primary: #2f7d32;
  --primary-strong: #256a29;
  --border: #c6d5b5;
  --chip: #e6f0da;
  --chip-active: #cfe3b3;
  --shadow: 0 12px 30px rgba(39, 53, 31, 0.12);
}

.app-header,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 3vw, 40px);
  gap: 16px;
}

.app-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.welcome-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.welcome-card {
  background: var(--card);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 32px);
  width: min(520px, 100%);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  gap: 18px;
}

.welcome-text {
  color: var(--muted);
  margin: 0;
}

.inspiration-quote {
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #f2f5ff;
  border: 1px solid #dfe5ff;
}

.inspiration-quote__text {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.inspiration-quote__author {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

body.theme-dark .inspiration-quote {
  background: #0b1220;
  border-color: #2a3546;
}

body.theme-dark .inspiration-quote__text {
  color: #e5e7eb;
}

body.theme-dark .inspiration-quote__author {
  color: #9ca3af;
}

body.theme-jungle .inspiration-quote {
  background: #e6f3d9;
  border-color: #c6d5b5;
}

body.theme-jungle .inspiration-quote__author {
  color: var(--muted);
}

.inspiration-quote--header {
  flex: 1;
  text-align: center;
}

.app-screen.is-hidden,
.welcome-screen.is-hidden {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.invite-parent {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

body.theme-dark .icon-button {
  border-color: #334155;
  color: #e5e7eb;
  background: #0f172a;
}

body.theme-jungle .icon-button {
  border-color: #b7c8a4;
  background: #f0f7e7;
}

.help-popover {
  position: absolute;
  top: 42px;
  right: 0;
  width: min(260px, 70vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  color: var(--text);
  z-index: 5;
}

body.theme-dark .help-popover {
  background: #0b1220;
  border-color: #2a3546;
}

body.theme-jungle .help-popover {
  background: #f2f8ea;
  border-color: #c6d5b5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand__icon {
  font-size: 2.2rem;
}

.brand h1 {
  font-family: "Nunito", "Avenir Next Rounded", "Arial Rounded MT Bold",
    system-ui, sans-serif;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-panel {
  display: grid;
  gap: 6px;
  text-align: right;
}

.auth-status {
  font-weight: 600;
  font-size: 0.95rem;
}

.auth-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-form input {
  min-width: 200px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-form--stacked {
  display: grid;
  gap: 10px;
}

.auth-recovery__title {
  font-weight: 600;
  margin: 0;
}

.auth-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(320px, 1fr);
  gap: 24px;
  padding: 0 clamp(16px, 3vw, 40px) 32px;
}

.app-column {
  display: grid;
  gap: 24px;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

h1,
h2 {
  margin: 0 0 6px;
}

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

body.theme-dark p,
body.theme-dark label {
  color: #cbd5f5;
}

.task-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.timeline--grid {
  margin-top: 16px;
}

.task-form label {
  gap: 4px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font: inherit;
  background: #fff;
  color: var(--text);
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #0b1220;
  border-color: #2a3546;
  color: #e5e7eb;
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder {
  color: #94a3b8;
}

textarea {
  resize: vertical;
}

.primary-button,
.ghost-button {
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font: inherit;
  cursor: pointer;
  border: none;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

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

.primary-button--small {
  padding: 6px 12px;
  font-size: 0.9rem;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.ghost-button:hover {
  background: rgba(75, 107, 251, 0.08);
  border-color: #b9c7ff;
}

body.theme-dark .ghost-button {
  border-color: #334155;
  color: #e5e7eb;
}

body.theme-jungle .ghost-button:hover {
  background: rgba(47, 125, 50, 0.12);
  border-color: #7aa765;
}

.theme-button.is-active {
  background: var(--chip-active);
  border-color: var(--primary);
}

.auth-panel {
  display: grid;
  gap: 10px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-status {
  font-weight: 600;
}

.auth-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-user {
  font-size: 0.85rem;
  color: var(--muted);
}

body.theme-dark .auth-user {
  color: #cbd5f5;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.theme-switch--inline {
  margin-right: 4px;
}

.theme-switch__label {
  white-space: nowrap;
}

.theme-switch input {
  appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #d1d5db;
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  outline: none;
}

.theme-switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  transition: transform 0.2s ease;
}

.theme-switch input:checked {
  background: var(--primary);
}

.theme-switch input:checked::after {
  transform: translateX(18px);
}

.theme-dark .theme-switch input {
  background: #374151;
}

.theme-dark .theme-switch input::after {
  background: #0f172a;
}

.primary-button--small {
  padding: 8px 14px;
  font-size: 0.9rem;
}

.ghost-button--small {
  padding: 6px 12px;
  font-size: 0.9rem;
}

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

.card-header h2 {
  white-space: nowrap;
}

.task-form.is-collapsed {
  display: none;
}

.list-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.chip {
  background: var(--chip);
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
}

.chip--active {
  background: var(--chip-active);
  border-color: #b9c7ff;
  color: var(--primary-strong);
  font-weight: 600;
}

body.theme-dark .chip {
  background: #0f172a;
  border-color: #1f2937;
  color: #cbd5f5;
}

body.theme-dark .chip--active {
  background: #1f2a52;
  border-color: #425a9c;
  color: #dbe3ff;
}

body.theme-jungle .chip {
  background: #e6f0da;
  border-color: #c6d5b5;
  color: #2f3d25;
}

body.theme-jungle .chip--active {
  background: #cfe3b3;
  border-color: #7aa765;
  color: #1f2a1a;
}

.subject-lists {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.timeline {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fbfcff;
}

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

.timeline-title {
  font-weight: 700;
}

.timeline-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.timeline-actions {
  display: flex;
  gap: 8px;
}

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

.timeline.is-collapsed .timeline-days {
  display: none;
}

.timeline-day {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 2px 2px;
  border-radius: 12px;
  border: 1px solid transparent;
  min-height: 38px;
}

.timeline-day__date {
  font-size: 0.7rem;
  color: var(--muted);
}

body.theme-dark .timeline-day__date {
  color: #cbd5f5;
}

.timeline-day__date.is-today {
  color: var(--text);
  font-weight: 700;
  border: 1px solid #b9c7ff;
  border-radius: 999px;
  padding: 2px 6px;
  background: #eef1ff;
}

body.theme-dark .timeline-day__date.is-today {
  color: #0b1220;
  border-color: #7c9dff;
  background: #c7d2fe;
}

body.theme-jungle .timeline-day__date.is-today {
  color: #27351f;
  border-color: #9abb84;
  background: #d9ebc3;
}

.timeline-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

.timeline-dot--laxa {
  background: #4b6bfb;
}

.timeline-dot--prov {
  background: #ef476f;
}

.timeline-dot:focus-visible {
  outline: 2px solid #111827;
  outline-offset: 2px;
}

.task-item.is-highlighted {
  background: #f6f8ff;
  border-radius: 12px;
  padding: 10px;
}

.task-item.is-highlighted--laxa {
  border: 1px solid #b9c7ff;
}

.task-item.is-highlighted--prov {
  border: 1px solid #f6b4c6;
}

.subject-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #fbfcff;
}

body.theme-dark .subject-card,
body.theme-dark .timeline {
  background: #0b1220;
}

body.theme-jungle .timeline,
body.theme-jungle .subject-card {
  background: #f2f8ea;
}

body.theme-jungle .timeline-dot--laxa {
  background: #2f7d32;
}

body.theme-jungle .timeline-dot--prov {
  background: #b45309;
}

body.theme-jungle .task-item.is-highlighted {
  background: #edf5e3;
}

body.theme-jungle .task-item.is-highlighted--laxa {
  border-color: #9abb84;
}

body.theme-jungle .task-item.is-highlighted--prov {
  border-color: #d2a165;
}

.subject-card h3 {
  margin: 0 0 12px;
}

.task-item {
  display: grid;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.2s ease;
}

.task-item__main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.task-item:hover {
  background: var(--bg);
}

.task-item:last-child {
  border-bottom: none;
}

.task-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}

body.theme-dark .task-meta {
  color: #a5b4fc;
}

.task-type {
  font-weight: 600;
  color: var(--primary-strong);
}

.task-actions button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}

button:focus-visible {
  outline: 2px solid #111827;
  outline-offset: 2px;
}

body.theme-dark .task-actions button {
  color: #cbd5f5;
}


.empty-state {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: grid;
  align-items: stretch;
  justify-items: stretch;
  padding: 0;
  z-index: 1000;
}

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

.modal-card {
  width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  max-width: none;
  overflow: hidden;
  background: var(--card);
  border-radius: 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 16px;
  padding: 20px;
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.modal-form {
  position: sticky;
  bottom: 0;
  background: var(--card);
  padding-top: 8px;
  padding-bottom: env(safe-area-inset-bottom);
}

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

.modal-title {
  margin: 0;
}

.modal-pep {
  margin: 4px 0 0;
  color: var(--muted);
}

.modal-chat {
  background: #f7f9ff;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 1;
  min-height: 0;
  width: 100%;
  height: auto;
}

.modal-message {
  background: #ffffff;
  border: 1px solid #dfe5ff;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.95rem;
  color: var(--text);
}

.modal-message code.inline-math {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  background: #eef1ff;
  border: 1px solid #dfe5ff;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 0.9em;
}

.modal-message .math-block {
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f2f5ff;
  border: 1px solid #dfe5ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  white-space: pre-wrap;
}

.modal-message .inline-math {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  background: #eef1ff;
  border: 1px solid #dfe5ff;
  padding: 1px 6px;
  border-radius: 8px;
}

.modal-message .math-block code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 0.95em;
}

.modal-message--user {
  background: #eef6ff;
  border-color: #cfe0ff;
}

.progress-bar {
  width: 100%;
}

.progress-bar__track {
  width: 100%;
  height: 8px;
  background: #e3e8ff;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar__fill {
  width: 40%;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transform: translateX(-60%);
  animation: progress-bar 1.1s ease-in-out infinite;
}

@keyframes progress-bar {
  0% {
    transform: translateX(-60%);
  }
  50% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(60%);
  }
}

.modal-form {
  display: grid;
  gap: 10px;
}

.modal-form textarea {
  font-size: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

body.theme-dark .modal-chat {
  background: #0b1220;
}

body.theme-dark .modal-message {
  background: #111827;
  border-color: #2a3546;
  color: #e5e7eb;
}

body.theme-dark .modal-message code.inline-math {
  background: #1f2a52;
  border-color: #2f3d6a;
  color: #e5e7eb;
}

body.theme-dark .modal-message .math-block {
  background: #0b1220;
  border-color: #2a3546;
  color: #e5e7eb;
}

body.theme-dark .modal-message--user {
  background: #1f2a52;
  border-color: #2f3d6a;
}

@media (max-width: 900px) {
  .modal-overlay {
    padding: 0;
  }

  .modal-card {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
}

body.theme-dark .empty-state {
  border-color: #334155;
  color: #cbd5f5;
}

.assistant-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  touch-action: pan-y;
}

.assistant-card {
  width: min(720px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  gap: 20px;
}

.assistant-header {
  display: grid;
  gap: 6px;
}

.assistant-top {
  display: flex;
  justify-content: flex-start;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 0;
  background: var(--card);
}

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

.assistant-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.assistant-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.assistant-chat {
  display: grid;
  gap: 12px;
  max-height: min(45vh, 420px);
  overflow-y: auto;
  padding-right: 6px;
}

.assistant-message {
  padding: 12px 16px;
  border-radius: 16px;
  background: #f7f9ff;
  border: 1px solid #dfe5ff;
}

.assistant-message--user {
  background: #eef6ff;
  border-color: #d3e6ff;
}

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

.assistant-form textarea {
  min-height: 90px;
}

.assistant-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 900px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .auth-panel {
    text-align: left;
  }

  .inspiration-quote--header {
    width: 100%;
    text-align: left;
  }
}

@media (min-width: 901px) {
  .task-form,
  .task-form.is-collapsed {
    display: grid;
  }

  #toggleTaskForm {
    display: none;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 12.5px;
  }

  .app-header,
  .app-footer {
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
  }

  .brand {
    gap: 8px;
  }

  .brand__icon {
    font-size: 1.15rem;
  }

  .brand h1 {
    font-size: 0.95rem;
    line-height: 1.1;
  }

  .app-grid {
    gap: 10px;
    padding: 0 10px 16px;
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
  }

  .card {
    padding: 10px;
  }

  .card-header {
    gap: 6px;
  }

  h1,
  h2 {
    margin: 0 0 4px;
  }

  .inspiration-quote {
    padding: 6px 8px;
  }

  .inspiration-quote__text {
    font-size: 0.72rem;
  }

  .inspiration-quote__author {
    font-size: 0.62rem;
  }

  input,
  select,
  textarea {
    padding: 7px 9px;
  }

  .primary-button,
  .ghost-button {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .chips {
    gap: 6px;
  }

  .chip {
    padding: 4px 6px;
    font-size: 0.7rem;
  }

  .task-item {
    padding: 8px 0;
  }

  .task-meta {
    font-size: 0.7rem;
  }

  .modal-card {
    padding: 10px;
    gap: 8px;
  }

  .modal-chat {
    padding: 6px;
  }

  .modal-message {
    font-size: 0.78rem;
  }

  .timeline {
    padding: 6px;
  }

  .timeline-days {
    gap: 4px;
  }

  .timeline-day {
    padding: 4px 2px;
  }

  .timeline-day__date {
    font-size: 0.65rem;
  }

  .timeline-dot {
    width: 7px;
    height: 7px;
  }
}

@media (max-width: 430px) {
  body {
    font-size: 12px;
  }

  .app-header,
  .app-footer {
    padding: 6px 10px;
    padding-top: calc(6px + env(safe-area-inset-top));
  }

  .brand h1 {
    font-size: 0.9rem;
  }

  .card {
    padding: 9px;
  }

  .primary-button,
  .ghost-button {
    padding: 5px 9px;
    font-size: 0.75rem;
  }

  .chip {
    font-size: 0.68rem;
  }
}
