/* =============================================================
   ORBIT — Design System
   Palette: ink (near-black violet), cool paper background,
   "orbit" gradient signature (amber → coral → violet) standing
   in for the sweep of a day, dawn to dusk.
   ============================================================= */

:root {
  /* ---- Core neutrals (cool, violet-tinted — not warm cream) ---- */
  --ink: #14151C;
  --ink-soft: #292A38;
  --ink-elevated: #1E1F2A;
  --paper: #F6F5F9;
  --white: #FFFFFF;
  --line: #E9E8F0;
  --line-strong: #DAD9E4;
  --gray-900: #24242E;
  --gray-600: #5B5A6B;
  --gray-400: #9493A3;
  --gray-200: #E9E8F0;
  --gray-100: #F6F5F9;

  /* ---- Orbit accent trio ---- */
  --amber: #FF9B3D;
  --amber-soft: #FFEBD6;
  --coral: #FF5D73;
  --coral-soft: #FFE3E7;
  --violet: #6E5AF0;
  --violet-soft: #EAE5FE;

  /* legacy alias so any un-migrated reference still resolves */
  --accent: var(--amber);
  --accent-soft: var(--amber-soft);

  --success: #1FAE7B;
  --success-soft: #DDF4EC;
  --red: #EF4444;
  --red-soft: #FDE6E6;
  --green: var(--success);

  --gradient-orbit: linear-gradient(135deg, var(--amber) 0%, var(--coral) 52%, var(--violet) 100%);
  --gradient-orbit-soft: linear-gradient(135deg, var(--amber-soft) 0%, var(--coral-soft) 55%, var(--violet-soft) 100%);
  --gradient-ink: radial-gradient(120% 140% at 0% 0%, #34364A 0%, #1B1C27 46%, #101017 100%);

  /* ---- Geometry ---- */
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 13px;
  --radius-pill: 999px;

  /* ---- Elevation ---- */
  --shadow-soft: 0 1px 2px rgba(18, 16, 38, 0.05), 0 16px 32px -12px rgba(18, 16, 38, 0.16);
  --shadow-card: 0 1px 2px rgba(18, 16, 38, 0.04), 0 8px 20px -8px rgba(18, 16, 38, 0.12);
  --shadow-glow: 0 12px 28px -8px rgba(255, 93, 115, 0.38);
  --shadow-glow-tight: 0 6px 16px -4px rgba(255, 155, 61, 0.4);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

* { box-sizing: border-box; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
  border-radius: 6px;
}

.app-shell, .app-shell-home, .app-shell-calendar {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--white);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.app-main {
  flex: 1;
  padding: 18px 20px calc(120px + var(--safe-bottom));
}

/* ---------- Top App Bar ---------- */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 6px;
}
.app-topbar h1 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.2s ease, box-shadow 0.2s ease;
}
.icon-btn.accent {
  background: var(--gradient-orbit);
  box-shadow: var(--shadow-glow-tight);
}
.icon-btn:hover { background: var(--line); }
.icon-btn.accent:hover { filter: brightness(1.04); }
.icon-btn:active { transform: scale(0.92); }

.date-heading {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 19px;
  font-weight: 600;
  padding: 6px 20px 14px;
  color: var(--gray-900);
}

/* ---------- Timeline (Home) ---------- */
.timeline {
  position: relative;
  padding-left: 6px;
}
.timeline-slot {
  display: flex;
  gap: 14px;
  align-items: stretch;
}
.timeline-time {
  width: 74px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  padding-top: 16px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.timeline-line {
  width: 2px;
  background: linear-gradient(var(--line) 0%, var(--line) 100%);
  margin: 0 6px;
  flex-shrink: 0;
  border-radius: 2px;
}
.timeline-cards {
  flex: 1;
  padding-bottom: 18px;
}

.task-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.18s var(--ease), box-shadow 0.2s ease, opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.task-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-soft); }
.task-card:active { transform: scale(0.985); }
.task-card.completed { opacity: 0.5; }
.task-card.completed .task-title { text-decoration: line-through; }
.task-card.long-pressing, .agenda-card.long-pressing, .category-card-wrapper.long-pressing .category-card {
  background: var(--gradient-orbit-soft);
  border-color: transparent;
  transform: scale(0.97);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  cursor: pointer;
  font-weight: 600;
  font-size: 15.5px;
  transition: background 0.15s ease, transform 0.15s var(--ease);
  margin-bottom: 10px;
}
.menu-item:hover { background: var(--line); }
.menu-item:active { transform: scale(0.98); }
.menu-item.delete {
  color: var(--red);
  background: var(--red-soft);
}
.menu-item.delete:hover { background: #FADADA; }
.menu-item.delete svg {
    stroke: var(--red);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 13, 28, 0.45);
    backdrop-filter: blur(2px);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}
