/* ============ THEME VARIABLES ============ */
:root,
[data-theme="light"] {
  --bg-page: #F9FAFB;
  --bg-card: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-input: #FFFFFF;
  --bg-muted: #F3F4F6;
  --bg-muted-2: #F9FAFB;
  --bg-accent-soft: #EFF6FF;
  --bg-success-soft: #DCFCE7;
  --bg-warn-soft: #FEF3C7;
  --bg-danger-soft: #FEE2E2;

  --text-primary: #111827;
  --text-secondary: #374151;
  --text-tertiary: #6B7280;
  --text-muted: #9CA3AF;
  --text-disabled: #D1D5DB;
  --text-on-accent: #FFFFFF;

  --border-color: #E5E7EB;
  --border-soft: #F3F4F6;

  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --danger: #DC2626;
  --warn: #D97706;
  --success: #16A34A;

  --warn-text-strong: #92400E;
  --warn-text-soft: #B45309;

  --overlay: rgba(17, 24, 39, 0.55);
  --press-overlay: rgba(0,0,0,0.04);

  /* Chevron for light selects — dark arrow on light bg */
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
  --bg-page: #080E1A;
  --bg-card: #0F1826;
  --bg-elevated: #172030;
  --bg-input: #172030;
  --bg-muted: #1A2436;
  --bg-muted-2: #0F1826;
  --bg-accent-soft: rgba(59,130,246,0.15);
  --bg-success-soft: rgba(74,222,128,0.12);
  --bg-warn-soft: rgba(251,191,36,0.12);
  --bg-danger-soft: rgba(248,113,113,0.12);

  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-tertiary: #94A3B8;
  --text-muted: #64748B;
  --text-disabled: #334155;
  --text-on-accent: #FFFFFF;

  --border-color: #1E2D42;
  --border-soft: #172030;

  --accent: #60A5FA;
  --accent-hover: #93C5FD;
  --danger: #F87171;
  --warn: #FBBF24;
  --success: #4ADE80;

  --warn-text-strong: #FCD34D;
  --warn-text-soft: #FBBF24;

  --overlay: rgba(0, 0, 0, 0.72);
  --press-overlay: rgba(255,255,255,0.06);

  /* Chevron for dark selects — light arrow on dark bg */
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* ============ SMOOTH THEME TRANSITIONS ============ */
/* Applied to html so all CSS variables animate when theme switches */
html {
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}
/* Transition key surfaces so dark-mode flip feels premium */
*,
*::before,
*::after {
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
}
/* But DON'T slow down transforms / opacity animations (buttons, sheets, etc) */
.nav-fab-btn,
.toggle,
.toggle::after,
.overlay,
.sheet,
.modal-overlay,
.modal-card,
.chev,
.install-fab,
.toast {
  transition-property: transform, opacity;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}
/* Re-apply original transitions that must not be overridden */
.toggle { transition: background-color 0.22s ease; }
.toggle::after { transition: left 0.22s ease; }
.sheet { transition: transform 0.3s cubic-bezier(0.32,0.72,0,1); }
.overlay { transition: opacity 0.25s ease; }
.modal-overlay { transition: opacity 0.2s ease; }
.modal-card { transition: transform 0.2s ease; }
.chev { transition: transform 0.2s ease; }
.toast { transition: opacity 0.2s ease, transform 0.2s ease; }

/* ============ BASE ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body { min-height: 100vh; }
button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit; }
input, select, textarea { font-family: inherit; color: var(--text-primary); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
a { color: var(--accent); text-decoration: none; }
ul, li { list-style: none; padding: 0; margin: 0; }
i.ti { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }

/* ============ APP SHELL ============ */
#app {
  max-width: 430px;
  min-width: 320px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-page);
  position: relative;
}

/* ============ HEADER — MOBILE 2 FIX: iOS safe area ============ */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  /* MOBILE 2 FIX: Account for iOS notch/status bar */
  padding-top: env(safe-area-inset-top, 0);
  height: calc(56px + env(safe-area-inset-top, 0));
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: flex-end;
  padding-bottom: 0;
  padding-left: 16px;
  padding-right: 16px;
  z-index: 50;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,0.08);
}
.app-header > * { height: 56px; display: flex; align-items: center; }
.app-title {
  font-size: 16px;
  font-weight: 500;
  flex: 1;
  gap: 10px;
}
.app-title-text { font-size: 16px; font-weight: 500; }
.header-actions { gap: 4px; }
.back-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #fff;
  margin-left: -8px;
  font-size: 22px;
}
.back-btn:active { background: rgba(255,255,255,0.15); }
.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  position: relative;
}
.icon-btn:active { background: rgba(255,255,255,0.15); }
.red-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: #F87171; border-radius: 50%;
  border: 1.5px solid var(--accent);
}

