/* ==========================================================================
   Homework Hub — glassmorphism homework tracker
   ========================================================================== */

:root {
  --bg: #070b16;
  --text: #eef3ff;
  --muted: #a7b4cd;
  --faint: #93a3bd;
  --primary: #2dd4bf;
  --primary-ink: #04211e;
  --accent: #fb923c;
  --danger: #fb7185;
  --success: #6ee7b7;
  --glass-bg: linear-gradient(155deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.045));
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-border-strong: rgba(255, 255, 255, 0.26);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow: 0 26px 60px -26px rgba(2, 6, 20, 0.95);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --header-h: 76px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 104px;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Plus Jakarta Sans", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 620px at 10% -10%, rgba(45, 212, 191, 0.17), transparent 62%),
    radial-gradient(820px 700px at 100% 0%, rgba(139, 92, 246, 0.24), transparent 58%),
    radial-gradient(760px 640px at 50% 112%, rgba(251, 146, 60, 0.13), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  overflow-x: hidden;
}

h1, h2, h3, p {
  margin: 0;
}

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

button {
  cursor: pointer;
}

svg.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: 12px;
  background: #0b1224;
  color: var(--primary);
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid #5eead4;
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Background
   -------------------------------------------------------------------------- */

.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
}

.b1 {
  width: 46vw;
  height: 46vw;
  min-width: 320px;
  min-height: 320px;
  left: -8vw;
  top: -10vw;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.5), transparent 66%);
  animation: drift1 26s ease-in-out infinite alternate;
}

.b2 {
  width: 42vw;
  height: 42vw;
  min-width: 300px;
  min-height: 300px;
  right: -6vw;
  top: 4vh;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.55), transparent 66%);
  animation: drift2 32s ease-in-out infinite alternate;
}

.b3 {
  width: 38vw;
  height: 38vw;
  min-width: 260px;
  min-height: 260px;
  left: 32vw;
  bottom: -18vw;
  background: radial-gradient(circle, rgba(251, 146, 60, 0.34), transparent 66%);
  animation: drift3 29s ease-in-out infinite alternate;
}

@keyframes drift1 {
  to { transform: translate3d(6vw, 8vh, 0) scale(1.12); }
}

@keyframes drift2 {
  to { transform: translate3d(-7vw, 12vh, 0) scale(0.92); }
}

@keyframes drift3 {
  to { transform: translate3d(4vw, -10vh, 0) scale(1.08); }
}

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

.wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 32px) 56px;
}

.glass {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7fe9dc;
}

