/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg: #F0F4FF;
  --surface: #FFFFFF;
  --surface2: #F7F9FF;
  --border: #E2E8F7;
  --primary: #4F6EF7;
  --primary-hover: #3B5CE4;
  --primary-light: #EEF1FF;
  --accent: #FF6B6B;
  --accent2: #FFB347;
  --green: #34C759;
  --green-light: #E8FAF0;
  --red: #FF3B30;
  --text: #1A1F36;
  --text2: #5A6480;
  --text3: #9AA0B8;
  --sidebar-bg: #1A1F36;
  --sidebar-text: #C8CEEA;
  --sidebar-active: #4F6EF7;
  --sidebar-active-bg: rgba(79,110,247,0.15);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(79,110,247,0.08);
  --shadow-lg: 0 8px 32px rgba(79,110,247,0.14);
  --font: 'Nunito', sans-serif;
  --font-body: 'Nunito Sans', sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, select, textarea { font-family: var(--font); }

/* ── App Layout ────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 64px;
  min-width: 64px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 12px;
}
.logo-icon { font-size: 28px; }
.logo-text { display: none; }

.nav-links { list-style: none; padding: 0 6px; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.18s;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  position: relative;
}
.nav-link span:not(.nav-icon):not(.nav-badge) { display: none; }
.nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  border-left-color: var(--primary);
}
.nav-icon {
  width: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.18s;
}
.nav-link:hover .nav-icon,
.nav-link.active .nav-icon { opacity: 1; }
.nav-icon svg { display: block; }

.nav-badge {
  margin-left: auto;
  background: #FF3B30;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 10px;
  padding: 2px 7px;
  min-width: 18px;
  text-align: center;
  line-height: 14px;
  animation: badgePop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes badgePop { from { transform: scale(0); } to { transform: scale(1); } }

.sidebar-members { display: none; }
.sidebar-member-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
}
.member-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.member-avatar {
  font-size: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 20px 24px 16px;
  min-width: 0;
  overflow-y: auto;
}

/* Dashboard only — fills viewport, columns scroll internally */
.main-content.dashboard-layout {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}
.dashboard-layout .page-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
  margin-bottom: 10px;
  gap: 12px;
}
.dashboard-layout .header-right {
  justify-self: end;
}
.page-title { font-size: 22px; font-weight: 900; letter-spacing: -0.5px; }
.page-subtitle { font-size: 13px; color: var(--text2); margin-top: 1px; font-weight: 600; }

/* ── Dashboard 3-column grid ───────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1.5fr;
  gap: 18px;
  flex: 1;
  min-height: 0;
}
.dashboard-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding-right: 4px;
}

.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 42px;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(79,110,247,0.3); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,110,247,0.4); }
.btn-secondary { background: var(--surface); color: var(--primary); border: 2px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--red); border: 2px solid rgba(255,59,48,0.3); padding: 8px 16px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.btn-danger-ghost:hover { background: rgba(255,59,48,0.08); }
.btn-icon { padding: 8px 14px; font-size: 20px; color: var(--text2); border-radius: 8px; }
.btn-icon:hover { background: var(--surface); color: var(--text); }
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: #444;
  border: 2px solid #E0E0E0;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  min-height: 42px;
}
.btn-google:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); border-color: #C0C0C0; }

.btn-close {
  background: var(--surface2);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-close:hover { background: var(--border); color: var(--text); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

/* ── Sections ──────────────────────────────────────────────── */
.dashboard-section { margin-bottom: 20px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title { font-size: 18px; font-weight: 900; }
.section-link { font-size: 13px; font-weight: 700; color: var(--primary); }
.section-link:hover { text-decoration: underline; }

/* ── Event Cards ───────────────────────────────────────────── */
.event-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow);
  border-top: 1.5px solid var(--border);
  border-right: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
}
.event-card-title { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.event-card-time { font-size: 12px; color: var(--text2); font-weight: 600; }
.event-card-member {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 6px;
}

/* ── Calendar ──────────────────────────────────────────────── */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.calendar-month-title { font-size: 22px; font-weight: 900; flex: 1; }

.calendar-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
  min-width: 0;
}