/* ============ MAIN CONTENT — MOBILE 2 FIX: account for header + bottom nav ============ */
.app-main {
  /* MOBILE 2 FIX: Push below the taller safe-area-aware header */
  padding-top: calc(56px + env(safe-area-inset-top, 0));
  /* MOBILE 2 FIX: Push above the taller safe-area-aware bottom nav */
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
  overflow-y: auto;
  min-height: 100vh;
}

/* ============ BOTTOM NAV — 5 tabs + center FAB (6-col grid) ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  /* Account for iOS home indicator */
  height: calc(64px + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: grid;
  /* 6-column: 2 left tabs | FAB slot (wider) | 3 right tabs */
  grid-template-columns: repeat(2, 1fr) 64px repeat(3, 1fr);
  align-items: center;
  z-index: 50;
}
.nav-item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--text-muted);
  /* Slightly smaller label to fit 5 tabs comfortably */
  font-size: 9.5px;
  font-weight: 500;
  min-height: 44px;
  padding: 0 2px;
}
.nav-item i.ti { font-size: 20px; }
.nav-item.active { color: var(--accent); }
.nav-item:active { opacity: 0.7; }
/* Premium active indicator pip */
.nav-item.active i.ti {
  position: relative;
}
.nav-item.active::before {
  content: '';
  display: block;
  width: 24px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.85;
}

/* Center FAB in bottom nav */
.nav-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Lift FAB above the nav bar */
  margin-top: -18px;
}
.nav-fab-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.5), 0 1px 4px rgba(0,0,0,0.15);
  font-size: 26px;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.15s ease !important;
}
.nav-fab-btn:active {
  transform: scale(0.90);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
/* Dark mode FAB gets a brighter glow */
[data-theme="dark"] .nav-fab-btn {
  box-shadow: 0 4px 20px rgba(96,165,250,0.45), 0 1px 4px rgba(0,0,0,0.3);
}

/* ============ SCREEN ============ */
.screen {
  padding: 16px;
  display: none;
}
.screen.active { display: block; }

/* ============ OVERDUE BANNER ============ */
.overdue-banner {
  background: var(--bg-danger-soft);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.od-title {
  font-size: 13px; font-weight: 600;
  color: var(--danger);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 3px;
}
.od-sub { font-size: 12px; color: var(--text-tertiary); margin-bottom: 10px; }
.od-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.od-actions button {
  font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  /* MOBILE 4 FIX: Minimum touch target */
  min-height: 36px;
}
.od-actions button:active { opacity: 0.7; }

/* ============ DATE STRIP ============ */
.date-strip {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 4px;
}
.date-strip::-webkit-scrollbar { display: none; }
.date-item {
  display: flex; flex-direction: column;
  align-items: center;
  min-width: 48px; padding: 8px 4px;
  border-radius: 12px;
  color: var(--text-tertiary);
  gap: 4px;
  flex-shrink: 0;
  /* MOBILE 4 FIX: Minimum touch target */
  min-height: 64px;
  justify-content: center;
}
.date-item:active { background: var(--bg-muted); }
.dname { font-size: 11px; font-weight: 500; }
.dnum { font-size: 18px; font-weight: 600; }
.ddot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.date-item.today .dnum { color: var(--accent); }
.date-item.selected {
  background: var(--accent);
  color: #fff;
}
.date-item.selected .ddot { background: #fff; }

/* ============ SUMMARY CARDS ============ */
.summary-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.summary-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--border-color);
}
.sc-top { display: flex; align-items: center; gap: 8px; }
.sc-top i.ti { font-size: 18px; }
.sc-num { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.sc-label { font-size: 11px; color: var(--text-tertiary); font-weight: 500; }

/* ============ SECTION HEADER ============ */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.see-all {
  font-size: 12px; color: var(--accent); font-weight: 500;
  padding: 6px 8px;
  /* MOBILE 4 FIX: Taller touch target */
  min-height: 36px;
}

/* ============ TASK CARD ============ */
.task-card {
  background: var(--bg-card);
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  display: flex; align-items: center;
  overflow: hidden;
  position: relative;
}
.pbar {
  width: 4px; align-self: stretch;
  flex-shrink: 0;
  border-radius: 0;
}
.task-card.prio-urgent   .pbar { background: var(--danger); }
.task-card.prio-moderate .pbar { background: var(--warn); }
.task-card.prio-normal   .pbar { background: var(--success); }
.tc-body {
  flex: 1; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 4px;
  cursor: pointer;
  min-width: 0;
}
.tc-title {
  font-size: 14px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-sub {
  font-size: 12px; color: var(--text-tertiary);
  display: flex; align-items: center; gap: 4px;
}
.tc-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.task-card.done .tc-title { text-decoration: line-through; color: var(--text-muted); }
.task-check {
  /* MOBILE 4 FIX: Minimum 44px touch target */
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 18px;
  margin-right: 4px;
  border-radius: 50%;
}
.task-check:active { background: var(--bg-muted); }
.task-card.done .task-check { color: var(--success); }

/* TASK CARD FULL (tasks screen) */
.task-card-full .tc-meta {
  font-size: 12px; color: var(--text-tertiary);
  display: flex; align-items: center; gap: 4px;
}
.task-card-full .tc-meta i.ti { font-size: 13px; }
.task-expand-actions {
  display: none; margin-top: 8px;
  gap: 6px; flex-wrap: wrap;
}
.task-card-full.expanded .task-expand-actions { display: flex; }

/* ============ BADGES ============ */
.badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 3px;
}
.badge-urgent   { background: var(--bg-danger-soft); color: var(--danger); }
.badge-moderate { background: var(--bg-warn-soft);   color: var(--warn); }
.badge-normal   { background: var(--bg-success-soft); color: var(--success); }
.badge-formal   { background: var(--bg-accent-soft); color: var(--accent); }
.badge-casual   { background: var(--bg-muted); color: var(--text-tertiary); }
.badge-section  { background: var(--bg-muted); color: var(--text-tertiary); }
.badge-count    { background: var(--bg-muted); color: var(--text-secondary); }

/* ============ UNITS ============ */
.units-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }

.unit-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}
.uc-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.uc-left {
  display: flex; align-items: center; gap: 8px;
  flex: 1; cursor: pointer;
}
.uc-left i.ti { font-size: 20px; color: var(--accent); }
.uc-name { font-size: 15px; font-weight: 600; }
.uc-actions { display: flex; gap: 4px; }
/* MOBILE 4 FIX: Larger touch targets for unit card actions */
.uc-actions button {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-tertiary); font-size: 16px;
}
.uc-actions button:active { background: var(--bg-muted); }
.uc-pills, .uc-bottom {
  display: flex; gap: 6px; flex-wrap: wrap;
  cursor: pointer;
}
.uc-bottom { margin-top: 6px; }
.pill-gray {
  font-size: 12px; color: var(--text-muted);
  padding: 3px 8px; background: var(--bg-muted);
  border-radius: 99px;
}