/* --------------------------------------------------------------------------
   Buttons & controls
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease),
    border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), color 0.18s var(--ease);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  background: linear-gradient(135deg, #5eead4, #22c3b1);
  color: var(--primary-ink);
  box-shadow: 0 12px 30px -14px rgba(45, 212, 191, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-primary:hover {
  filter: brightness(1.07);
  box-shadow: 0 16px 34px -14px rgba(45, 212, 191, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--glass-border);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
}

.btn-alert {
  background: linear-gradient(135deg, #fdba74, #fb923c);
  color: #351303;
  box-shadow: 0 12px 30px -16px rgba(251, 146, 60, 0.9);
}

.btn-alert:hover {
  filter: brightness(1.06);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: #d3dcee;
  position: relative;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    color 0.18s var(--ease), transform 0.18s var(--ease);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.26);
  color: #fff;
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn[aria-pressed="true"] {
  background: rgba(45, 212, 191, 0.17);
  border-color: rgba(45, 212, 191, 0.48);
  color: #a7f3e9;
}

.icon-btn.sm {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  color: #aebbd2;
}

.icon-btn.sm .icon {
  width: 17px;
  height: 17px;
}

.icon-btn.sm::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 14px;
}

.icon-btn.sm:hover {
  color: #fff;
}

.icon-btn.danger:hover {
  background: rgba(251, 113, 133, 0.16);
  border-color: rgba(251, 113, 133, 0.4);
  color: #fecdd3;
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 13, 27, 0.55);
  color: var(--text);
  font-size: 0.94rem;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease),
    background 0.18s var(--ease);
}

.input::placeholder {
  color: #7f8da8;
}

.input:hover {
  border-color: rgba(255, 255, 255, 0.24);
}

.input:focus {
  outline: none;
  border-color: rgba(94, 234, 212, 0.72);
  background: rgba(8, 13, 27, 0.76);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.input:focus-visible {
  outline: 2px solid #5eead4;
  outline-offset: 2px;
}

.input[aria-invalid="true"] {
  border-color: rgba(251, 113, 133, 0.8);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.12);
}

select.input {
  appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-color: rgba(8, 13, 27, 0.6);
}

select.input option {
  background: #101829;
  color: var(--text);
}

textarea.input {
  min-height: 98px;
  resize: vertical;
  line-height: 1.55;
}

.select-wrap {
  position: relative;
  min-width: 176px;
}

.select-wrap .chev {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.select-wrap.small {
  min-width: 132px;
}

.select-wrap.small .input {
  min-height: 40px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 0.86rem;
  border-radius: 12px;
}

.search {
  position: relative;
  flex: 1 1 280px;
}

.search > .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.search .input {
  padding-left: 44px;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 12px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 12px 10px 14px;
  border-radius: 22px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 14px;
  color: #04211e;
  background: linear-gradient(140deg, #7ff2e5, #2dd4bf 52%, #a78bfa);
  box-shadow: 0 10px 24px -10px rgba(45, 212, 191, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.brand-mark .icon {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.brand-text {
  display: grid;
  min-width: 0;
}

.brand-text strong {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.brand-text small {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.today-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.82rem;
  font-weight: 600;
  color: #c8d3e6;
  white-space: nowrap;
}

.today-pill .icon {
  width: 17px;
  height: 17px;
  color: #8ce9dd;
}

/* --------------------------------------------------------------------------
   Deadline alert
   -------------------------------------------------------------------------- */

.alert-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border-color: rgba(251, 146, 60, 0.34);
  background:
    linear-gradient(115deg, rgba(251, 146, 60, 0.17), rgba(251, 113, 133, 0.1) 58%, rgba(255, 255, 255, 0.04));
}

.alert-card.is-overdue {
  border-color: rgba(251, 113, 133, 0.42);
  background:
    linear-gradient(115deg, rgba(251, 113, 133, 0.22), rgba(190, 24, 93, 0.12) 58%, rgba(255, 255, 255, 0.04));
}

.alert-card[hidden] {
  display: none;
}

.alert-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 15px;
  color: #fed7aa;
  background: rgba(251, 146, 60, 0.18);
  border: 1px solid rgba(251, 146, 60, 0.32);
}

.is-overdue .alert-icon {
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.18);
  border-color: rgba(251, 113, 133, 0.34);
}

.alert-icon::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid rgba(251, 146, 60, 0.5);
  animation: ping 2.6s var(--ease) infinite;
}

.is-overdue .alert-icon::after {
  border-color: rgba(251, 113, 133, 0.55);
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.65; }
  70%, 100% { transform: scale(1.22); opacity: 0; }
}

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

.alert-body h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.alert-body p {
  margin-top: 2px;
  font-size: 0.85rem;
  color: #d6deee;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-card .btn {
  margin-left: auto;
  flex: none;
}