.cal-day-header {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text3);
  padding: 6px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-day {
  min-height: 80px;
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  min-width: 0;
  overflow: hidden;
}
.cal-day:hover { background: var(--primary-light); }
.cal-day.other-month { opacity: 0.35; }
.cal-day.today .cal-date {
  background: var(--primary);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day.selected { background: var(--primary-light); }
.cal-date { font-size: 14px; font-weight: 800; margin-bottom: 4px; }
.cal-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event-dot {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.day-events-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
}

/* ── Chores ────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--radius-sm);
  width: fit-content;
  border: 1.5px solid var(--border);
}
.filter-tab {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text2);
  transition: all 0.15s;
  min-height: 38px;
}
.filter-tab.active { background: var(--primary); color: #fff; }
.filter-tab:hover:not(.active) { background: var(--surface2); }

.member-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.member-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  border: 2px solid transparent;
  transition: all 0.15s;
  min-height: 36px;
  background: var(--surface);
  color: var(--text2);
  border-color: var(--border);
}
.member-filter-btn.active { color: #fff; border-color: transparent; }
.member-filter-btn:hover { transform: scale(1.03); }

.chores-list { display: flex; flex-direction: column; gap: 10px; }

.chore-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 18px 14px 15px;
  border-left: 3px solid var(--border);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  transition: all 0.15s;
}
.chore-item:hover { box-shadow: var(--shadow-lg); }
.chore-item.completed { opacity: 0.55; }
.chore-item.completed .chore-title { text-decoration: line-through; }

.chore-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  font-size: 14px;
}
.chore-check:hover { border-color: var(--green); background: var(--green-light); }
.chore-check.checked { background: var(--green); border-color: var(--green); color: #fff; }

.chore-info { flex: 1; min-width: 0; }
.chore-title { font-weight: 800; font-size: 15px; margin-bottom: 3px; }
.chore-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chore-due { font-size: 12px; font-weight: 600; color: var(--text2); }
.chore-due.overdue { color: var(--red); }
.chore-points { font-size: 12px; font-weight: 700; color: var(--accent2); }
.chore-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  color: #fff;
}
.chore-recurrence { font-size: 11px; color: var(--text3); font-weight: 600; }

.chore-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.chore-item:hover .chore-actions { opacity: 1; }
.chore-action-btn {
  background: var(--surface2);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  transition: all 0.12s;
  min-height: 30px;
}
.chore-action-btn:hover { background: var(--border); color: var(--text); }
.chore-action-btn.delete:hover { background: rgba(255,59,48,0.1); color: var(--red); }

/* ── Chore Templates ───────────────────────────────────────── */
.chore-template-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 130px;
  overflow-y: auto;
  padding: 4px 2px;
}
.chore-template-chip {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chore-template-chip:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.chore-template-chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Leaderboard ───────────────────────────────────────────── */
.leaderboard { display: flex; flex-direction: column; gap: 10px; }
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 20px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}
.leaderboard-rank { font-size: 20px; font-weight: 900; width: 32px; text-align: center; }
.leaderboard-rank.first { color: #FFD700; }
.leaderboard-rank.second { color: #C0C0C0; }
.leaderboard-rank.third { color: #CD7F32; }
.leaderboard-info { flex: 1; }
.leaderboard-name { font-weight: 800; font-size: 16px; }
.leaderboard-sub { font-size: 12px; color: var(--text2); font-weight: 600; }
.leaderboard-points {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent2);
}
.leaderboard-pts-label { font-size: 11px; font-weight: 700; color: var(--text3); text-align: right; }

/* ── Settings ──────────────────────────────────────────────── */
.members-list { display: flex; flex-direction: column; gap: 10px; }
.member-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 20px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}
.member-item-avatar { font-size: 28px; }
.member-item-info { flex: 1; }
.member-item-name { font-weight: 800; font-size: 16px; }
.member-item-sub { font-size: 12px; color: var(--text2); font-weight: 600; }
.member-color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
  border: 2px solid rgba(0,0,0,0.1);
}