/* ============ DETAIL SECTION ============ */
.detail-section { margin-bottom: 20px; }
.detail-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}

/* HEAD CARD */
.head-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
}
.head-card:active { opacity: 0.85; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.hc-info { flex: 1; min-width: 0; }
.hc-name { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.hc-role { font-size: 12px; color: var(--text-tertiary); }
/* MOBILE 4 FIX: Larger touch target for head card remove button */
.hc-remove {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--text-muted); font-size: 16px;
  flex-shrink: 0;
}
.hc-remove:active { background: var(--bg-danger-soft); color: var(--danger); }

/* CHIPS */
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-muted); border-radius: 99px;
  padding: 6px 10px 6px 12px;
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer;
  /* MOBILE 4 FIX: Minimum 36px chip height */
  min-height: 36px;
}
.chip:active { opacity: 0.7; }
/* MOBILE 4 FIX: Larger chip remove button */
.chip-x {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  margin: -6px -6px -6px 0;
  border-radius: 50%;
  color: var(--text-muted); font-size: 12px;
}
.chip-x:active { background: var(--bg-danger-soft); color: var(--danger); }

/* ============ ACCORDION ============ */
.accordion { margin-bottom: 8px; }
.accordion-header {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  /* MOBILE 4 FIX: 44px minimum */
  min-height: 44px;
}
.accordion-header:active { opacity: 0.8; }
.chev { font-size: 16px; color: var(--text-muted); transition: transform 0.2s; }
.accordion.open .chev { transform: rotate(180deg); }
.accordion-body { display: none; padding: 8px 0; }
.accordion.open .accordion-body { display: block; }