.modal-overlay.open {
    display: flex;
}
.modal-sheet {
    background: #fff;
    width: 100%;
    max-width: 480px;
    border-radius: 28px 28px 0 0;
    padding: 26px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -20px 50px rgba(15, 13, 28, 0.25);
    animation: sheetUp 0.28s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }

.agenda-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.18s var(--ease), background 0.2s ease, border-color 0.2s ease;
}
.agenda-card:hover { border-color: var(--line-strong); }

.task-card .task-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
}
.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}
.priority-flag {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.task-card-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.checkbox {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid var(--line-strong);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}
.checkbox.checked {
  background: var(--gradient-orbit);
  border-color: transparent;
  box-shadow: var(--shadow-glow-tight);
}
.checkbox svg { opacity: 0; transition: opacity 0.15s ease, transform 0.2s var(--ease); transform: scale(0.6); }
.checkbox.checked svg { opacity: 1; transform: scale(1); }

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--gray-400);
}
.empty-state svg { margin-bottom: 14px; opacity: 0.5; }
.empty-state p { font-size: 14.5px; line-height: 1.6; max-width: 260px; margin: 0 auto; }

/* ---------- Calendar Page ---------- */
.date-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 20px 18px;
  scrollbar-width: none;
}
.date-selector::-webkit-scrollbar { display: none; }
.date-chip {
  flex-shrink: 0;
  width: 56px;
  padding: 12px 0;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  text-align: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.18s var(--ease), box-shadow 0.2s ease;
}
.date-chip:active { transform: scale(0.95); }
.date-chip .dow {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  margin-bottom: 6px;
  display: block;
}
.date-chip .dom {
  font-size: 16px;
  font-weight: 700;
}
.date-chip.active {
  background: var(--gradient-orbit);
  box-shadow: var(--shadow-glow-tight);
}
.date-chip.active .dow, .date-chip.active .dom { color: var(--white); }

.section-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin: 20px 4px 10px;
}

.agenda-card .agenda-title {
  font-size: 15.5px;
  font-weight: 600;
  margin-bottom: 4px;
}
.agenda-card .agenda-time {
  font-size: 13px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 5px;
}
.status-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 0;
  white-space: nowrap;
}

/* ---------- Progress / Stats ---------- */
.stats-card {
  background: var(--gradient-ink);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: var(--white);
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.stats-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120px 120px at 92% -10%, rgba(255, 155, 61, 0.45), transparent 70%),
    radial-gradient(160px 160px at 110% 60%, rgba(255, 93, 115, 0.35), transparent 70%),
    radial-gradient(140px 140px at -10% 120%, rgba(110, 90, 240, 0.4), transparent 70%);
  pointer-events: none;
}
.stats-card h3 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 18px;
  opacity: 0.75;
  letter-spacing: 0.2px;
  position: relative;
}
.stats-row {
  display: flex;
  justify-content: space-between;
  position: relative;
}
.stat-block .stat-value {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #FFC98C, #FF9B3D);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-block .stat-label {
  font-size: 11.5px;
  color: rgba(255,255,255,0.55);
  margin-top: 3px;
  font-weight: 500;
}

/* ---------- Profile Page ---------- */
.user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 22px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.user-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-soft); }
.user-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gradient-orbit);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  color: var(--white);
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow-tight);
}
.user-card .u-name { font-size: 17px; font-weight: 700; }
.user-card .u-sub { font-size: 13px; color: var(--gray-400); margin-top: 2px; }
.user-card .chevron { margin-left: auto; color: var(--gray-400); }

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.category-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px 16px;
  position: relative;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s var(--ease), border-color 0.2s ease, box-shadow 0.2s ease;
}
.category-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-soft); }
.category-card:active { transform: scale(0.97); }
.category-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--amber-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber);
  margin-bottom: 10px;
}
/* Cycle icon accents across the grid so categories read distinctly */
.category-card-wrapper:nth-of-type(4n+2) .category-icon { background: var(--coral-soft); color: var(--coral); }
.category-card-wrapper:nth-of-type(4n+3) .category-icon { background: var(--violet-soft); color: var(--violet); }
.category-card-wrapper:nth-of-type(4n+4) .category-icon { background: var(--success-soft); color: var(--success); }