.settings-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.settings-card-info { flex: 1; min-width: 0; }
.settings-card-info h3 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.settings-desc { font-size: 13px; color: var(--text2); font-weight: 600; margin-bottom: 8px; }
.settings-card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.google-status { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.connected { background: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.status-dot.disconnected { background: var(--text3); }
.status-text.connected { color: var(--green); }

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,31,54,0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h3 { font-size: 20px; font-weight: 900; }
.modal-body { padding: 16px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1.5px solid var(--border);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 800; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  font-size: 15px;
  font-family: var(--font);
  font-weight: 600;
  color: var(--text);
  background: var(--surface2);
  transition: border-color 0.15s;
  min-height: 44px;
}
.form-input:focus { outline: none; border-color: var(--primary); background: #fff; }
textarea.form-input { resize: vertical; min-height: 72px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.color-picker { display: flex; align-items: center; gap: 12px; }
.color-input { width: 44px; height: 44px; border: none; border-radius: 8px; cursor: pointer; padding: 2px; background: var(--surface2); }
.color-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.color-preset {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.12s;
}
.color-preset:hover, .color-preset.selected { border-color: var(--text); transform: scale(1.15); }

.emoji-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.emoji-opt {
  font-size: 24px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: all 0.12s;
}
.emoji-opt:hover { background: var(--surface2); }
.emoji-opt.selected { border-color: var(--primary); background: var(--primary-light); }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--text3);
  font-weight: 700;
  font-size: 15px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--sidebar-bg);
  color: #fff;
  padding: 12px 24px;
  border-radius: 40px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  z-index: 9000;
  animation: toastIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
}
.toast.success { background: #1a8a3c; }
.toast.error   { background: var(--red); }
.toast.info    { background: var(--primary); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Settings Tabs ─────────────────────────────────────────── */
.settings-tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 6px;
  border: 1.5px solid var(--border);
  width: fit-content;
  flex-wrap: wrap;
}
.settings-tab {
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  background: none;
  border: none;
  font-family: var(--font);
}
.settings-tab:hover:not(.active) { background: var(--surface2); color: var(--text); }
.settings-tab.active { background: var(--primary); color: #fff; }
.settings-tab-panel { display: none; }
.settings-tab-panel.active { display: block; }

/* ── Skeleton Loaders ──────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}
.sk-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  margin-bottom: 10px;
}
.sk-line { height: 13px; margin-bottom: 8px; }
.sk-line.w100 { width: 100%; }
.sk-line.w70  { width: 70%;  }
.sk-line.w45  { width: 45%;  }

/* ── Security Compact Rows ─────────────────────────────────── */
.sec-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: 14px;
  border: 2px solid var(--border);
  margin-bottom: 10px;
  transition: box-shadow 0.15s;
}
.sec-row:hover { box-shadow: var(--shadow-lg); }
.sec-row.sec-open   { border-color: var(--red);   background: #fff8f8; }
.sec-row.sec-closed { border-color: var(--green);  background: #f6fef9; }
.sec-row.sec-armed  { border-color: var(--accent2); background: #fffbf0; }
.sec-row.sec-disarmed { border-color: var(--primary); background: var(--primary-light); }
.sec-row-icon { font-size: 26px; flex-shrink: 0; width: 36px; text-align: center; }
.sec-row-info { flex: 1; min-width: 0; }
.sec-row-name { font-weight: 800; font-size: 15px; }
.sec-row-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  margin-top: 4px;
  background: var(--surface2);
  color: var(--text2);
}
.sec-row-badge.open     { background: #ffeaea; color: var(--red); }
.sec-row-badge.closed   { background: #e6f9ed; color: #1a8a3c; }
.sec-row-badge.armed    { background: #fff3cd; color: #856404; }
.sec-row-badge.disarmed { background: var(--primary-light); color: var(--primary); }
.sec-row-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.sec-section  { display: flex; flex-direction: column; }
.sec-section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0 16px; }

/* ── Alarm Card ─────────────────────────────────────────────── */
.alarm-card {
  background: var(--surface);
  border-radius: 14px;
  border: 2px solid var(--primary);
  padding: 18px 20px;
  margin-bottom: 10px;
}
.alarm-card.sec-armed { border-color: var(--accent2); background: #fffbf0; }
.alarm-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.alarm-card-icon { font-size: 28px; }
.alarm-card-name { font-weight: 800; font-size: 16px; }
.alarm-card-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.alarm-card-btns .btn { flex: 1; min-width: 100px; justify-content: center; font-size: 14px; }

/* ── Camera Loading Placeholder ────────────────────────────── */
.camera-feed-card { position: relative; }
.camera-feed-card .camera-feed-img { display: none; }
.camera-feed-card .camera-feed-img.loaded { display: block; }
.camera-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #1a1f36 0%, #2a3464 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255,255,255,0.35);
  font-size: 13px;
  font-weight: 600;
}
.camera-placeholder-icon { font-size: 32px; opacity: 0.4; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .page-title { font-size: 22px; }
  .cal-day { min-height: 56px; }
  .cal-event-dot { display: none; }
  .cal-day.has-events::after {
    content: '•';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--primary);
    font-size: 16px;
  }
  .form-row { grid-template-columns: 1fr; }
  .settings-card { flex-direction: column; align-items: flex-start; }
}

/* ── Calendar Picker ───────────────────────────────────────── */
.cal-picker { margin-top: 12px; }
.cal-picker-title { font-size: 12px; font-weight: 800; color: var(--text2); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; }
.cal-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 4px;
  border: 2px solid transparent;
}
.cal-option:hover { background: var(--surface2); }
.cal-option.selected { background: var(--primary-light); border-color: var(--primary); }
.cal-option-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cal-option-name { font-size: 14px; font-weight: 700; flex: 1; }
.cal-option-check { color: var(--primary); font-size: 16px; }
.cal-picker-save { margin-top: 10px; }

/* ── Standalone Calendar Picker Section ────────────────────── */
#familyCalPickerSection {
  flex-direction: column !important;
  align-items: stretch !important;
}

/* ── Slideshow Overlay ─────────────────────────────────────── */
#slideshowOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  cursor: pointer;
}
#slideshowOverlay.active { display: block; }

.slideshow-bg {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
  overflow: hidden;
}
/* Blurred backdrop fills the frame */
.slideshow-bg::before {
  content: '';
  position: absolute;
  inset: -20px;
  background-image: inherit;
  background-size: cover;
  background-position: center;
  filter: blur(18px) brightness(0.7);
  transform: scale(1.1);
}
/* Sharp photo centered with contain */
.slideshow-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: inherit;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

.slideshow-info {
  position: absolute;
  bottom: 80px;
  left: 60px;
  color: white;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  pointer-events: none;
}
.slideshow-clock {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
}
.slideshow-date {
  font-size: 24px;
  font-weight: 600;
  margin-top: 8px;
  opacity: 0.9;
}

.slideshow-controls {
  position: absolute;
  bottom: 30px;
  right: 40px;
  display: flex;
  gap: 12px;
}
.slideshow-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slideshow-btn:hover { background: rgba(255,255,255,0.35); }

.slideshow-tap-hint {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* ── Slideshow Trigger Button ──────────────────────────────── */
.slideshow-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  transition: all 0.2s;
  z-index: 100;
}
.slideshow-trigger:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.1);
}