/* ============ CALENDAR ============ */
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cal-nav button {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 20px; color: var(--text-secondary);
}
.cal-nav button:active { background: var(--bg-muted); }
.cal-month { font-size: 16px; font-weight: 600; }
.cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-days span {
  text-align: center; font-size: 11px; font-weight: 600;
  color: var(--text-muted); padding: 4px 0;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; margin-bottom: 10px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: 13px; color: var(--text-secondary);
  gap: 2px;
  position: relative;
  /* MOBILE 4 FIX: tap area */
  min-height: 36px;
}
.cal-cell:active { background: var(--bg-muted); }
.cal-cell.today .num-wrap {
  color: var(--accent); font-weight: 700;
}
.cal-cell.selected {
  background: var(--accent); color: #fff;
}
.cal-cell.selected .num-wrap { color: #fff; font-weight: 700; }
.cal-cell.other-month { opacity: 0.35; }
.dots { display: flex; gap: 2px; }
.d { width: 5px; height: 5px; border-radius: 50%; }
.d.u { background: var(--danger); }
.d.m { background: var(--warn); }
.d.n { background: var(--success); }
.d.b { background: var(--accent); }
.more { font-size: 9px; color: var(--text-muted); }
.legend-row {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.lg { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-tertiary); }
.ldot { width: 8px; height: 8px; border-radius: 50%; }

/* ============ TASKS SCREEN ============ */
.filter-pills {
  display: flex; gap: 6px;
  overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: none; margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}
.filter-pills::-webkit-scrollbar { display: none; }
.filter-pill {
  white-space: nowrap;
  font-size: 12px; font-weight: 500;
  padding: 6px 14px; border-radius: 99px;
  background: var(--bg-muted); color: var(--text-secondary);
  flex-shrink: 0;
  /* MOBILE 4 FIX: Minimum height */
  min-height: 36px;
}
.filter-pill.active { background: var(--accent); color: #fff; }
.sort-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.toggle-pair {
  display: flex; border: 1px solid var(--border-color);
  border-radius: 8px; overflow: hidden;
  flex-shrink: 0;
}
.toggle-pair .seg-btn {
  padding: 8px 12px; font-size: 12px; font-weight: 500;
  color: var(--text-tertiary);
  min-height: 36px;
}
.toggle-pair .seg-btn.active { background: var(--accent); color: #fff; }

/* ============ TASK EXPAND ACTIONS ============ */
.btn-done-soft, .btn-resched-soft, .btn-notdone-soft {
  font-size: 12px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 8px;
  /* MOBILE 4 FIX: Minimum tap area */
  min-height: 36px;
}
.btn-done-soft   { background: var(--bg-success-soft); color: var(--success); }
.btn-resched-soft{ background: var(--bg-accent-soft); color: var(--accent); }
.btn-notdone-soft{ background: var(--bg-muted); color: var(--text-tertiary); }
.btn-done-soft:active, .btn-resched-soft:active, .btn-notdone-soft:active { opacity: 0.7; }

/* ============ SETTINGS ============ */
.settings-app-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}
.sac-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--bg-accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--accent);
}
.sac-name { font-size: 16px; font-weight: 600; }
.sac-version { font-size: 12px; color: var(--text-muted); }

.settings-group { margin-bottom: 20px; }
.settings-group-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 4px; margin-bottom: 6px;
}
.settings-list {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  /* MOBILE 4 FIX: Minimum 52px height for settings rows */
  height: 52px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 14px; color: var(--text-secondary);
}
.settings-row:last-child { border-bottom: none; }
.settings-row:active { background: var(--press-overlay); }
.settings-row.hidden { display: none; }
.sr-control { display: flex; align-items: center; gap: 8px; max-width: 55%; }
.sr-icon-right { font-size: 18px; }
.sr-icon-right.accent { color: var(--accent); }
.sr-icon-right.danger { color: var(--danger); }

/* Theme toggle */
.theme-toggle-group {
  display: flex; gap: 6px;
}
.theme-toggle-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px; border-radius: 10px;
  border: 1.5px solid var(--border-color);
  gap: 4px; font-size: 11px; font-weight: 500;
  color: var(--text-tertiary);
  min-height: 52px;
}
.theme-toggle-btn i.ti { font-size: 18px; }
.theme-toggle-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-accent-soft);
}

/* ============ TOGGLE SWITCH ============ */
.toggle {
  width: 44px; height: 26px;
  background: var(--bg-muted); border-radius: 13px;
  position: relative; cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 21px; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.15s;
  /* MOBILE 4 FIX: Minimum 44px height */
  min-height: 44px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}