/* --------------------------------------------------------------------------
   Page heading & stats
   -------------------------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 2px 4px 16px;
}

.page-head h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-top: 2px;
}

.page-sub {
  font-size: 0.86rem;
  color: var(--muted);
  text-align: right;
  padding-bottom: 4px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  display: grid;
  gap: 4px;
  padding: 15px 17px 16px;
  border-radius: var(--radius-md);
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--muted);
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #8ce9dd;
  background: rgba(45, 212, 191, 0.13);
  border: 1px solid rgba(45, 212, 191, 0.2);
}

.stat-icon .icon {
  width: 17px;
  height: 17px;
}

.stat-icon.danger {
  color: #fda4af;
  background: rgba(251, 113, 133, 0.13);
  border-color: rgba(251, 113, 133, 0.22);
}

.stat-icon.warning {
  color: #fdba74;
  background: rgba(251, 146, 60, 0.13);
  border-color: rgba(251, 146, 60, 0.22);
}

.stat-icon.success {
  color: #86efac;
  background: rgba(110, 231, 183, 0.12);
  border-color: rgba(110, 231, 183, 0.22);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-value.danger { color: #fecdd3; }
.stat-value.warning { color: #fed7aa; }
.stat-value.success { color: #bbf7d0; }

.stat-note {
  font-size: 0.74rem;
  color: var(--faint);
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 326px;
  gap: 18px;
  align-items: start;
}

.main-col {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.side-col {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 100px;
  align-self: start;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Toolbar & chips
   -------------------------------------------------------------------------- */

.toolbar {
  display: grid;
  gap: 13px;
  padding: 14px;
  border-radius: var(--radius-md);
}

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

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
  color: #c6d1e5;
  font-size: 0.81rem;
  font-weight: 600;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    color 0.18s var(--ease), transform 0.18s var(--ease);
}

.chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.chip:active {
  transform: scale(0.98);
}

.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, #8ce9dd);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, #8ce9dd) 18%, transparent);
}

.chip .chip-count {
  font-size: 0.71rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #dbe4f4;
  font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] {
  background: rgba(45, 212, 191, 0.17);
  border-color: rgba(94, 234, 212, 0.5);
  color: #d7fff8;
}

.chip[aria-pressed="true"] .chip-count {
  background: rgba(45, 212, 191, 0.25);
  color: #eafffb;
}

.chip.urgent {
  color: #fed7aa;
}

.chip.urgent .dot {
  background: #fb923c;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.18);
}

.chip.urgent[aria-pressed="true"] {
  background: rgba(251, 146, 60, 0.18);
  border-color: rgba(251, 146, 60, 0.52);
  color: #ffedd5;
}

.chip.urgent[aria-pressed="true"] .chip-count {
  background: rgba(251, 146, 60, 0.26);
  color: #fff3e4;
}

/* --------------------------------------------------------------------------
   Task groups & cards
   -------------------------------------------------------------------------- */

#taskSections {
  display: grid;
  gap: 22px;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.group-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.group-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--lvl, #2dd4bf);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--lvl, #2dd4bf) 16%, transparent);
}

.group-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: #cfdaeb;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.group-sub {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--faint);
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 13px;
}

.task {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 14px 19px;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease),
    box-shadow 0.22s var(--ease), opacity 0.22s var(--ease);
}

.task::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--lvl, #2dd4bf);
  opacity: 0.85;
}