/* Day toggle checkboxes */
.day-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 2px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.15s;
  user-select: none;
}
.day-toggle input { display: none; }
.day-toggle:has(input:checked) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Multi-assign checkboxes */
.member-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 2px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.15s;
  user-select: none;
}
.member-checkbox-label input { display: none; }
.member-checkbox-label.checked {
  color: white;
  border-color: transparent;
}

/* Dashboard chores by person */
.person-chores-section { margin-bottom: 16px; }
.person-chores-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 800;
  font-size: 15px;
}
.dashboard-chore-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
  background: var(--surface);
  border-radius: 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--border);
  border: 1.5px solid var(--border);
  transition: all 0.15s;
}
.dashboard-chore-item.done { opacity: 0.5; }
.dashboard-chore-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.dashboard-chore-check.checked { color: white; border-color: transparent; }
.dashboard-chore-title { font-size: 14px; font-weight: 600; flex: 1; }
.dashboard-chore-title.done { text-decoration: line-through; }
.dashboard-chore-pts { font-size: 12px; color: var(--text2); }
.chore-tod-group-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  margin: 10px 0 4px 0;
  padding-left: 4px;
}
.chore-tod-group-header:first-child { margin-top: 4px; }

.quote-author {
  font-style: normal;
  font-weight: 700;
  color: var(--text2);
}

/* ── Daily Chores View ─────────────────────────────────────── */
.chore-person-section {
  margin-bottom: 24px;
}
.chore-person-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0 4px;
}
.chore-person-avatar { font-size: 22px; }
.chore-person-name { font-weight: 800; font-size: 17px; flex: 1; }
.chore-person-count {
  font-size: 12px;
  color: var(--text2);
  background: var(--bg2);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
}

.chore-done-section {
  margin-top: 8px;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.chore-done-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text2);
  cursor: pointer;
  background: var(--bg2);
  user-select: none;
}
.chore-done-header:hover { background: var(--border); }
#doneSectionBody { padding: 8px; background: var(--surface); }

/* Chore title done state */
.chore-title.done {
  text-decoration: line-through;
  color: var(--text2);
}

/* Completing animation */
@keyframes choreComplete {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 0.6; }
}
.chore-item.completing {
  animation: choreComplete 0.4s ease forwards;
}

/* ── Chore Columns (Today View) ──────────────────────────────── */
.chore-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  align-items: start;
}
.chore-column {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.chore-column-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  background: var(--surface);
}
.chore-column-avatar { font-size: 24px; }
.chore-column-name { font-weight: 800; font-size: 18px; flex: 1; }
.chore-column-count {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
}
.chore-column-body { padding: 8px; }

.chore-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 12px 12px 10px;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1.5px solid var(--border);
  border-left: 3px solid var(--border);
  background: var(--bg);
  transition: all 0.2s;
}
.chore-card:last-child { margin-bottom: 0; }
.chore-card.done { opacity: 0.55; background: var(--bg2); }
.chore-card:hover { box-shadow: var(--shadow-lg); }
.chore-card.missed { opacity: 0.5; background: var(--bg2); border-left-color: var(--text-muted) !important; cursor: default; }
.chore-card.missed:hover { box-shadow: none; }
.missed-x { display:flex; align-items:center; justify-content:center; width:22px; height:22px; border-radius:50%; border:2px solid var(--text-muted); color:var(--text-muted); font-size:13px; flex-shrink:0; }
.missed-section { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }

.chore-card-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.2s;
}
.chore-card-check:hover { transform: scale(1.1); }
.chore-card-check.checked { color: white; }

.chore-card-body { flex: 1; min-width: 0; }
.chore-card-title {
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 2px;
  transition: all 0.2s;
}
.chore-card-title.done {
  text-decoration: line-through;
  color: var(--text2);
}
.chore-card-desc { font-size: 12px; color: var(--text2); margin-bottom: 3px; }
.chore-card-pts { font-size: 12px; color: var(--text2); }