/* BUG 8 FIX: Visual error state for invalid form fields */
.form-input.error, .form-select.error {
  border-color: var(--danger);
  background: var(--bg-danger-soft);
}
.form-error-msg {
  font-size: 11px; color: var(--danger);
  margin-top: 4px; min-height: 14px;
}
.form-textarea {
  resize: none; height: 80px;
  min-height: 80px;
}
/* FIX: Use CSS variable for chevron so dark mode gets the right color */
.form-select {
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.input-with-icon {
  position: relative; display: flex; align-items: center;
}
.input-with-icon > i.ti {
  position: absolute; left: 12px; font-size: 16px;
  color: var(--text-muted); pointer-events: none; z-index: 1;
}
.input-with-icon > .form-input,
.input-with-icon > .form-select {
  padding-left: 36px;
}
.flex-1 { flex: 1; }

/* Segmented control */
.segmented {
  display: grid;
  background: var(--bg-muted);
  border-radius: 10px;
  padding: 3px; gap: 2px;
}
.segmented.cols-2 { grid-template-columns: repeat(2, 1fr); }
.segmented.cols-3 { grid-template-columns: repeat(3, 1fr); }
.segmented.cols-4 { grid-template-columns: repeat(4, 1fr); }
.seg-btn {
  padding: 8px 4px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text-tertiary);
  text-align: center;
  /* MOBILE 4 FIX */
  min-height: 36px;
}
.seg-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.seg-btn.prio-urgent.active  { color: var(--danger); }
.seg-btn.prio-moderate.active{ color: var(--warn); }
.seg-btn.prio-normal.active  { color: var(--success); }

/* Range input */
input[type="range"] {
  -webkit-appearance: none;
  height: 4px; border-radius: 4px;
  background: var(--bg-muted); outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.range-val { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }

/* ============ BUTTONS ============ */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px; font-weight: 600;
  /* MOBILE 4 FIX */
  min-height: 44px;
}
.btn-primary:active { background: var(--accent-hover); }
.btn-primary.lg { height: 50px; font-size: 15px; }
.btn-primary.full { width: 100%; justify-content: center; margin-bottom: 10px; }
.btn-outline {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  min-height: 36px;
}
.btn-outline:active { background: var(--bg-muted); }
.btn-cancel-link {
  display: block; text-align: center;
  color: var(--text-muted); font-size: 14px;
  padding: 12px; width: 100%;
  min-height: 44px;
}
.btn-cancel-link:active { opacity: 0.6; }

/* Section divider */
.section-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 10px;
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border-color);
}
.sd-label { font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

/* ============ OVERLAYS / SHEETS ============ */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: var(--overlay);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.overlay.open { opacity: 1; pointer-events: all; }

.sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  max-height: 92vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.overlay.open .sheet { transform: translateY(0); }
.sheet.h80 { height: 80vh; overflow-y: auto; }
.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border-color);
  margin: 12px auto 0;
}
.sheet-title {
  font-size: 16px; font-weight: 600;
  padding: 14px 16px 8px;
  color: var(--text-primary);
}
.sheet-content { padding: 0 16px 20px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  padding: 20px;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-card {
  background: var(--bg-card);
  border-radius: 16px; padding: 20px;
  width: 100%; max-width: 340px;
  transform: scale(0.92);
  transition: transform 0.2s;
}
.modal-overlay.open .modal-card { transform: scale(1); }
.m-title {
  font-size: 15px; font-weight: 600;
  color: var(--text-primary); margin-bottom: 16px;
  text-align: center; line-height: 1.4;
}
.m-buttons { display: flex; flex-direction: column; gap: 8px; }
.btn-confirm-yes {
  padding: 13px; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 600;
  text-align: center; width: 100%;
  min-height: 44px;
}
.btn-confirm-no {
  padding: 13px; border-radius: 10px;
  background: var(--bg-muted); color: var(--text-secondary);
  font-size: 14px; font-weight: 600;
  text-align: center; width: 100%;
  min-height: 44px;
}

/* ============ OPTION ROWS ============ */
.option-list { display: flex; flex-direction: column; gap: 2px; }
.option-row {
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  height: 52px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 14px; color: var(--text-secondary);
  text-align: left; width: 100%;
}
.option-row:active { background: var(--bg-muted); }
.option-row i.ti { font-size: 18px; color: var(--text-muted); }

/* ============ TASK DETAIL ============ */
.detail-title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; padding-top: 8px;
}
.dt-title { font-size: 17px; font-weight: 600; flex: 1; line-height: 1.35; }
.dt-edit {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--bg-muted); font-size: 16px;
}
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.info-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.info-row i.ti { font-size: 16px; color: var(--accent); flex-shrink: 0; }
.ir-label { color: var(--text-muted); min-width: 72px; }
.ir-value { color: var(--text-primary); font-weight: 500; }

