/* Student Planner styles */

:root {
  --bg: #f6f3fc;
  --card: #fff;
  --ink: #1f1a2e;
  --muted: #6b6582;
  --line: #e8e3f3;
  --soft: #efe9fb;
  --primary: #7c3aed;
  --accent: #db2777;
  --brand: linear-gradient(135deg, #7c3aed, #db2777);
  --low: #15803d;
  --medium: #b45309;
  --high: #c81e1e;
  --info: #2563eb;
  --shadow: 0 6px 20px #4c1d9514;
  --radius: 18px;
  --sans: 'DM Sans', system-ui, Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #15121f;
  --card: #1f1b2d;
  --ink: #f1edfa;
  --muted: #a39dba;
  --line: #2f2944;
  --soft: #2a2340;
  --primary: #a78bfa;
  --accent: #f472b6;
  --low: #4ade80;
  --medium: #fbbf24;
  --high: #f87171;
  --info: #60a5fa;
  --shadow: 0 6px 20px #0000004d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }

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

.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Layout ---------- */

.app {
  max-width: 560px; margin: 0 auto; min-height: 100vh;
  padding: 0 16px calc(150px + env(safe-area-inset-bottom));
}

/* The Duedly header: the same on every screen, and stays at the top while scrolling. */
.topbar {
  position: sticky; top: 0; z-index: 9;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -16px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  color: var(--ink); text-decoration: none;
}
.brand img { border-radius: 11px; box-shadow: var(--shadow); flex: none; }
.brand span {
  font-size: 22px; font-weight: 700; letter-spacing: -.5px;
  background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* The screen's own title under the header, e.g. "Tasks · 3 pending". */
.page-head { padding: 16px 0 14px; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.4px; line-height: 1.15; text-wrap: balance; }
.page-head p { font-size: 14px; margin-top: 4px; max-width: 46ch; }

main:focus { outline: none; }

/* "You're offline" / "Saving 2 changes…" bar under the header */
.sync {
  --c: var(--info);
  display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 10px 12px;
  border-radius: 12px; font-size: 13px; font-weight: 600;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
}
.sync.offline { --c: var(--medium); }
.sync .ico { width: 18px; height: 18px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.get-app {
  display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700;
  box-shadow: 0 6px 14px #7c3aed33;
}
.get-app .ico { width: 18px; height: 18px; }


.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: grid; place-items: center;
}
.icon-btn.on-color { background: #ffffff2e; border-color: #ffffff40; color: #fff; }
.icon-btn.avatar { background: var(--brand); border: 0; color: #fff; font-weight: 700; font-size: 16px; }

/* Bottom tab bar */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 10;
  width: 100%; max-width: 560px;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px #4c1d950d;
}
.tabbar button {
  border: 0; background: none; color: var(--muted);
  display: grid; justify-items: center; gap: 3px; padding: 6px 0; border-radius: 12px;
  font-size: 11.5px; font-weight: 600;
}
.tabbar button.active { color: var(--primary); background: var(--soft); }

.fab {
  position: fixed; z-index: 11;
  right: max(16px, calc(50% - 280px + 16px));
  bottom: calc(82px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 16px; padding: 14px 18px;
  background: var(--brand); color: #fff; font-weight: 700;
  box-shadow: 0 10px 24px #7c3aed4d;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 12px 18px; min-height: 46px;
  background: var(--brand); color: #fff; font-weight: 700;
}
.btn.ghost { background: var(--soft); color: var(--primary); }
.btn.danger { background: var(--high); color: #fff; }
.btn.danger-text { color: var(--high); }
.btn.block { width: 100%; }
.btn.grow { flex: 1; }

/* ---------- Cards and sections ---------- */

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

.section-title { font-size: 16px; font-weight: 700; margin: 24px 0 10px; }
.section-title.late { color: var(--high); }

.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px; border-radius: 22px; color: #fff;
  background: var(--brand); box-shadow: 0 12px 28px #7c3aed40;
}
.hero-kicker { font-size: 13px; opacity: .85; }
.hero h2 { font-size: 21px; margin: 4px 0 6px; letter-spacing: -.3px; }
.hero-sub { font-size: 13px; opacity: .9; }

.ring {
  --pct: 0;
  width: 76px; height: 76px; flex: none; border-radius: 50%;
  background: conic-gradient(#fff calc(var(--pct) * 1%), #ffffff40 0);
  display: grid; place-items: center;
}
.ring span {
  width: 60px; height: 60px; border-radius: 50%; background: #5b21b6;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px; display: grid; gap: 2px;
}
.stat b { font-size: 22px; }
.stat small { color: var(--muted); font-size: 12.5px; }
.stat-ico {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 6px;
}
.stat-ico .ico { width: 18px; height: 18px; }
.stat-ico.pending { color: var(--info); background: color-mix(in srgb, var(--info) 14%, transparent); }
.stat-ico.done { color: var(--low); background: color-mix(in srgb, var(--low) 14%, transparent); }
.stat-ico.late { color: var(--high); background: color-mix(in srgb, var(--high) 14%, transparent); }

/* ---------- Task rows ---------- */

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

.task {
  display: flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 6px 12px 6px 6px; position: relative; overflow: hidden;
}
/* Subject color strip on the left. */
.task::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--subject);
}

.check {
  width: 44px; height: 44px; flex: none; border: 0; background: none;
  display: grid; place-items: center; margin-left: 4px;
}
.check .ico {
  width: 26px; height: 26px; padding: 4px; border-radius: 50%;
  border: 2px solid var(--line); stroke: transparent; stroke-width: 3;
}
.check:hover .ico { border-color: var(--subject); }
.check[aria-pressed="true"] .ico { background: var(--subject); border-color: var(--subject); stroke: #fff; }

.task-main {
  flex: 1; min-width: 0; border: 0; background: none; text-align: left;
  display: grid; gap: 2px; padding: 8px 4px;
}
.task-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta.late { color: var(--high); font-weight: 600; }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }

.chip {
  flex: none; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
}
.chip.p0 { --c: var(--low); }
.chip.p1 { --c: var(--medium); }
.chip.p2 { --c: var(--high); }
.chip.done { --c: var(--low); }
.chip.late { --c: var(--high); }
.chip.pending { --c: var(--info); }

/* ---------- Tasks screen ---------- */

.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: var(--soft); border-radius: 14px; padding: 4px;
}
.tabs button {
  border: 0; background: none; border-radius: 11px; padding: 9px 2px;
  font-weight: 600; font-size: 13.5px; color: var(--muted); white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px;
  font-size: 11.5px; background: var(--line); margin-left: 2px;
}

.filter { display: block; margin: 12px 0; }
.filter select, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 11px 12px; min-height: 46px;
}

/* ---------- Planner ---------- */

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { border: 0; background: none; font-weight: 700; font-size: 16px; padding: 8px 12px; border-radius: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-week span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal-grid button {
  border: 0; background: none; border-radius: 12px; aspect-ratio: 1; min-height: 40px;
  display: grid; align-content: center; justify-items: center; gap: 2px; font-weight: 600; font-size: 14px;
}
.cal-grid button:hover { background: var(--soft); }
.cal-grid button.today { color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.cal-grid button.late:not(.selected) { color: var(--high); }
.cal-grid button.selected { background: var(--brand); color: #fff; box-shadow: 0 6px 14px #db277740; }
.dots { display: flex; gap: 2px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; }
.dots .done-dot { background: var(--muted); opacity: .5; }
.selected .dots i { background: #fff !important; }

/* ---------- Subjects ---------- */

.subjects { display: grid; gap: 12px; }
.subject {
  position: relative; overflow: hidden; border-radius: 20px; color: #fff;
  display: flex; align-items: flex-start; gap: 8px; padding: 16px;
  box-shadow: var(--shadow);
}
.subject-main {
  flex: 1; min-width: 0; border: 0; background: none; color: inherit; text-align: left;
  display: grid; gap: 4px; padding: 0; position: relative; z-index: 1;
}
.subject-name { font-size: 19px; font-weight: 700; }
.subject-meta, .subject-pct { font-size: 13px; opacity: .92; }
.subject-meta .ico { width: 14px; height: 14px; vertical-align: -2px; }
.subject .icon-btn { position: relative; z-index: 1; }
.subject-letter {
  position: absolute; right: 18px; bottom: -22px; font-size: 96px; font-weight: 700;
  line-height: 1; opacity: .16; pointer-events: none;
}
.bar { display: block; height: 7px; border-radius: 999px; background: #ffffff40; margin: 8px 0 2px; max-width: 75%; }
.bar span { display: block; height: 100%; border-radius: inherit; background: #fff; }

.overall { margin-top: 14px; }
.overall h3 { font-size: 15px; margin-bottom: 10px; }
.overall-row { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.overall-row b { display: block; font-size: 22px; }
.overall-row small { color: var(--muted); }

/* ---------- Empty states ---------- */

.empty { text-align: center; padding: 36px 20px; display: grid; justify-items: center; gap: 6px; }
.empty-icon {
  width: 64px; height: 64px; border-radius: 20px; background: var(--soft); color: var(--primary);
  display: grid; place-items: center; margin-bottom: 6px;
}
.empty-icon .ico { width: 30px; height: 30px; }
.empty h3 { font-size: 17px; }
.empty p { color: var(--muted); max-width: 320px; }
.empty .btn { margin-top: 10px; }
.empty-actions { display: grid; gap: 4px; }

/* ---------- Bottom sheet ---------- */

.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; margin: auto auto 0;
  border: 0; padding: 0; border-radius: 24px 24px 0 0;
  background: var(--card); color: var(--ink); overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet[open] { animation: rise .22s ease-out; }
.sheet::backdrop, .confirm::backdrop { background: #0f0a1f80; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px; position: sticky; top: 0; background: var(--card); z-index: 1;
}
.sheet-head h2 { font-size: 18px; }
.sheet-body { padding: 4px 16px 16px; }
.sheet-actions {
  display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line);
  position: sticky; bottom: 0; background: var(--card);
}
.sheet-actions.flat { padding: 8px 0 0; border: 0; position: static; }
/* The main action gets its own full-width row; Delete and Edit share the row below. */
.sheet-actions:not(.flat) { flex-wrap: wrap; }
.sheet-actions:not(.flat) .grow { flex-basis: 100%; order: -1; }
.sheet-actions:not(.flat) .ghost { flex: 1; }

.detail-title { font-size: 21px; letter-spacing: -.3px; }
.chips { display: flex; gap: 6px; margin: 10px 0 8px; }
.info-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; }
.info-row > .ico { color: var(--muted); margin-top: 2px; }
.info-row small { display: block; color: var(--muted); font-size: 12px; }
.info-row em { color: var(--muted); font-style: normal; }
.notes { white-space: pre-wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* ---------- Forms ---------- */

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 6px; }
.field > span { margin: 0; }
.field textarea { resize: vertical; }
.field [aria-invalid="true"] { border-color: var(--high); }
.error { color: var(--high); font-size: 12.5px; min-height: 0; }
.error:empty { display: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.segmented { --c: var(--primary); display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span {
  display: block; text-align: center; padding: 10px; border-radius: 12px;
  border: 1px solid var(--line); font-weight: 600;
}
.segmented .p0 { --c: var(--low); }
.segmented .p1 { --c: var(--medium); }
.segmented .p2 { --c: var(--high); }
.segmented input:checked + span { border-color: var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches label {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  position: relative; color: #fff; cursor: pointer;
}
.swatches input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatches .ico { opacity: 0; stroke-width: 3; }
.swatches input:checked + .ico { opacity: 1; }
.swatches label:has(input:checked) { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--primary); }
.swatches label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 5px; }

.field > span em { font-style: normal; font-weight: 500; }
.small { font-size: 13px; }

.link {
  border: 0; background: none; padding: 0; color: var(--primary); font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
}

/* "I agree to the Terms of Use and Privacy Policy" */
.agree { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.agree input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }
.agree:has([aria-invalid="true"]) input { outline: 2px solid var(--high); outline-offset: 1px; }
.agree + .error:not(:empty) { display: block; margin-top: 6px; }

.notice {
  --c: var(--low);
  display: flex; gap: 12px; padding: 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--c) 12%, transparent);
}
.notice > .ico { color: var(--c); margin-top: 1px; }
.notice.warning { --c: var(--high); }

/* ---------- Sign in, create account, forgot / new password ---------- */

.auth {
  max-width: 440px; min-height: 100vh; margin: 0 auto;
  padding: calc(32px + env(safe-area-inset-top)) 16px calc(48px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img { border-radius: 14px; box-shadow: var(--shadow); }
.auth-brand b { display: block; font-size: 17px; }
.auth-brand small { color: var(--muted); }
.auth-card { padding: 20px; display: grid; gap: 16px; }
.auth-card h2 { font-size: 22px; letter-spacing: -.3px; }
.auth-card .lead { color: var(--muted); margin-top: 4px; }
.auth-card .lead:empty { display: none; }
.auth-switch { text-align: center; color: var(--muted); }
.auth-loading { text-align: center; padding: 24px; }
.form-links { display: flex; justify-content: flex-end; margin-top: -6px; }
.btn:disabled { opacity: .6; cursor: progress; }

/* ---------- Account sheet and policies ---------- */

.profile { display: flex; align-items: center; gap: 14px; padding: 4px 0 16px; min-width: 0; }
.profile b { display: block; font-size: 17px; }
.profile small { color: var(--muted); overflow-wrap: anywhere; }
.avatar-lg {
  width: 56px; height: 56px; flex: none; border-radius: 18px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
}
.account-note { margin-bottom: 14px; }

.menu { display: grid; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.menu button {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border: 0; border-bottom: 1px solid var(--line); background: var(--card); text-align: left; font-weight: 600;
}
.menu button:last-child { border-bottom: 0; }
/* A link styled like the menu's buttons (Admin dashboard). */
.menu .menu-link {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; text-decoration: none;
}
.menu .menu-link span { flex: 1; }
.menu .menu-link .ico:first-child { color: var(--primary); }
.menu .menu-link .ico:last-child { color: var(--muted); width: 18px; height: 18px; }
.menu button span { flex: 1; }
.menu button span small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.menu .ico:first-child { color: var(--primary); }
.menu .ico:last-child { color: var(--muted); width: 18px; height: 18px; }

.policy h3 { font-size: 15px; margin: 18px 0 6px; }
.policy p + p { margin-top: 8px; }
.policy ul { margin: 6px 0; padding-left: 20px; display: grid; gap: 4px; }
.policy a { color: var(--primary); }

/* ---------- Task types and checklists ---------- */

.chip.type { --c: var(--primary); }
.progress { height: 7px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .3s; }

.checklist {
  display: grid; gap: 6px; margin: 4px 0 8px; padding: 12px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--bg);
}
.checklist-head { display: flex; justify-content: space-between; align-items: baseline; }
.checklist-head small { color: var(--muted); }
.step {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px; border: 0; background: none; text-align: left;
}
.step .ico {
  width: 22px; height: 22px; padding: 3px; flex: none; border-radius: 7px;
  border: 2px solid var(--line); stroke: transparent; stroke-width: 3;
}
.step.done .ico { background: var(--low); border-color: var(--low); stroke: #fff; }
.step.done span { text-decoration: line-through; color: var(--muted); }

/* Editable lists in forms: checklist steps and class times. */
.edit-rows { display: grid; gap: 8px; }
.edit-rows:empty { display: none; }
.edit-row { display: flex; gap: 6px; align-items: center; }
.edit-row input, .edit-row select {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 10px; min-height: 44px;
}
/* Day and the remove button on the first line, start and end times on the second, room on the third. */
.class-edit { display: grid; grid-template-columns: 1fr 1fr 40px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; }
.class-edit select { grid-column: 1 / 3; }
.class-edit .icon-btn { grid-column: 3; grid-row: 1; }
.class-edit input[type="text"] { grid-column: 1 / 3; }
.btn.add-row { justify-self: start; min-height: 40px; padding: 8px 14px; margin-top: 8px; }

/* ---------- Class schedule ---------- */

.class-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; position: relative; overflow: hidden;
}
.class-row::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--subject); }
.class-time { display: grid; font-weight: 700; font-size: 13.5px; min-width: 64px; }
.class-time small { font-weight: 500; color: var(--muted); }
.class-main { flex: 1; min-width: 0; display: grid; }
.class-main small { color: var(--muted); font-size: 12.5px; }
.class-row.done { opacity: .55; }
.class-row.now { border-color: var(--subject); box-shadow: 0 0 0 1px var(--subject); }
.chip.class-now { --c: var(--low); }
.chip.class-next { --c: var(--info); }
.chip.class-done { --c: var(--muted); }

/* ---------- Reminders ---------- */

.hint {
  width: 100%; display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 14px;
  border: 1px dashed var(--primary); border-radius: 16px; background: var(--soft); color: var(--ink); text-align: left;
}
.hint > .ico:first-child { color: var(--primary); }
.hint span { flex: 1; font-size: 13px; color: var(--muted); }
.hint b { display: block; font-size: 14px; color: var(--ink); }

/* On/off switch in the Account sheet. */
.switch {
  width: 42px; height: 24px; flex: none; border-radius: 999px; background: var(--line); position: relative; transition: background .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px #0003; transition: transform .2s;
}
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(18px); }

/* ---------- Focus timer ---------- */

.focus-card { display: grid; justify-items: center; gap: 14px; padding: 20px 16px; }
.focus-phase {
  font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
  color: var(--primary); background: var(--soft);
}
.focus-phase.break { color: var(--low); background: color-mix(in srgb, var(--low) 14%, transparent); }
.timer-ring {
  --pct: 0; --c: var(--primary);
  width: 200px; height: 200px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--pct) * 1%), var(--soft) 0);
}
.timer-ring.break { --c: var(--low); }
.timer-ring span {
  width: 172px; height: 172px; border-radius: 50%; background: var(--card);
  display: grid; place-items: center; font-size: 44px; font-weight: 700; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.focus-task { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; text-align: center; }
.focus-task .ico { width: 18px; height: 18px; }
.timer-buttons { display: flex; gap: 8px; width: 100%; }
.timer-buttons .btn { flex: 1; }
.focus-options { margin-top: 14px; gap: 12px; }
.study-bars { display: grid; gap: 10px; margin-top: 16px; }
.study-bar { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; font-size: 14px; font-weight: 600; }
.study-bar small { color: var(--muted); font-weight: 500; }
.study-bar .progress { grid-column: 1 / -1; }
.focus-empty { margin-top: 12px; text-align: center; }

/* ---------- Duey AI chat ---------- */

.icon-btn.ai-btn { color: var(--primary); }
.bubble .ask-duey { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 13px; text-decoration: none; }
.bubble .ask-duey .ico { width: 15px; height: 15px; }

/* The chat fills the sheet: messages scroll, the message box stays at the bottom. */
.sheet.chat-sheet[open] { display: flex; flex-direction: column; height: 92vh; overflow: hidden; }
.chat-sheet .sheet-head { flex: none; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.chat-sheet .sheet-head h2 { display: flex; align-items: center; gap: 8px; }
.chat-sheet .sheet-head h2 .ico { color: var(--primary); }
.chat-head-actions { display: flex; gap: 8px; align-items: center; }
.small-btn { min-height: 36px; padding: 6px 12px; font-size: 13.5px; border-radius: 11px; }
.small-btn .ico { width: 16px; height: 16px; }

.chat-log {
  flex: 1; overflow-y: auto; padding: 14px 16px 18px;
  display: flex; flex-direction: column; gap: 14px; background: var(--bg);
}
.msg { display: flex; gap: 8px; max-width: 100%; }
.msg p + p, .msg-text ul, .msg-text ol { margin-top: 6px; }
.msg-text ul, .msg-text ol, .suggestion ul { padding-left: 20px; margin-bottom: 0; }
.msg-text li + li { margin-top: 3px; }
.msg.user { justify-content: flex-end; }
.msg.user p {
  max-width: 82%; padding: 10px 14px; border-radius: 18px 18px 4px 18px;
  background: var(--brand); color: #fff; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-avatar { width: 38px; height: 38px; flex: none; }
.msg-avatar:not(.live) .mascot, .msg-avatar:not(.live) .mascot * { animation: none !important; }
.msg-body {
  flex: 1; min-width: 0; display: grid; gap: 10px; padding: 10px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 4px 18px 18px 18px; box-shadow: var(--shadow);
}
.msg.error { align-items: center; color: var(--high); font-size: 14px; padding: 0 4px; }
.msg.typing .msg-body { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: typing 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-prompts { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  border: 1px solid var(--line); background: var(--soft); color: var(--primary);
  border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600;
}

/* A suggestion from Duey, with its Add button. */
/* Icon and text side by side; the Add button on its own line under the text. */
.suggestion {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 10px; padding: 10px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
}
.suggestion > .btn { margin-left: 42px; }
.suggestion.added { opacity: .7; }
.suggestion-ico {
  width: 32px; height: 32px; flex: none; border-radius: 10px; display: grid; place-items: center;
  color: var(--primary); background: var(--soft);
}
.suggestion-ico .ico { width: 18px; height: 18px; }
.suggestion-main { flex: 1 1 calc(100% - 42px); min-width: 0; display: grid; gap: 2px; font-size: 14px; }
.suggestion-main small { color: var(--muted); font-size: 12.5px; }
.suggestion ul { margin-top: 4px; font-size: 13px; color: var(--muted); }
.add-all { justify-self: start; }

.chat-input {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--card);
}
.chat-input textarea {
  flex: 1; resize: none; min-height: 46px; max-height: 140px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
}
.send-btn { width: 46px; padding: 0; flex: none; }

/* ---------- Duedly Pro ---------- */

.pro-chip {
  display: inline-block; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .4px;
  padding: 2px 8px; border-radius: 999px; color: #fff; background: linear-gradient(135deg, #f59e0b, #db2777);
  vertical-align: 2px;
}
.menu .pro-chip { flex: none; }
.menu .count {
  font-style: normal; font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--high); color: #fff; margin-left: 4px;
}
.icon-btn.avatar.pro, .avatar-lg.pro { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px #f59e0b; }

.pro-sheet { display: grid; gap: 14px; }
.pro-hero {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; color: #fff; background: var(--brand);
}
.pro-hero h3 { font-size: 19px; }
.pro-hero p { font-size: 14px; opacity: .95; margin-top: 2px; }
.pro-mascot { width: 72px; height: 72px; flex: none; }

.compare { width: 100%; border-collapse: collapse; font-size: 14px; }
.compare th, .compare td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.compare th:first-child, .compare td:first-child { text-align: left; }
.compare th { font-size: 12.5px; color: var(--muted); }
.compare th:last-child, .compare td:last-child { color: var(--primary); }
.compare .ico { width: 18px; height: 18px; color: var(--low); vertical-align: middle; }

.plan-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plan-option { position: relative; }
.plan-option input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.plan-option span {
  display: grid; gap: 2px; padding: 12px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer;
}
.plan-option big { font-size: 22px; font-weight: 700; }
.plan-option small { color: var(--muted); }
.plan-option input:checked + span { border-color: var(--primary); background: var(--soft); }
.plan-option input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.pay-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
.pay-steps .link { margin-left: 4px; font-size: 13px; }
.gcash-qr { display: block; width: 200px; max-width: 100%; margin-top: 8px; border-radius: 12px; border: 1px solid var(--line); }

.chat-quota {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 0; padding: 8px 16px 0;
  font-size: 12.5px; color: var(--muted); background: var(--card); border-top: 1px solid var(--line);
}
.chat-quota .ico { width: 14px; height: 14px; color: var(--primary); }
.chat-quota + .chat-input { border-top: 0; }
.msg.upgrade { color: var(--primary); align-items: flex-start; }
.msg.upgrade .btn { margin-top: 8px; }

/* Admin: review payments */
.admin { display: grid; gap: 12px; }
.pay-card { border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: grid; gap: 6px; background: var(--card); }
.pay-card > small { color: var(--muted); }
.pay-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pay-card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 4px 0 0; font-size: 13.5px; }
.pay-card dt { color: var(--muted); }
.pay-card dd { margin: 0; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .5px; }
.pay-note { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.pay-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Duey, the mascot (drawn by mascotSvg() in js/app.js) ---------- */

.mascot-card { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.mascot-btn {
  width: 96px; height: 96px; flex: none; padding: 0; border: 0; background: none; border-radius: 24px;
}
.mascot { display: block; width: 100%; height: 100%; overflow: visible; }

/* Speech bubble with a little tail pointing at Duey. */
.bubble {
  position: relative; flex: 1; min-width: 0; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  animation: bubble-pop .35s ease-out;
}
.bubble::before {
  content: ''; position: absolute; left: -7px; top: 50%; width: 12px; height: 12px;
  background: var(--card); border: solid var(--line); border-width: 0 0 1px 1px;
  transform: translateY(-50%) rotate(45deg);
}
.bubble b { display: block; font-size: 12px; color: var(--primary); margin-bottom: 2px; }
.bubble p { font-size: 14px; }
.bubble.hop { animation: bubble-pop .35s ease-out; }
.mascot-btn.hop .mascot { animation: m-hop .6s ease; }
.home-start { justify-items: center; margin-top: 6px; }

/* Parts of the drawing move around fixed points of the 120 × 120 picture. */
.mascot * { transform-box: view-box; }
.mascot .m-body { animation: m-bob 3s ease-in-out infinite; transform-origin: 60px 108px; }
.mascot .m-shadow { animation: m-shadow 3s ease-in-out infinite; transform-origin: 60px 113px; }
.mascot .m-eyes { animation: m-blink 4.5s infinite; transform-origin: 60px 60px; }
.mascot .m-arm-wave { animation: m-wave 2.6s ease-in-out infinite; transform-origin: 98px 60px; }
/* remind: the bells ring every 2 seconds */
.mascot .m-bells { transform-origin: 60px 30px; }
.mascot[data-mood="remind"] .m-bells { animation: m-ring 2s infinite; }
.mascot .m-ring { opacity: 0; animation: m-ring-lines 2s infinite; }
/* worried: fidgets and sweats */
.mascot[data-mood="worried"] .m-body { animation: m-fidget 2.4s ease-in-out infinite; }
.mascot .m-sweat { animation: m-sweat 2.4s ease-in infinite; }
/* celebrate: jumps, with twinkling stars */
.mascot[data-mood="celebrate"] .m-body { animation: m-jump .9s ease-in-out infinite; }
.mascot[data-mood="celebrate"] .m-shadow { animation: m-shadow .9s ease-in-out infinite; }
.mascot .m-spark path { transform-box: fill-box; transform-origin: center; animation: m-twinkle 1.2s ease-in-out infinite; }
.mascot .m-spark path:nth-child(2) { animation-delay: -.4s; }
.mascot .m-spark path:nth-child(3) { animation-delay: -.8s; }
/* sleepy: breathes slowly, zzz */
.mascot[data-mood="sleepy"] .m-body { animation: m-breathe 4s ease-in-out infinite; }
.mascot .m-zzz text { font: 700 14px var(--sans); fill: var(--primary); animation: m-z 3s ease-in infinite; }
.mascot .m-zzz text:nth-child(2) { animation-delay: -1.5s; }

@keyframes m-bob { 50% { transform: translateY(-4px); } }
@keyframes m-shadow { 50% { transform: scaleX(.82); opacity: .6; } }
@keyframes m-blink { 0%, 90%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.1); } }
@keyframes m-wave {
  0%, 55%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(-22deg); }
  20%, 40% { transform: rotate(12deg); }
}
@keyframes m-ring {
  0%, 55%, 90%, 100% { transform: rotate(0); }
  60%, 70%, 80% { transform: rotate(-9deg); }
  65%, 75%, 85% { transform: rotate(9deg); }
}
@keyframes m-ring-lines { 0%, 55%, 92%, 100% { opacity: 0; } 60%, 86% { opacity: 1; } }
@keyframes m-fidget { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes m-sweat {
  0% { transform: translateY(-4px); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(12px); opacity: 0; }
}
@keyframes m-jump {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(0) scale(1.06, .94); }
  50% { transform: translateY(-14px) scale(.97, 1.03); }
}
@keyframes m-twinkle { 0%, 100% { transform: scale(.4); opacity: .3; } 50% { transform: scale(1.1); opacity: 1; } }
@keyframes m-breathe { 50% { transform: scale(1.025, .98); } }
@keyframes m-z {
  0% { transform: translate(0, 0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(8px, -16px); opacity: 0; }
}
@keyframes m-hop { 30% { transform: translateY(-10px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
@keyframes bubble-pop { from { transform: scale(.92); opacity: 0; } }

/* Duey cheering at the bottom left when a task is completed. */
.mascot-pop {
  position: fixed; z-index: 40; margin: 0; padding: 0; border: 0; overflow: visible;
  /* Above the "Add task" button, so it never covers it. */
  inset: auto auto calc(140px + env(safe-area-inset-bottom)) max(16px, calc(50% - 280px + 16px));
  width: max-content; max-width: min(330px, calc(100% - 32px));
  display: flex; align-items: flex-end; gap: 4px;
  background: none; color: var(--ink);
  animation: pop-in .45s cubic-bezier(.3, 1.5, .6, 1);
}
.mascot-pop .mascot { width: 76px; height: 76px; flex: none; }
.mascot-pop .bubble { margin-bottom: 34px; padding: 10px 12px; }
.mascot-pop .bubble p { font-weight: 600; }
@keyframes pop-in { from { transform: translateY(40px) scale(.7); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .mascot, .mascot *, .bubble, .mascot-pop { animation: none !important; }
}

/* ---------- Confirm dialog and toast ---------- */

.confirm {
  border: 0; border-radius: 20px; padding: 20px; width: min(360px, calc(100% - 32px));
  background: var(--card); color: var(--ink);
}
.confirm h2 { font-size: 18px; margin-bottom: 8px; }
.confirm p { color: var(--muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  inset: auto auto calc(150px + env(safe-area-inset-bottom)) 50%; margin: 0; border: 0;
  width: max-content; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px;
  font-weight: 600; box-shadow: 0 10px 24px #0000003d;
}
.toast.error { background: var(--high); color: #fff; }

@media (max-width: 380px) {
  .field-row { grid-template-columns: 1fr; }
  .fab span { display: none; }
  .get-app { padding: 0 11px; }
  .fab { padding: 15px; }
}