.task:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 30px 60px -28px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.task[data-level="overdue"] { --lvl: #fb7185; }
.task[data-level="urgent"] { --lvl: #fb923c; }
.task[data-level="soon"] { --lvl: #fbbf24; }
.task[data-level="calm"] { --lvl: #2dd4bf; }
.task[data-level="done"] { --lvl: #64748b; }

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

.subject {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--c, #8ce9dd);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: color-mix(in srgb, var(--c, #8ce9dd) 15%, transparent);
  border-color: color-mix(in srgb, var(--c, #8ce9dd) 30%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject .dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--c, #8ce9dd);
}

.check {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
  color: transparent;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
    color 0.2s var(--ease), transform 0.2s var(--ease);
}

.check::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
}

.check .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.6;
}

.check:hover {
  border-color: rgba(94, 234, 212, 0.8);
  background: rgba(45, 212, 191, 0.16);
  color: rgba(167, 243, 233, 0.8);
}

.check:active {
  transform: scale(0.92);
}

.is-done .check {
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  border-color: transparent;
  color: #04211e;
}

.task-title {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.42;
  letter-spacing: -0.005em;
  word-break: break-word;
}

.task-notes {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: auto;
  padding-top: 2px;
  font-size: 0.79rem;
  color: #bcc8dd;
}

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

.due .icon {
  width: 15px;
  height: 15px;
  color: #93a3bd;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 600;
  color: #fed7aa;
  background: rgba(251, 146, 60, 0.13);
  border: 1px solid rgba(251, 146, 60, 0.24);
}

.tag .icon {
  width: 12px;
  height: 12px;
  stroke-width: 2;
}

.task-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.countdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #a7f3e9;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.22);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.countdown.lvl-urgent {
  color: #ffedd5;
  background: rgba(251, 146, 60, 0.16);
  border-color: rgba(251, 146, 60, 0.34);
}

.countdown.lvl-overdue {
  color: #ffe4e6;
  background: rgba(251, 113, 133, 0.17);
  border-color: rgba(251, 113, 133, 0.36);
}

.countdown.lvl-soon {
  color: #fef3c7;
  background: rgba(251, 191, 36, 0.13);
  border-color: rgba(251, 191, 36, 0.3);
}

.countdown.lvl-done {
  color: #bbf7d0;
  background: rgba(110, 231, 183, 0.12);
  border-color: rgba(110, 231, 183, 0.24);
}

.countdown.is-pulsing {
  animation: softPulse 2.4s var(--ease) infinite;
}

@keyframes softPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0); }
  50% { box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.12); }
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.is-done {
  opacity: 0.58;
}

.is-done:hover {
  opacity: 0.85;
}

.is-done .task-title {
  text-decoration: line-through;
  text-decoration-color: rgba(167, 243, 233, 0.55);
  color: #c3cede;
}

.is-done .task-notes {
  color: #8e9bb4;
}

/* Done group */
.done-group {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 16px;
}

.done-group > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  list-style: none;
  cursor: pointer;
  border-radius: 10px;
  transition: color 0.18s var(--ease);
}

.done-group > summary::-webkit-details-marker {
  display: none;
}

.done-group > summary:hover .group-title {
  color: #fff;
}

.done-group .chev {
  width: 18px;
  height: 18px;
  color: var(--muted);
  margin-left: 2px;
  transition: transform 0.22s var(--ease);
}

.done-group[open] .chev {
  transform: rotate(180deg);
}

.done-group[open] > summary {
  margin-bottom: 12px;
}

.done-group .group-dot {
  --lvl: #6ee7b7;
}

/* Empty state */
.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 46px 24px;
  border-radius: var(--radius-lg);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.035);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  color: #8ce9dd;
  background: rgba(45, 212, 191, 0.13);
  border: 1px solid rgba(45, 212, 191, 0.24);
}

.empty-icon .icon {
  width: 26px;
  height: 26px;
}

.empty h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.empty p {
  font-size: 0.86rem;
  color: var(--muted);
  max-width: 42ch;
}

.empty .btn {
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   Sidebar panels
   -------------------------------------------------------------------------- */

.panel {
  padding: 18px;
  border-radius: var(--radius-lg);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.94rem;
  font-weight: 700;
}

.panel-head h2 .icon {
  width: 18px;
  height: 18px;
  color: #8ce9dd;
}

.pill {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  color: #a7f3e9;
  background: rgba(45, 212, 191, 0.14);
  border: 1px solid rgba(45, 212, 191, 0.26);
}

.ring-wrap {
  position: relative;
  width: 168px;
  margin: 4px auto 10px;
  display: grid;
  place-items: center;
}

.ring {
  width: 100%;
  height: auto;
  transform: rotate(-90deg);
  overflow: visible;
}

.ring-track,
.ring-fill {
  fill: none;
  stroke-width: 11;
  stroke-linecap: round;
}

.ring-track {
  stroke: rgba(255, 255, 255, 0.1);
}

.ring-fill {
  stroke: url(#ringGradient);
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.7s var(--ease);
  filter: drop-shadow(0 0 8px rgba(45, 212, 191, 0.35));
}

.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1px;
  text-align: center;
}

.ring-label strong {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ring-label span {
  font-size: 0.71rem;
  color: var(--muted);
}

.panel-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: rgba(255, 255, 255, 0.1);
}

.mini-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #93a3bd;
  margin-bottom: 11px;
}