.notes-block { background: var(--bg-muted); border-radius: 12px; padding: 12px; margin: 14px 0; }
.notes-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.nh-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.nh-edit {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 14px; color: var(--text-muted);
}
.notes-body { font-size: 14px; color: var(--text-secondary); line-height: 1.5; white-space: pre-wrap; }
.notes-body.empty { color: var(--text-muted); font-style: italic; }
.action-row-3 {
  display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap;
}
.action-row-3 > * { flex: 1; justify-content: center; }

/* ============ EMPTY STATE ============ */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 40px 20px; text-align: center;
}
.empty-state i.ti { font-size: 44px; color: var(--text-disabled); }
.es-text { font-size: 14px; color: var(--text-muted); line-height: 1.4; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0));
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(17,24,39,0.9);
  color: #fff; font-size: 13px; font-weight: 500;
  padding: 10px 18px; border-radius: 20px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ SKELETON LOADING (IMPROVEMENT 6) ============ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--border-color) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 10px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card { height: 80px; margin-bottom: 10px; }
.skeleton-text { height: 14px; width: 60%; margin-bottom: 8px; }

/* ============ PWA INSTALL FAB (MOBILE 1) ============ */
.install-fab {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0));
  left: 50%; transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  border-radius: 24px;
  height: 44px;
  padding: 0 20px;
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  z-index: 60;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
  white-space: nowrap;
}
.install-fab.hidden { display: none; }
.install-fab:active { opacity: 0.85; }

/* ============ MISC ============ */
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.accent { color: var(--accent); }
.danger { color: var(--danger); }

/* ============ REMINDER LIST (per-task) ============ */
.reminder-list {
  display: flex; flex-direction: column;
  gap: 8px;
}
.reminder-empty {
  font-size: 12px; color: var(--text-muted);
  font-style: italic;
  padding: 14px; text-align: center;
  background: var(--bg-muted); border-radius: 10px;
}
.reminder-row {
  background: var(--bg-muted); border-radius: 12px;
  padding: 10px;
  border: 1px solid var(--border-color);
  position: relative;
}
.reminder-row-top {
  display: flex; align-items: center; gap: 8px;
}
.reminder-row-top .form-select {
  flex: 1;
  background-color: var(--bg-card);
}
.reminder-del {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 16px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}
.reminder-del:active {
  background: var(--bg-danger-soft);
  color: var(--danger);
}
.reminder-custom {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}
.reminder-custom.hidden { display: none; }
.reminder-custom .form-input,
.reminder-custom .form-select {
  background-color: var(--bg-card);
  min-height: 40px;
  font-size: 13px;
}
.reminder-custom-label {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-weight: 500;
}
.reminder-custom-preview {
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  padding: 4px 8px;
  background: var(--bg-accent-soft);
  border-radius: 6px;
  display: inline-block;
}

/* ============ CUSTOM RINGTONES MANAGEMENT ============ */
.custom-ring-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.cr-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  flex-shrink: 0;
  font-size: 18px;
}
.cr-info { flex: 1; min-width: 0; }
.cr-name {
  font-size: 14px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cr-size { font-size: 11px; color: var(--text-tertiary); }
.cr-action {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text-tertiary);
  font-size: 16px;
  flex-shrink: 0;
}
.cr-action:active { background: var(--bg-muted); }
.cr-action.danger:active { background: var(--bg-danger-soft); color: var(--danger); }