.chore-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.chore-card:hover .chore-card-actions { opacity: 1; }

/* chore title done in full list */
.chore-title.done {
  text-decoration: line-through;
  color: var(--text2);
}

/* ── Time of Day ──────────────────────────────────────────── */
.tod-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.15s;
  user-select: none;
  background: var(--bg);
}
.tod-btn input { display: none; }
.tod-btn.active,
.tod-btn:has(input:checked):not(:has(input[value=""])) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.chore-tod {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  margin-right: 4px;
  text-transform: capitalize;
}
.chore-tod-morning  { background: #fff3cd; color: #856404; }
.chore-tod-afternoon { background: #fff0d6; color: #b35c00; }
.chore-tod-evening  { background: #e8e4f7; color: #5e35b1; }

/* ── Time-of-Day Sections in Columns ─────────────────────── */
.tod-section {
  margin-bottom: 12px;
}
.tod-section:last-child { margin-bottom: 0; }

.tod-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 4px 4px;
  margin-bottom: 4px;
}
.tod-section-progress {
  background: currentColor;
  color: white;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 20px;
  opacity: 0.85;
}

.tod-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.tod-summary-chip {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1.5px solid currentColor;
  opacity: 0.9;
  transition: all 0.2s;
}
.tod-summary-chip.done { opacity: 1; }

/* Override column header to accommodate ring */
.chore-column-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 14px 12px;
  background: var(--surface);
}

/* ── Stock Ticker ─────────────────────────────────────────── */
.stock-ticker {
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--surface);
  border-radius: 10px;
  padding: 0;
  margin-bottom: 10px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  height: 34px;
}
.ticker-scroll {
  display: flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
}
.ticker-item { display: flex; align-items: center; gap: 5px; padding: 0 14px; height: 34px; }
.ticker-sep  { color: var(--border); font-size: 14px; line-height: 1; flex-shrink: 0; }
.ticker-symbol { font-weight: 800; font-size: 12px; color: var(--text); letter-spacing: 0.04em; }
.ticker-price  { font-size: 12px; font-weight: 600; color: var(--text); }
.ticker-change { font-size: 11px; font-weight: 700; }
.ticker-up   { color: #34c759; }
.ticker-down { color: var(--red); }

/* ── Security Page ─────────────────────────────────────────── */
.security-device-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--border);
  text-align: center;
}
.security-device-card.sec-open   { border-color: var(--red); }
.security-device-card.sec-closed { border-color: #34c759; }
.sec-card-icon  { font-size: 40px; line-height: 1; }
.sec-card-name  { font-weight: 800; font-size: 16px; }
.sec-card-state { font-size: 13px; font-weight: 700; text-transform: capitalize; padding: 3px 10px; border-radius: 20px; background: var(--bg2); }
.sec-card-state.state-open   { background: #ffeaea; color: var(--red); }
.sec-card-state.state-closed { background: #e6f9ed; color: #1a8a3c; }
.sec-card-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: center; flex-wrap: wrap; }
.sec-btn { font-size: 13px; padding: 8px 14px; }

/* ── Camera Feeds ──────────────────────────────────────────── */
.camera-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.camera-feed-card { background: var(--surface); border-radius: 16px; overflow: hidden; border: 1px solid var(--border); cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.camera-feed-card:hover { transform: scale(1.01); box-shadow: var(--shadow-lg); }
.camera-feed-label { padding: 10px 14px; font-weight: 700; font-size: 14px; border-bottom: 1px solid var(--border); }
.camera-feed-iframe { width: 100%; aspect-ratio: 16/9; border: none; display: block; background: #000; }
.camera-feed-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #000; }

/* ── Camera Fullscreen Modal ────────────────────────────────── */
.camera-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.camera-modal {
  width: min(92vw, 1100px);
  background: #111318;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  animation: scaleIn 0.2s ease;
}
.camera-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: #1a1f2e;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.camera-modal-title { color: #fff; font-weight: 700; font-size: 16px; flex: 1; text-align: center; }
.camera-modal-close {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.1); color: #fff;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.camera-modal-close:hover { background: rgba(255,255,255,0.2); }
.camera-modal-nav {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.1); color: #fff;
  font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.camera-modal-nav:hover { background: rgba(255,255,255,0.22); }
.camera-modal-img { width: 100%; display: block; background: #000; max-height: 72vh; object-fit: contain; cursor: grab; }
.camera-modal-dots { display: flex; justify-content: center; gap: 6px; padding: 10px 0 6px; }
.cam-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.3); transition: background 0.2s; }
.cam-dot.active { background: #fff; }
@keyframes scaleIn { from { transform: scale(0.93); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }

/* ── School Menu Widget ───────────────────────────────────── */
.menu-compact {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.menu-row-label {
  font-size: 12px;
  font-weight: 900;
  color: var(--text2);
  white-space: nowrap;
  min-width: 72px;
}
.menu-row-items {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  line-height: 1.5;
}
.menu-row-items .menu-entree { font-weight: 800; color: var(--primary); }

/* ── Weather Widget ─────────────────────────────────────────── */
.weather-widget {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 20px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 110px;
  flex-shrink: 0;
  text-align: center;
}
.weather-widget:empty { display: none; }
.weather-icon { font-size: 32px; line-height: 1; }
.weather-temp { font-size: 26px; font-weight: 900; color: var(--text); line-height: 1.1; }
.weather-condition { font-size: 12px; color: var(--text2); font-weight: 600; margin-top: 2px; }
.weather-hilo { font-size: 12px; color: var(--text2); font-weight: 700; margin-top: 2px; }
.weather-city { font-size: 11px; color: var(--text2); font-weight: 600; opacity: 0.7; margin-top: 1px; }
.weather-tomorrow {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  width: 100%; text-align: center;
}
.weather-tmr-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); margin-bottom: 3px; }
.weather-tmr-row { display: flex; align-items: center; justify-content: center; gap: 5px; }
.weather-tmr-icon { font-size: 16px; }
.weather-tmr-hilo { font-size: 12px; font-weight: 700; color: var(--text2); }
.weather-tmr-precip { font-size: 11px; color: var(--primary); font-weight: 600; }
@media (max-width: 600px) { .weather-widget { display: none; } }

/* ── Header Right (weather + HA badge group) ────────────────── */
.header-right {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Home Assistant Badge (header) ──────────────────────────── */
.ha-status-badge {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.ha-status-badge:empty { display: none; }
.ha-badge-item {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border-radius: 20px;
  padding: 5px 10px 5px 7px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.ha-badge-item.ha-state-open {
  border-color: rgba(255, 149, 0, 0.4);
  background: rgba(255, 149, 0, 0.06);
}
.ha-badge-item.ha-state-closed {
  border-color: rgba(52, 199, 89, 0.35);
  background: rgba(52, 199, 89, 0.06);
}
.ha-badge-item.ha-alarm-armed {
  border-color: rgba(255, 59, 48, 0.4);
  background: rgba(255, 59, 48, 0.05);
}
.ha-badge-item.ha-alarm-disarmed {
  border-color: rgba(79, 110, 247, 0.35);
  background: rgba(79, 110, 247, 0.05);
}
.ha-badge-icon { font-size: 14px; }
.ha-badge-label { color: var(--text2); }
.ha-badge-state { color: var(--text); }
.ha-state-open .ha-badge-state { color: #e07800; }
.ha-state-closed .ha-badge-state { color: #1a8a3c; }

/* ── Dashboard: All-done mini leaderboard ───────────────────── */
.dash-chores-done {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 14px 16px;
}
.dash-chores-done-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text2);
  margin-bottom: 12px;
}
.dash-mini-lb { display: flex; flex-direction: column; gap: 8px; }
.dash-mini-lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--bg);
}
.dash-mini-lb-medal { font-size: 16px; width: 20px; text-align: center; }
.dash-mini-lb-avatar { font-size: 16px; }
.dash-mini-lb-name  { flex: 1; font-weight: 800; font-size: 14px; }
.dash-mini-lb-pts   { font-weight: 900; font-size: 15px; }
.dash-mini-lb-pts small { font-size: 10px; font-weight: 700; opacity: 0.7; margin-left: 1px; }

/* ── Home Assistant Device Cards (section) ──────────────────── */
.ha-device-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}
.ha-device-card.ha-state-open { border-color: rgba(255, 149, 0, 0.5); }
.ha-device-card.ha-state-closed { border-color: rgba(52, 199, 89, 0.5); }
.ha-device-icon { font-size: 32px; }
.ha-device-info { flex: 1; }
.ha-device-name { font-size: 15px; font-weight: 800; color: var(--text); }
.ha-device-state {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
  text-transform: capitalize;
}
.ha-state-open .ha-device-state { color: #e07800; }
.ha-state-closed .ha-device-state { color: #28a745; }
.ha-state-unknown .ha-device-state { color: var(--text2); }
@media (max-width: 600px) { .ha-status-badge { display: none; } }

/* ── Alarm Card ─────────────────────────────────────────────── */
.ha-alarm-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ha-alarm-card.ha-alarm-disarmed { border-color: rgba(52, 199, 89, 0.5); }
.ha-alarm-card.ha-alarm-armed    { border-color: rgba(255, 59, 48, 0.5); background: rgba(255,59,48,0.03); }
.ha-alarm-card.ha-alarm-triggered { border-color: #ff3b30; background: rgba(255,59,48,0.08); animation: alarm-pulse 1s ease-in-out infinite; }
.ha-alarm-card.ha-alarm-pending  { border-color: rgba(255, 149, 0, 0.5); }
@keyframes alarm-pulse { 0%,100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 4px rgba(255,59,48,0.3); } }

.ha-alarm-header { display: flex; align-items: center; gap: 12px; }
.ha-alarm-icon { font-size: 28px; }
.ha-alarm-info { flex: 1; }
.ha-alarm-name { font-size: 14px; font-weight: 800; color: var(--text2); }
.ha-alarm-state {
  font-size: 18px;
  font-weight: 900;
  margin-top: 1px;
}
.ha-alarm-disarmed .ha-alarm-state { color: #28a745; }
.ha-alarm-armed .ha-alarm-state    { color: #dc3545; }
.ha-alarm-triggered .ha-alarm-state { color: #dc3545; }
.ha-alarm-pending .ha-alarm-state  { color: #e07800; }

.ha-alarm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ha-alarm-btn {
  flex: 1;
  min-width: 90px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface2);
  color: var(--text2);
}
.ha-alarm-btn:hover { transform: translateY(-1px); }
.ha-alarm-btn.active-disarm { background: rgba(52,199,89,0.12); color: #28a745; border-color: rgba(52,199,89,0.4); }
.ha-alarm-btn.active-arm    { background: rgba(255,59,48,0.10); color: #dc3545; border-color: rgba(255,59,48,0.4); }
.ha-alarm-btn:disabled { opacity: 0.45; cursor: default; transform: none; }

/* ── Alarm Badge Popover ────────────────────────────────────── */
.ha-badge-item.ha-alarm-clickable { cursor: pointer; }
.ha-badge-item.ha-alarm-clickable:hover { filter: brightness(1.05); }
.ha-alarm-popover {
  position: fixed;
  z-index: 999;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
  animation: popover-in 0.15s ease;
}
@keyframes popover-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.ha-popover-title { font-size: 12px; font-weight: 800; color: var(--text2); padding: 0 4px 4px; border-bottom: 1px solid var(--border); }
.ha-popover-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  background: var(--surface2);
  color: var(--text);
  border: 2px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s;
}
.ha-popover-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); transform: translateY(-1px); }
.ha-popover-btn.active { background: rgba(52,199,89,0.1); color: #28a745; border-color: rgba(52,199,89,0.4); }
.ha-popover-btn.active-arm { background: rgba(255,59,48,0.08); color: #dc3545; border-color: rgba(255,59,48,0.35); }
.ha-popover-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

/* ── Dark Mode ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0E1017;
  --surface: #1A1E2E;
  --surface2: #222638;
  --border: #2C3150;
  --text: #E8EAF5;
  --text2: #8A90B8;
  --text3: #555A80;
  --primary-light: rgba(79,110,247,0.18);
  --green-light: rgba(52,199,89,0.12);
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}
[data-theme="dark"] .sidebar { background: #0A0C14; }
[data-theme="dark"] .sidebar-logo { border-color: rgba(255,255,255,0.05); }
[data-theme="dark"] .settings-card,
[data-theme="dark"] .form-input,
[data-theme="dark"] .modal { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: var(--surface2); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .sec-row.sec-open     { background: rgba(255,59,48,0.12); }
[data-theme="dark"] .sec-row.sec-closed   { background: rgba(52,199,89,0.10); }
[data-theme="dark"] .sec-row.sec-armed    { background: rgba(255,179,71,0.12); }
[data-theme="dark"] .sec-row.sec-disarmed { background: rgba(79,110,247,0.15); }
[data-theme="dark"] .alarm-card.sec-armed { background: rgba(255,179,71,0.12); }

/* ── Auto-dim overlay ──────────────────────────────────────── */
html { transition: filter 2s ease; }
html.dimmed { filter: brightness(0.04); cursor: none; }

/* ── Messages Page ─────────────────────────────────────────── */
.msg-compose {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.msg-author-select { max-width: 260px; }
.msg-textarea { resize: none; min-height: 70px; line-height: 1.5; font-size: 15px; }
.msg-send-btn { align-self: flex-end; padding: 10px 28px; }

.msg-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.msg-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

.msg-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-avatar { font-size: 20px; line-height: 1; }
.msg-author { font-weight: 700; font-size: 14px; flex: 1; }
.msg-time { font-size: 12px; color: var(--text3); }
.msg-delete {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: transparent;
  color: var(--text3);
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.msg-delete:hover { background: rgba(255,59,48,0.1); color: var(--accent); }
.msg-body { font-size: 15px; line-height: 1.5; color: var(--text); word-break: break-word; }

/* ── Dashboard Message Preview Pill ───────────────────────── */
.cam-dragging { opacity: 0.4; }
.cam-drag-over { outline: 2px dashed var(--primary); outline-offset: 2px; }

.dash-cam-strip {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.dash-cam-card {
  position: relative;
  width: 180px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  aspect-ratio: 16/9;
  display: block;
  flex-shrink: 0;
}
.dash-cam-card:hover { opacity: 0.88; }
.dash-cam-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dash-cam-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 3px 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.msg-preview-pill {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.msg-preview-pill:hover { box-shadow: var(--shadow-lg); }
.msg-preview-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}
.msg-compose-btn {
  flex-shrink: 0;
  padding: 0 16px;
  height: 100%;
  min-height: 42px;
  border-left: 1px solid var(--border);
  font-size: 18px;
  color: var(--primary);
  background: transparent;
  transition: background 0.15s;
}
.msg-compose-btn:hover { background: var(--primary-light); }
.msg-preview-icon { font-size: 18px; flex-shrink: 0; }
.msg-preview-from { font-weight: 700; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
.msg-preview-divider { color: var(--text3); flex-shrink: 0; }
.msg-preview-text { font-size: 13px; color: var(--text2); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-preview-more { font-size: 12px; color: var(--primary); font-weight: 700; white-space: nowrap; flex-shrink: 0; margin-left: auto; }

/* Event Detail Modal */
.event-detail-modal { max-width: 420px; width: 90%; padding: 0; overflow: hidden; }
.event-detail-color-bar { height: 6px; width: 100%; border-radius: 0; }
.event-detail-title { font-size: 17px; font-weight: 800; color: var(--text1); line-height: 1.3; margin: 0; }
.event-detail-time { font-size: 13px; color: var(--text2); margin-top: 6px; font-weight: 600; }
.event-detail-desc { font-size: 13px; color: var(--text2); margin-top: 8px; line-height: 1.5; }
.event-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.event-detail-tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }

/* Ring live camera modal */
#cameraLiveFrame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto !important;
  min-height: 0;
  border: 0;
  background: #000;
}

#cameraModal .camera-modal-content {
  width: min(92vw, 1200px);
  max-height: 92vh;
}

#cameraModal .camera-modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

#cameraModalImg {
  max-width: 100%;
  max-height: 75vh;
}

/* ============================================================
   Hayes Family Hub — Wall Calendar / Touchscreen Layout
   ============================================================ */

/* Use the available screen instead of leaving the lower half empty */
.calendar-wrapper {
  height: calc(100vh - 190px);
  min-height: 600px;
  display: flex;
}

/* Header row + however many week rows the current month needs */
#calendarGrid.calendar-grid {
  flex: 1;
  height: 100%;
  min-height: 0;
  grid-template-rows: 46px;
  grid-auto-rows: 1fr;
}

/* Bigger weekday labels */
#calendarGrid .cal-day-header {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Make every date cell a substantial touch target */
#calendarGrid .cal-day {
  min-height: 0;
  padding: 10px 11px;
  overflow: hidden;
  cursor: pointer;
}

/* Larger date numbers */
#calendarGrid .cal-date {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 7px;
}

/* Today's number */
#calendarGrid .cal-day.today .cal-date span {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
}

/* Event stack */
#calendarGrid .cal-events {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Existing "dot" events are really event bars — make them usable by touch */
#calendarGrid .cal-event-dot {
  min-height: 30px;
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
  line-height: 18px;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

/* Bigger month navigation */
.calendar-nav {
  min-height: 58px;
  gap: 12px;
}

.calendar-month-title {
  font-size: 25px;
  font-weight: 850;
}

#prevMonth,
#nextMonth {
  width: 48px;
  height: 48px;
  font-size: 27px;
}

#todayBtn {
  min-height: 44px;
  padding-left: 18px;
  padding-right: 18px;
  font-size: 14px;
  font-weight: 800;
}

/* Header controls should be finger-sized too */
#syncBtn,
#addEventBtn {
  min-height: 44px;
  padding: 10px 17px;
  font-size: 14px;
}

/* Larger day detail panel when a day is tapped */
#dayEventsPanel {
  font-size: 15px;
}

#dayEventsPanel .event-card {
  padding: 14px 16px;
}

#dayEventsPanel .event-card-title {
  font-size: 16px;
}

#dayEventsPanel .event-card-time {
  font-size: 14px;
}

/* Larger popup buttons */
.event-detail-modal .btn {
  min-height: 42px;
  padding-left: 16px;
  padding-right: 16px;
}

/* Keep it usable on smaller browser windows too */
@media (max-height: 760px) {
  .calendar-wrapper {
    height: calc(100vh - 165px);
    min-height: 480px;
  }

  #calendarGrid .cal-day {
    padding: 6px 8px;
  }

  #calendarGrid .cal-event-dot {
    min-height: 25px;
    padding: 4px 7px;
    font-size: 12px;
  }
}

