:root {
  --blue: #0047AB;
  --navy: #000080;
  --sky: #82C8E5;
  --slate: #6D8196;
  --glass: rgba(255, 255, 255, 0.10);
  --glass-strong: rgba(255, 255, 255, 0.16);
  --border: rgba(255, 255, 255, 0.22);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.72);
  --radius: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--navy) 0%, var(--blue) 55%, #023a8f 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------- decorative background ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
}

.orb-1 {
  width: 420px;
  height: 420px;
  background: var(--sky);
  top: -120px;
  right: -100px;
}

.orb-2 {
  width: 360px;
  height: 360px;
  background: var(--slate);
  bottom: -140px;
  left: -100px;
  opacity: 0.4;
}

.orb-3 {
  width: 260px;
  height: 260px;
  background: var(--sky);
  top: 45%;
  left: 60%;
  opacity: 0.25;
}

/* ---------- glass utility ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- layout ---------- */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 120px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  position: sticky;
  top: 12px;
  z-index: 10;
}

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

.logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 2px;
}

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

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--glass-strong);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

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

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  font-size: 24px;
  user-select: none;
}

/* ---------- banner ---------- */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
}

.banner .material-symbols-outlined {
  color: var(--sky);
  font-size: 26px;
}

.banner p {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 2px;
}

.banner .icon-btn {
  margin-left: auto;
  width: 34px;
  height: 34px;
}