/* ============ BEAUTIFUL IN-APP NOTIFICATIONS ============ */
#inapp-notif-stack {
  position: fixed;
  top: calc(56px + env(safe-area-inset-top, 0) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: calc(100% - 24px);
  max-width: 420px;
  display: flex; flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.inapp-notif {
  pointer-events: all;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 14px 14px 14px 14px;
  display: flex; align-items: flex-start; gap: 12px;
  box-shadow:
    0 12px 30px rgba(0,0,0,0.18),
    0 4px 12px rgba(0,0,0,0.10),
    inset 0 1px 0 rgba(255,255,255,0.6);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  transform: translateY(-20px) scale(0.96);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}
.inapp-notif.show { transform: translateY(0) scale(1); opacity: 1; }
.inapp-notif.hide { transform: translateY(-20px) scale(0.96); opacity: 0; }

/* Animated glow strip on the left */
.inapp-notif-glow {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), #7c3aed);
  animation: notifGlow 2s ease-in-out infinite;
}
.inapp-notif.kind-alarm .inapp-notif-glow {
  background: linear-gradient(180deg, var(--danger), #f59e0b);
}
.inapp-notif.kind-overdue .inapp-notif-glow {
  background: linear-gradient(180deg, var(--warn), var(--danger));
}
@keyframes notifGlow {
  0%, 100% { opacity: 0.6; box-shadow: 2px 0 12px rgba(37,99,235,0.4); }
  50%      { opacity: 1.0; box-shadow: 2px 0 18px rgba(37,99,235,0.7); }
}

.inapp-notif-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
  margin-left: 4px;
}
.inapp-notif.kind-alarm .inapp-notif-icon {
  background: linear-gradient(135deg, var(--danger), #f59e0b);
  box-shadow: 0 4px 14px rgba(220,38,38,0.45);
  animation: alarmShake 0.6s ease-in-out infinite;
}
.inapp-notif.kind-overdue .inapp-notif-icon {
  background: linear-gradient(135deg, var(--warn), var(--danger));
  box-shadow: 0 4px 14px rgba(217,119,6,0.45);
}
@keyframes alarmShake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  20%      { transform: rotate(-12deg) scale(1.05); }
  40%      { transform: rotate(12deg) scale(1.05); }
  60%      { transform: rotate(-8deg) scale(1.02); }
  80%      { transform: rotate(8deg) scale(1.02); }
}

.inapp-notif-body { flex: 1; min-width: 0; }
.inapp-notif-title {
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  line-height: 1.3;
}
.inapp-notif-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}
.inapp-notif-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.inn-btn {
  font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 18px;
  background: var(--bg-muted);
  color: var(--text-secondary);
  min-height: 32px;
  transition: transform 0.1s, background 0.15s !important;
}
.inn-btn.inn-open {
  background: var(--accent); color: #fff;
}
.inn-btn.inn-snooze {
  background: var(--warn); color: #fff;
}
.inn-btn:active { transform: scale(0.94); }

.inapp-notif-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  z-index: 1;
}
.inapp-notif-close:active { background: var(--bg-muted); }

/* Dark mode notification card adjustments */
[data-theme="dark"] .inapp-notif {
  background: rgba(15, 24, 38, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-color: rgba(96, 165, 250, 0.18);
  box-shadow:
    0 12px 36px rgba(0,0,0,0.55),
    0 4px 12px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
[data-theme="dark"] .inapp-notif-icon {
  background: linear-gradient(135deg, #60A5FA, #818CF8);
  box-shadow: 0 4px 16px rgba(96,165,250,0.5);
}
[data-theme="dark"] .inapp-notif.kind-alarm .inapp-notif-icon {
  background: linear-gradient(135deg, #F87171, #FBBF24);
  box-shadow: 0 4px 16px rgba(248,113,113,0.55);
}
[data-theme="dark"] .inapp-notif-glow {
  background: linear-gradient(180deg, #60A5FA, #A78BFA);
}
[data-theme="dark"] .inapp-notif.kind-alarm .inapp-notif-glow {
  background: linear-gradient(180deg, #F87171, #FBBF24);
}

/* Mobile fix: stack on small screens with side margins */
@media (min-width: 600px) {
  #inapp-notif-stack {
    left: auto;
    right: 24px;
    transform: none;
    width: 360px;
  }
}

/* ============ MOBILE 3: Responsive — Tablet & Desktop ============ */
@media (min-width: 600px) {
  body {
    background: #CBD5E1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 0 24px;
  }

  /* FIX: dark-theme is on <html> (documentElement), not <body>.
     Correct selectors: html[data-theme="dark"] or :root[data-theme="dark"] */
  html[data-theme="dark"] body,
  :root[data-theme="dark"] body {
    background: #040810;
  }

  #app {
    border-radius: 28px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    min-height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    overflow: hidden;
    position: relative;
  }

  html[data-theme="dark"] #app,
  :root[data-theme="dark"] #app {
    box-shadow: 0 12px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(96,165,250,0.08);
  }

  .app-header {
    border-radius: 28px 28px 0 0;
    left: 0;
    transform: none;
    width: 100%;
  }

  .bottom-nav {
    border-radius: 0 0 28px 28px;
    left: 0;
    transform: none;
    width: 100%;
  }

  .app-main {
    max-height: calc(100vh - 48px - calc(56px + env(safe-area-inset-top, 0)) - calc(64px + env(safe-area-inset-bottom, 0)));
    overflow-y: auto;
  }

  .overlay, .modal-overlay {
    border-radius: 28px;
    position: absolute;
  }

  .toast {
    position: absolute;
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
  }
}

/* ============ OFFLINE BANNER position fix ============ */
#offline-banner {
  position: fixed;
  top: calc(56px + env(safe-area-inset-top, 0));
  left: 0; right: 0; z-index: 99;
}

/* ============ PREMIUM DARK MODE ENHANCEMENTS ============ */

/* Richer card depth in dark mode */
[data-theme="dark"] .unit-card,
[data-theme="dark"] .task-card,
[data-theme="dark"] .summary-card,
[data-theme="dark"] .head-card,
[data-theme="dark"] .settings-list,
[data-theme="dark"] .settings-app-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* Accent glow on active nav items in dark mode */
[data-theme="dark"] .nav-item.active {
  text-shadow: 0 0 12px rgba(96,165,250,0.5);
}
[data-theme="dark"] .nav-item.active i.ti {
  filter: drop-shadow(0 0 6px rgba(96,165,250,0.45));
}

/* Richer header in dark mode — subtle gradient instead of flat accent */
[data-theme="dark"] .app-header {
  background: linear-gradient(135deg, #1E40AF 0%, #1D4ED8 60%, #2563EB 100%);
  box-shadow: 0 2px 12px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.06);
}

/* Priority bar glow in dark mode */
[data-theme="dark"] .task-card.prio-urgent   .pbar { box-shadow: 2px 0 8px rgba(248,113,113,0.4); }
[data-theme="dark"] .task-card.prio-moderate .pbar { box-shadow: 2px 0 8px rgba(251,191,36,0.35); }
[data-theme="dark"] .task-card.prio-normal   .pbar { box-shadow: 2px 0 8px rgba(74,222,128,0.35); }

/* Form inputs — subtle inner glow on focus in dark mode */
[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.15);
}

/* Skeleton shimmer adapted for dark mode */
[data-theme="dark"] .skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-muted) 25%,
    #1E2D42 50%,
    var(--bg-muted) 75%
  );
  background-size: 200% 100%;
}