.category-card .cat-name { font-size: 15.5px; font-weight: 700; }
.category-card .cat-count { font-size: 13px; color: var(--gray-400); margin-top: 6px; }
.category-more {
  position: absolute;
  top: 16px; right: 12px;
  color: var(--gray-400);
}
.category-card.add-category {
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--line-strong);
  box-shadow: none;
  color: var(--gray-400);
  background: var(--gray-100);
}
.category-card.add-category:hover { border-color: var(--violet); color: var(--violet); background: var(--violet-soft); }
.category-card-wrapper {
  position: relative;
}
.category-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
}
.icon-btn-small {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.icon-btn-small:hover {
  background: var(--gray-100);
}
.icon-btn-small:active {
  transform: scale(0.9);
}
.icon-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.icon-option {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-600);
  transition: all 0.2s ease;
}
.icon-option[data-selected="true"] {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}
.icon-option:hover {
  border-color: var(--gray-400);
}
.icon-option:active {
  transform: scale(0.95);
}

/* ---------- Habit Tracker ---------- */
.habit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color 0.2s ease;
}
.habit-row:hover { border-color: var(--line-strong); }
.habit-row .habit-name { font-weight: 600; font-size: 15px; }
.habit-streak {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--coral);
  background: var(--coral-soft);
  padding: 5px 11px;
  border-radius: var(--radius-pill);
}

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 14px calc(14px + var(--safe-bottom));
  z-index: 40;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  transition: background 0.25s var(--ease), color 0.25s ease, transform 0.2s var(--ease);
}
.nav-item.active {
  background: var(--ink);
  color: var(--white);
  padding: 10px 18px;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -6px rgba(20, 21, 28, 0.45);
}

/* ---------- Floating Action Button ---------- */
.fab {
  position: fixed;
  bottom: calc(96px + var(--safe-bottom));
  right: calc(50% - 240px + 20px);
  width: 58px;
  height: 58px;
  border-radius: 19px;
  background: var(--gradient-orbit);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  border: none;
  cursor: pointer;
  z-index: 45;
  transition: transform 0.22s var(--ease), box-shadow 0.22s ease;
}
.fab:hover { transform: translateY(-2px) rotate(90deg); box-shadow: 0 16px 32px -8px rgba(255, 93, 115, 0.48); }
.fab:active { transform: scale(0.9); }
@media (max-width: 520px) {
  .fab { right: 20px; }
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 7px;
  letter-spacing: 0.1px;
}
.form-control {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--gray-100);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--violet);
  background: var(--white);
  box-shadow: 0 0 0 4px var(--violet-soft);
}
textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.priority-select { display: flex; gap: 8px; }
.priority-option {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s ease;
}
.priority-option.selected {
  background: var(--gradient-orbit);
  border-color: transparent;
  color: var(--white);
  box-shadow: var(--shadow-glow-tight);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--gradient-orbit);
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: transform 0.18s var(--ease), box-shadow 0.2s ease, filter 0.2s ease;
  margin-top: 10px;
}
.btn-primary:hover { filter: brightness(1.03); }
.btn-primary:active { transform: scale(0.98); }

/* ---------- Auth Pages ---------- */
.auth-wrap {
  padding: 60px 26px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
.auth-wrap::before {
  content: "";
  position: absolute;
  top: -140px;
  right: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,155,61,0.28), rgba(255,93,115,0.16) 45%, transparent 70%);
  pointer-events: none;
}
.auth-logo {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--gradient-orbit);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 24px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-glow);
  position: relative;
}
.auth-wrap h1 { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 27px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.4px; position: relative; }
.auth-wrap p.sub { color: var(--gray-400); margin: 0 0 30px; font-size: 14.5px; position: relative; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--gray-600); position: relative; }
.auth-switch a { color: var(--violet); font-weight: 700; }
.alert-error {
  background: var(--red-soft);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  font-weight: 500;
  position: relative;
}

/* ---------- Utility ---------- */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt-0 { margin-top: 0; }
.text-muted { color: var(--gray-400); }

@media (min-width: 481px) {
  body { background: var(--gray-200); }
  .app-shell, .app-shell-home, .app-shell-calendar { box-shadow: 0 30px 80px rgba(20, 17, 36, 0.18); min-height: 100vh; }
}