/* ---------- progress chart ---------- */
.chart-card {
  padding: 14px 16px;
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chart-head strong {
  font-size: 0.95rem;
}

.chart-head .muted {
  font-size: 0.8rem;
}

.stacked-bar {
  display: flex;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  gap: 3px;
}

.bar-finished {
  background: linear-gradient(90deg, var(--sky), #8fe3d0);
  border-radius: 999px;
  min-width: 0;
  transition: width 0.4s ease;
}

.bar-unfinished {
  background: linear-gradient(90deg, var(--slate), #93a8bd);
  border-radius: 999px;
  min-width: 0;
  transition: width 0.4s ease;
}

.chart-labels {
  display: flex;
  gap: 18px;
  margin-top: 9px;
  font-size: 0.78rem;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}

.legend b {
  color: var(--text);
}

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

.dot.finished {
  background: var(--sky);
}

.dot.unfinished {
  background: var(--slate);
}

/* ---------- filters ---------- */
.filters {
  display: flex;
  gap: 6px;
  padding: 6px;
  position: sticky;
  top: 104px;
  z-index: 9;
}

.filter {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter.active {
  background: rgba(255, 255, 255, 0.22);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.filter:hover {
  color: var(--text);
}

/* ---------- view toggle ---------- */
.view-toggle {
  display: flex;
  gap: 6px;
  padding: 6px;
}

.view-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-btn .material-symbols-outlined {
  font-size: 20px;
}

.view-btn.active {
  background: rgba(255, 255, 255, 0.22);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.view-btn:hover {
  color: var(--text);
}

/* ---------- calendar ---------- */
.calendar {
  padding: 14px 16px;
}

.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.cal-head strong {
  flex: 1;
  text-align: center;
  font-size: 1rem;
}

.cal-head .btn {
  padding: 8px 14px;
  font-size: 0.8rem;
}

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

.cal-weekday {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 4px 0;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 46px;
  padding: 5px 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  animation: calCell 0.25s ease both;
}

.cal-day:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.cal-day:active {
  transform: scale(0.92);
}

.cal-day.today .cal-num {
  background: var(--blue);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.cal-day.selected {
  background: rgba(130, 200, 229, 0.25);
  box-shadow: inset 0 0 0 1px rgba(130, 200, 229, 0.6);
}

.cal-num {
  font-size: 0.82rem;
  line-height: 1;
}

.cal-dots {
  display: flex;
  gap: 3px;
  align-items: center;
  height: 6px;
}

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

.cal-dot.d-high {
  background: #ef5350;
}

.cal-dot.d-medium {
  background: #ffc107;
}

.cal-dot.d-low {
  background: var(--sky);
}

.cal-more {
  font-size: 0.62rem;
  color: var(--text-dim);
}

/* ---------- day header ---------- */
.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 0;
}

.day-header strong {
  font-size: 1.05rem;
}

/* ---------- task list ---------- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  align-items: flex-start;
  transition: transform 0.15s ease, opacity 0.25s ease;
  animation: pop 0.35s ease both;
}

.task.completed {
  opacity: 0.62;
}

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

.task-title {
  font-size: 1.02rem;
  font-weight: 600;
  word-break: break-word;
}

.task.completed .task-title {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.task-notes {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.chip .material-symbols-outlined {
  font-size: 14px;
}

.chip.urg-low {
  background: rgba(130, 200, 229, 0.25);
  border-color: rgba(130, 200, 229, 0.5);
}

.chip.urg-medium {
  background: rgba(255, 193, 7, 0.22);
  border-color: rgba(255, 193, 7, 0.5);
  color: #ffe9a3;
}

.chip.urg-high {
  background: rgba(244, 67, 54, 0.25);
  border-color: rgba(244, 67, 54, 0.55);
  color: #ffb9b3;
}

.chip.due-soon {
  background: rgba(130, 200, 229, 0.3);
  border-color: rgba(130, 200, 229, 0.6);
}

.reason {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(244, 67, 54, 0.12);
  border: 1px solid rgba(244, 67, 54, 0.35);
  color: #ffc9c4;
  font-size: 0.8rem;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.reason .material-symbols-outlined {
  font-size: 16px;
  margin-top: 1px;
}

/* ---------- checkbox ---------- */
.check {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.check .material-symbols-outlined {
  font-size: 22px;
}

.check:hover {
  border-color: var(--sky);
}

.check.on {
  background: rgba(0, 200, 83, 0.3);
  border-color: rgba(0, 200, 83, 0.7);
  color: #aef2c6;
}

.task-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-actions .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

/* ---------- empty state ---------- */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
}

.empty-icon {
  font-size: 56px !important;
  color: rgba(255, 255, 255, 0.35);
}

.muted {
  color: var(--text-dim);
  font-size: 0.82rem;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: max(20px, calc((100vw - 720px) / 2 + 8px));
  bottom: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--sky), var(--blue));
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 71, 171, 0.55);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  z-index: 20;
}

.fab .material-symbols-outlined {
  font-size: 30px;
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 71, 171, 0.7);
}

.fab:active {
  transform: scale(0.95);
}

/* ---------- modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 20, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 22px;
  background: rgba(18, 32, 72, 0.72);
  animation: pop 0.22s ease;
}

.modal h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 14px;
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border 0.2s ease, background 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--sky);
  background: rgba(255, 255, 255, 0.16);
}

textarea {
  resize: vertical;
}

select option {
  background-color: #0e1f47;
  color: #ffffff;
}

input[type='color'],
input[type='date'],
input[type='time'],
select {
  color-scheme: dark;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.btn {
  padding: 11px 20px;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

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

.btn.primary {
  background: linear-gradient(135deg, var(--sky), var(--blue));
  color: #fff;
}

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

/* ---------- settings ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-of-type {
  border-bottom: none;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  margin: 0;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  transition: background 0.2s ease;
  cursor: pointer;
}

.slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.switch input:checked + .slider {
  background: var(--blue);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: rgba(10, 20, 50, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  z-index: 60;
  animation: pop 0.25s ease;
  max-width: 90vw;
  text-align: center;
}

/* ---------- animations ---------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

@keyframes floatOrb {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(18px, -22px) scale(1.06);
  }
}

@keyframes calCell {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* staggered entrance for page sections */
.app > * {
  animation: fadeUp 0.5s ease both;
}
.app > *:nth-child(2) {
  animation-delay: 0.05s;
}
.app > *:nth-child(3) {
  animation-delay: 0.1s;
}
.app > *:nth-child(4) {
  animation-delay: 0.15s;
}
.app > *:nth-child(5) {
  animation-delay: 0.2s;
}
.app > *:nth-child(6) {
  animation-delay: 0.25s;
}
.app > *:nth-child(7) {
  animation-delay: 0.3s;
}
.app > *:nth-child(8) {
  animation-delay: 0.35s;
}

/* gentle drift for background orbs */
.orb-1 {
  animation: floatOrb 16s ease-in-out infinite;
}
.orb-2 {
  animation: floatOrb 20s ease-in-out infinite reverse;
}
.orb-3 {
  animation: floatOrb 24s ease-in-out infinite 4s;
}

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

  .app {
    padding: 14px 12px 110px;
  }

  .header {
    top: 10px;
  }

  .filters {
    top: 100px;
  }
}

/* ---------- auth screen ---------- */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 30px 28px;
  text-align: center;
  background: rgba(18, 32, 72, 0.78);
}

.auth-card .logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: block;
}

.auth-card h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.auth-card form {
  text-align: left;
  margin-top: 20px;
}

.auth-card .btn {
  width: 100%;
  margin-top: 4px;
}

.auth-switch {
  margin-top: 16px;
  font-size: 0.85rem;
}

.auth-switch button {
  background: none;
  border: none;
  color: var(--sky);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
}

#authError {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(244, 67, 54, 0.15);
  border: 1px solid rgba(244, 67, 54, 0.4);
  color: #ffc9c4;
  font-size: 0.85rem;
  text-align: left;
}

.auth-card .btn[disabled] {
  opacity: 0.6;
  cursor: wait;
}