/* Bottom nav dark mode glass effect */
[data-theme="dark"] .bottom-nav {
  background: rgba(15,24,38,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top-color: rgba(96,165,250,0.1);
}

/* Sheet dark mode glass */
[data-theme="dark"] .sheet {
  background: var(--bg-card);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.5), 0 -1px 0 rgba(96,165,250,0.08);
}

/* Toast dark mode */
[data-theme="dark"] .toast {
  background: rgba(30,45,66,0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(96,165,250,0.15);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* Accent soft badge glow in dark */
[data-theme="dark"] .badge-urgent {
  background: rgba(248,113,113,0.18);
  color: #FCA5A5;
}
[data-theme="dark"] .badge-moderate {
  background: rgba(251,191,36,0.16);
  color: #FCD34D;
}
[data-theme="dark"] .badge-normal {
  background: rgba(74,222,128,0.15);
  color: #6EE7B7;
}
[data-theme="dark"] .badge-formal {
  background: rgba(96,165,250,0.15);
  color: #93C5FD;
}

/* Theme toggle button premium feel */
.theme-toggle-btn {
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease !important;
}
[data-theme="dark"] .theme-toggle-btn.active {
  box-shadow: 0 0 12px rgba(96,165,250,0.25);
}

/* Overdue banner dark mode */
[data-theme="dark"] .overdue-banner {
  background: rgba(248,113,113,0.1);
  border-color: rgba(248,113,113,0.25);
  box-shadow: inset 0 1px 0 rgba(248,113,113,0.1);
}

/* Calendar selected cell glow */
[data-theme="dark"] .cal-cell.selected {
  box-shadow: 0 0 12px rgba(96,165,250,0.4);
}

/* Date strip selected item glow */
[data-theme="dark"] .date-item.selected {
  box-shadow: 0 2px 12px rgba(96,165,250,0.35);
}

/* Primary button glow in dark */
[data-theme="dark"] .btn-primary {
  box-shadow: 0 2px 12px rgba(96,165,250,0.3);
}
[data-theme="dark"] .btn-primary:active {
  box-shadow: none;
}

/* Red dot notification indicator */
[data-theme="dark"] .red-dot {
  border-color: #1D4ED8;
  box-shadow: 0 0 6px rgba(248,113,113,0.5);
}

/* Settings group label styling in dark */
[data-theme="dark"] .settings-group-label {
  color: rgba(96,165,250,0.7);
  letter-spacing: 0.1em;
}