.bars {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  gap: 5px;
}

.bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.79rem;
  color: #ccd7e9;
}

.bar-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.bar-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-name .dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--c, #8ce9dd);
}

.bar-count {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--c, #2dd4bf);
  opacity: 0.85;
  transition: width 0.6s var(--ease);
}

.bars-empty {
  font-size: 0.8rem;
  color: var(--faint);
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.hint.status {
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #b9c5da;
}

.hint.status.is-on {
  color: #bbf7d0;
  background: rgba(110, 231, 183, 0.09);
  border-color: rgba(110, 231, 183, 0.22);
}

.hint.status.is-off {
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.08);
  border-color: rgba(251, 113, 133, 0.2);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 4px;
  padding: 11px 12px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.switch-row:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.16);
}

.switch-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.switch-text strong {
  font-size: 0.82rem;
  font-weight: 600;
}

.switch-text small {
  font-size: 0.71rem;
  color: var(--faint);
}

.switch {
  appearance: none;
  position: relative;
  width: 46px;
  height: 26px;
  flex: none;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.13);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: transform 0.22s var(--ease), background 0.22s var(--ease);
}

.switch:checked {
  background: linear-gradient(135deg, #2dd4bf, #0d9488);
  border-color: transparent;
}

.switch:checked::after {
  transform: translateX(20px);
  background: #03201d;
}

.select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: #ccd7e9;
}

.site-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 36px;
  font-size: 0.76rem;
  color: var(--faint);
  text-align: center;
}

.site-foot .icon {
  width: 15px;
  height: 15px;
}

/* --------------------------------------------------------------------------
   Dialog
   -------------------------------------------------------------------------- */

.dialog {
  width: min(580px, calc(100vw - 28px));
  max-height: min(92dvh, 820px);
  padding: 0;
  border-radius: 26px;
  border: 1px solid var(--glass-border-strong);
  color: var(--text);
  background:
    linear-gradient(160deg, rgba(30, 41, 66, 0.94), rgba(12, 18, 34, 0.97));
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  overflow: auto;
  overscroll-behavior: contain;
}

.dialog::backdrop {
  background: rgba(4, 8, 18, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog[open] {
  animation: dialogIn 0.26s var(--ease);
}

.subject-dialog {
  width: min(500px, calc(100vw - 28px));
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 14px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent);
}

.dialog-head h2 {
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 1px;
}

.dialog-body {
  display: grid;
  gap: 15px;
  padding: 20px 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #cfd9ea;
}

.req {
  color: #fda4af;
}

.field-error {
  font-size: 0.76rem;
  color: #fecdd3;
  display: flex;
  align-items: center;
  gap: 5px;
}

.field-error[hidden] {
  display: none;
}

.dialog-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(13, 19, 35, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Subject manager */

.chip-add {
  border-style: dashed;
  border-color: rgba(94, 234, 212, 0.42);
  background: rgba(45, 212, 191, 0.08);
  color: #a7f3e9;
}

.chip-add:hover {
  background: rgba(45, 212, 191, 0.16);
  border-color: rgba(94, 234, 212, 0.62);
  color: #eafffb;
}

.chip-add .icon {
  width: 15px;
  height: 15px;
  stroke-width: 2.2;
}

.subject-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.subject-input-row .input {
  flex: 1;
  min-width: 0;
}

.color-preview {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--c, #5eead4);
  border: 2px solid rgba(255, 255, 255, 0.34);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, #5eead4) 15%, transparent);
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.subject-list-block {
  display: grid;
  gap: 9px;
}

.subject-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0 4px 0 0;
  list-style: none;
  max-height: 232px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.subject-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.045);
}

.subject-item .dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--c, #8ce9dd);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, #8ce9dd) 18%, transparent);
}

.subject-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
}

.subject-item-count {
  flex: none;
  font-size: 0.73rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.subject-item .icon-btn.sm {
  width: 32px;
  height: 32px;
}

.subject-item .icon-btn.sm:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.subject-item .icon-btn.sm:disabled:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  color: #aebbd2;
}

.subject-empty {
  padding: 10px 2px;
  font-size: 0.82rem;
  color: var(--faint);
}

.subject-dialog .hint {
  line-height: 1.45;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: clamp(12px, 3vw, 28px);
  bottom: clamp(12px, 3vw, 28px);
  z-index: 90;
  display: grid;
  gap: 9px;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 13px 13px 14px;
  border-radius: 16px;
  pointer-events: auto;
  animation: toastIn 0.3s var(--ease);
}

.toast.out {
  animation: toastOut 0.22s var(--ease) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  color: #a7f3e9;
  background: rgba(45, 212, 191, 0.14);
}

.toast-icon .icon {
  width: 17px;
  height: 17px;
}

.toast-danger .toast-icon {
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.15);
}

.toast p {
  flex: 1;
  font-size: 0.83rem;
  line-height: 1.45;
  padding-top: 4px;
  color: #e4ebf9;
  overflow-wrap: anywhere;
}

.toast-action {
  flex: none;
  align-self: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.15);
}

.toast-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  position: relative;
}

.toast-close::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 10px;
}

.toast-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.toast-close .icon {
  width: 15px;
  height: 15px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-col {
    position: static;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
}

@media (max-width: 860px) {
  .today-pill {
    display: none;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .page-sub {
    text-align: left;
    padding-bottom: 0;
  }
}

@media (max-width: 720px) {
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-value {
    font-size: 1.7rem;
  }

  .side-col {
    grid-template-columns: 1fr;
  }

  .alert-card {
    flex-wrap: wrap;
    gap: 12px;
  }

  .alert-body {
    flex: 1 1 200px;
  }

  .alert-card .btn {
    width: 100%;
    margin-left: 0;
  }

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

@media (max-width: 560px) {
  .wrap {
    padding: 12px 12px 40px;
  }

  .topbar {
    top: 8px;
    padding: 8px 10px;
    border-radius: 18px;
    gap: 10px;
    margin-bottom: 14px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-text small {
    display: none;
  }

  .brand-text strong {
    font-size: 0.98rem;
  }

  .btn-add-label {
    display: none;
  }

  #addBtn {
    width: 44px;
    padding: 0;
    border-radius: 14px;
  }

  .page-head {
    padding: 0 2px 12px;
  }

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

  .toolbar-row {
    flex-direction: column;
  }

  .search {
    flex-basis: auto;
  }

  .select-wrap {
    width: 100%;
    min-width: 0;
  }

  .alert-body p {
    white-space: normal;
  }

  .dialog-head,
  .dialog-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .dialog-foot {
    padding: 13px 16px;
  }

  .dialog-foot .btn {
    flex: 1;
  }

  .group-sub {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .blob,
  .alert-icon::after,
  .countdown.is-pulsing {
    animation: none !important;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .glass,
  .task,
  .panel {
    border: 1px solid CanvasText;
  }

  .brand-mark,
  .check {
    forced-color-adjust: none;
  }
}

/* Frosted glass needs a solid-enough fallback when backdrop-filter is missing */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: rgba(20, 28, 48, 0.94);
  }

  .alert-card {
    background: rgba(60, 38, 30, 0.94);
  }
}
