/* ========================================
   🐾 Ollie — Puppy Logbook Styles
   ======================================== */

:root {
  --gold-light: #F5E6D3;
  --gold: #D4A574;
  --gold-dark: #C4956A;
  --gold-darker: #A67B5B;
  --cream: #FFF9F2;
  --cream-dark: #F0E6DA;
  --text: #3D2C1E;
  --text-light: #6B5A4E;
  --text-muted: #8A7B6E;
  --green: #4CAF50;
  --green-light: #E8F5E9;
  --green-bg: #C8E6C9;
  --red: #E57373;
  --red-light: #FFEBEE;
  --red-bg: #FFCDD2;
  --blue: #64B5F6;
  --blue-light: #E3F2FD;
  --orange: #FFB74D;
  --orange-light: #FFF3E0;
  --purple: #BA68C8;
  --purple-light: #F3E5F5;
  --teal: #4DB6AC;
  --teal-light: #E0F2F1;
  --shadow-sm: 0 1px 3px rgba(61, 44, 30, 0.08);
  --shadow-md: 0 4px 12px rgba(61, 44, 30, 0.1);
  --shadow-lg: 0 8px 24px rgba(61, 44, 30, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-height: 72px;
  --header-height: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Skip Link (Accessibility) ---- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--gold-dark);
  color: white;
  padding: 8px 16px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 10000;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* ---- Focus Styles (Accessibility) ---- */
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* ---- Header ---- */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: white;
  padding: 0 20px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(164, 123, 91, 0.3);
}

.header-content {
  flex-shrink: 0;
}

.header-content h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.puppy-age {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 1px;
  font-weight: 500;
}

.header-summary {
  flex: 1;
  text-align: right;
  font-size: 15px;
  letter-spacing: 1px;
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.refresh-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.refresh-btn:active {
  transform: scale(0.9);
  background: rgba(255,255,255,0.35);
}

.refresh-btn.spinning {
  animation: spin 0.8s ease;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- Loading Skeleton ---- */
.loading-skeleton {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loading-skeleton.hidden {
  display: none;
}

.skeleton-bar {
  height: 48px;
  background: linear-gradient(90deg, var(--cream-dark) 25%, var(--gold-light) 50%, var(--cream-dark) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-card {
  height: 80px;
  background: linear-gradient(90deg, var(--cream-dark) 25%, var(--gold-light) 50%, var(--cream-dark) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-card-short {
  height: 56px;
  width: 75%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Main Content ---- */
#main-content {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100dvh - var(--header-height));
}

#main-content.hidden {
  display: none;
}

.view {
  display: none;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

.view.active {
  display: block;
}

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

/* ---- Date Selector ---- */
.date-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 16px;
  position: relative;
}

.date-nav {
  background: white;
  border: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 26px;
  color: var(--gold-darker);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.date-nav:active {
  transform: scale(0.92);
  box-shadow: var(--shadow-md);
}

.date-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.date-display {
  text-align: center;
  min-width: 180px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.date-display:hover,
.date-display:active {
  background: rgba(212, 165, 116, 0.12);
}

.date-display .date-main {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.date-display .date-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

.date-picker-hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* ---- Potty Banner ---- */
.potty-banner {
  background: white;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
}

.potty-banner.hidden {
  display: none;
}

.potty-banner .potty-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.potty-banner .potty-text {
  flex: 1;
  line-height: 1.4;
}

.potty-banner .potty-streak {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  display: block;
  margin-top: 2px;
}

.potty-banner .potty-score {
  font-size: 24px;
  font-weight: 800;
  flex-shrink: 0;
}

.potty-banner.good {
  border-left: 4px solid var(--green);
}

.potty-banner.good .potty-score {
  color: var(--green);
}

.potty-banner.warn {
  border-left: 4px solid var(--orange);
}

.potty-banner.warn .potty-score {
  color: var(--orange);
}

/* ---- Timeline ---- */
.timeline {
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--cream-dark);
  border-radius: 1px;
}

/* Dynamic timeline line: set by JS to span first dot to last dot */
.timeline.has-events::before {
  top: var(--timeline-top, 14px);
  bottom: var(--timeline-bottom, 14px);
}

.timeline-event {
  position: relative;
  padding: 0 0 20px 28px;
  animation: slideIn 0.3s ease;
  animation-fill-mode: backwards;
}

.timeline-event:last-child {
  padding-bottom: 0;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.timeline-event .timeline-dot {
  position: absolute;
  left: -8px;
  top: 14px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--gold);
  z-index: 2;
}

.timeline-event.type-plassen-buiten .timeline-dot,
.timeline-event.type-poepen-buiten .timeline-dot {
  border-color: var(--green);
  background: var(--green-light);
}

.timeline-event.type-plassen-binnen .timeline-dot,
.timeline-event.type-poepen-binnen .timeline-dot {
  border-color: var(--red);
  background: var(--red-light);
}

.timeline-event.type-eten .timeline-dot,
.timeline-event.type-drinken .timeline-dot {
  border-color: var(--orange);
  background: var(--orange-light);
}

.timeline-event.type-slapen .timeline-dot,
.timeline-event.type-ontwaken .timeline-dot {
  border-color: var(--blue);
  background: var(--blue-light);
}

.timeline-event.type-training .timeline-dot {
  border-color: var(--purple);
  background: var(--purple-light);
}

.timeline-event.type-uitlaten .timeline-dot,
.timeline-event.type-tuin .timeline-dot {
  border-color: var(--teal);
  background: var(--teal-light);
}

.timeline-event.type-milestone .timeline-dot {
  border-color: #FFD700;
  background: #FFF9C4;
}

.timeline-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.timeline-card:active {
  box-shadow: var(--shadow-md);
}

.timeline-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.event-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
}

.event-emoji {
  font-size: 20px;
  flex-shrink: 0;
}

.event-type {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
}

.event-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: auto;
}

.badge-buiten {
  background: var(--green-bg);
  color: #2E7D32;
}

.badge-binnen {
  background: var(--red-bg);
  color: #C62828;
}

.event-note {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.45;
  margin-left: 52px;
}

.event-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 52px;
  margin-top: 2px;
}

/* Indoor accident highlight */
.timeline-event.type-plassen-binnen .timeline-card,
.timeline-event.type-poepen-binnen .timeline-card {
  border-left: 3px solid var(--red);
  background: var(--red-light);
}

.timeline-event.type-milestone .timeline-card {
  border-left: 3px solid #FFD700;
  background: #FFFDE7;
}

/* ---- Stats ---- */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.section-subtitle {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-light);
  margin: 16px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.stat-card.stat-potty {
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
}

.stat-card.stat-streak {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
}

.stat-emoji {
  font-size: 28px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.stat-detail {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 6px;
}

.stat-potty .stat-value { color: var(--green); }
.stat-streak .stat-value { color: var(--orange); }

/* All-time stats */
.stats-alltime {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.alltime-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 10px;
}

.alltime-emoji {
  font-size: 20px;
  flex-shrink: 0;
}

.alltime-info {
  flex: 1;
}

.alltime-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.alltime-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.encouragement-card {
  background: linear-gradient(135deg, var(--gold-light) 0%, white 100%);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

.encouragement-card .enc-emoji {
  font-size: 36px;
  display: block;
  margin-bottom: 8px;
}

.encouragement-card .enc-text {
  font-weight: 600;
}

.encouragement-card .enc-sub {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 6px;
}

/* ---- Week View ---- */
.week-grid-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px 12px;
}

.week-grid {
  display: table;
  width: 100%;
  min-width: 340px;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.week-grid thead th {
  background: var(--gold-light);
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-darker);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: center;
  position: sticky;
  top: 0;
}

.week-grid thead th:first-child {
  text-align: left;
  padding-left: 14px;
  min-width: 80px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--gold-light);
}

.week-grid thead th.today {
  background: var(--gold);
  color: white;
}

.week-grid tbody td {
  padding: 10px 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  border-top: 1px solid var(--cream-dark);
}

.week-grid tbody td:first-child {
  text-align: left;
  padding-left: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  position: sticky;
  left: 0;
  background: white;
  z-index: 1;
}

.week-grid tbody td.today {
  background: #FFF9F0;
}

.week-grid .count-green { color: var(--green); }
.week-grid .count-red { color: var(--red); }
.week-grid .count-orange { color: var(--orange); }
.week-grid .count-blue { color: var(--blue); }
.week-grid .count-purple { color: var(--purple); }
.week-grid .count-teal { color: var(--teal); }

.week-grid .count-zero {
  color: var(--text-muted);
  font-weight: 400;
}

.potty-trend {
  margin-top: 16px;
}

.trend-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.trend-bars {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 120px;
  padding: 0 8px;
}

.trend-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.trend-bar {
  width: 100%;
  max-width: 40px;
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  transition: height 0.4s ease;
  position: relative;
}

.trend-bar.good {
  background: linear-gradient(180deg, var(--green) 0%, #81C784 100%);
}

.trend-bar.warn {
  background: linear-gradient(180deg, var(--orange) 0%, #FFD54F 100%);
}

.trend-bar.empty {
  background: var(--cream-dark);
  min-height: 4px;
}

.trend-bar-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 600;
}

.trend-bar-value {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* ---- Training View ---- */
.training-summary {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.training-tag {
  background: var(--purple-light);
  color: #7B1FA2;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.training-tag .tag-count {
  background: #CE93D8;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.training-entry {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--purple);
}

.training-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.training-exercise {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
}

.training-date {
  font-size: 12px;
  color: var(--text-muted);
}

.training-result {
  font-size: 14px;
  color: var(--purple);
  font-weight: 600;
}

.training-note {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.training-duration {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Empty States ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-emoji {
  font-size: 56px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.empty-state p {
  font-size: 15px;
  font-weight: 500;
}

.empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 400;
}

.empty-hint {
  text-align: left;
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.6;
}

.empty-hint p {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-hint ul {
  list-style: none;
  padding: 0;
}

.empty-hint li {
  padding: 4px 0;
}

.empty-hint li::before {
  content: '• ';
  color: var(--purple);
  font-weight: bold;
}

/* ---- Bottom Nav ---- */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: white;
  display: flex;
  box-shadow: 0 -2px 12px rgba(61, 44, 30, 0.08);
  z-index: 100;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  padding: 8px 4px;
}

.nav-tab.active {
  color: var(--gold-dark);
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.nav-tab.active .nav-label {
  color: var(--gold-dark);
}

.nav-tab:active {
  transform: scale(0.93);
}

/* ---- Loading dots ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  margin: 0 4px;
  animation: bounce 1.2s infinite ease-in-out;
}

.loading-dot:nth-child(2) { animation-delay: 0.1s; }
.loading-dot:nth-child(3) { animation-delay: 0.2s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- Timeline Photo/Video ---- */
.event-photo {
  margin-top: 8px;
  margin-left: 52px;
}

.event-photo img,
.event-photo video {
  max-width: 200px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(164, 123, 91, 0.25);
  border: 2px solid var(--gold-light);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: block;
}

.event-photo video {
  cursor: default;
}

.event-photo img:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-md);
}

/* ---- Gallery ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--gold-light);
  transition: transform 0.15s, box-shadow 0.15s;
}

.gallery-item:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-md);
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item .gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  padding: 24px 10px 8px;
  text-align: center;
}

.gallery-item .gallery-date {
  font-size: 11px;
  font-weight: 600;
}

.gallery-item .gallery-caption {
  font-size: 10px;
  opacity: 0.85;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item .gallery-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  pointer-events: none;
}

/* ---- Lightbox ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: #000000dd;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lightboxIn 0.2s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

@keyframes lightboxIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-close:active {
  background: rgba(255,255,255,0.4);
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

.lightbox-prev:active,
.lightbox-next:active {
  background: rgba(255,255,255,0.35);
}

.lightbox-prev:disabled,
.lightbox-next:disabled {
  opacity: 0.2;
  cursor: default;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lightbox-img,
.lightbox-video {
  max-width: 90vw;
  max-height: 75vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  object-fit: contain;
  animation: lightboxZoom 0.25s ease;
}

@keyframes lightboxZoom {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.lightbox-caption {
  color: white;
  font-size: 14px;
  text-align: center;
  max-width: 80vw;
  line-height: 1.4;
  opacity: 0.9;
}

.lightbox-caption:empty {
  display: none;
}

/* ---- Pull to Refresh indicator ---- */
.pull-indicator {
  position: fixed;
  top: var(--header-height);
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  background: var(--gold);
  color: white;
  padding: 8px 16px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  z-index: 99;
  transition: transform 0.2s;
  pointer-events: none;
}

.pull-indicator.visible {
  transform: translateX(-50%) translateY(0);
}

/* ---- Home / Dashboard ---- */
.home-hero {
  text-align: center;
  padding: 8px 0 16px;
}

.home-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.home-subtitle {
  font-size: 14px;
  color: var(--text-light);
  font-weight: 500;
  margin-top: 2px;
}

/* Polaroid Stack */
.polaroid-stack {
  position: relative;
  height: 260px;
  margin: 8px auto 24px;
  max-width: 280px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  perspective: 600px;
}

.polaroid-stack:active {
  transform: scale(0.98);
}

.polaroid {
  position: absolute;
  top: 0;
  left: 50%;
  margin-left: -90px;
  width: 180px;
  background: white;
  padding: 8px 8px 28px 8px;
  border-radius: 2px;
  box-shadow: 0 3px 12px rgba(61, 44, 30, 0.18), 0 1px 3px rgba(61, 44, 30, 0.12);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.polaroid-stack:hover .polaroid:nth-child(1) {
  transform: rotate(-6deg) translate(-12px, -4px) !important;
}

.polaroid-stack:hover .polaroid:nth-child(2) {
  transform: rotate(5deg) translate(16px, 0px) !important;
}

.polaroid img,
.polaroid video {
  width: 100%;
  height: 164px;
  object-fit: cover;
  display: block;
  border-radius: 1px;
  background: var(--cream-dark);
}

.polaroid-media {
  position: relative;
}

.polaroid-media video {
  width: 100%;
  height: 164px;
  object-fit: cover;
  display: block;
}

.polaroid-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  pointer-events: none;
}

.polaroid-caption {
  font-family: 'Caveat', 'Comic Sans MS', cursive, sans-serif;
  font-size: 13px;
  color: var(--text-light);
  text-align: center;
  margin-top: 6px;
  line-height: 1.2;
  max-height: 18px;
  overflow: hidden;
}

.polaroid-hint {
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-darker);
  opacity: 0.8;
}

.polaroid-empty {
  text-align: center;
  padding: 60px 20px;
  font-size: 36px;
  color: var(--text-muted);
}

.polaroid-empty span {
  font-size: 14px;
  display: block;
  margin-top: 8px;
}

/* Home Quick Stats */
.home-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.home-stat {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.home-stat:active {
  transform: scale(0.95);
  box-shadow: var(--shadow-md);
}

.home-stat-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}

.home-stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 4px;
}

/* Home Section Titles */
.home-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* Milestone Cards */
.milestone-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 3px solid #FFD700;
}

.milestone-emoji {
  font-size: 24px;
  flex-shrink: 0;
}

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

.milestone-note {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.milestone-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.milestone-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

/* Home Today Summary */
.home-today {
  margin-top: 20px;
}

.home-today-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.home-today-item {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.home-today-emoji {
  font-size: 16px;
}

.home-latest {
  font-size: 13px;
  color: var(--text-light);
  padding: 10px 14px;
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-latest-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.home-view-day-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  margin-top: 4px;
}

.home-view-day-btn:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

/* Home Milestone section */
#home-milestone {
  margin-bottom: 8px;
}

/* ---- Desktop ---- */
@media (min-width: 600px) {
  #main-content {
    max-width: 560px;
    margin: 0 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-alltime {
    grid-template-columns: repeat(3, 1fr);
  }

  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }

  .event-photo img,
  .event-photo video {
    max-width: 300px;
  }

  .lightbox-prev,
  .lightbox-next {
    width: 56px;
    height: 56px;
    font-size: 32px;
  }

  .lightbox-prev { left: 24px; }
  .lightbox-next { right: 24px; }
}

@media (min-width: 768px) {
  :root {
    --header-height: 80px;
  }

  #app-header {
    padding: 0 32px;
  }

  .header-content h1 {
    font-size: 26px;
  }

  .view {
    padding: 24px;
  }

  #main-content {
    max-width: 640px;
  }

  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Small screens: hide lightbox nav arrows, rely on swipe */
@media (max-width: 480px) {
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }

  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
}

/* Stats redesign */
.stats-subtitle { text-align: center; color: var(--text-muted); margin: -8px 0 16px; font-size: 0.9rem; }
.stats-hero { text-align: center; background: var(--card-bg); border-radius: 16px; padding: 24px 20px; margin-bottom: 16px; box-shadow: var(--card-shadow); }
.stats-hero-pct { font-size: 3.5rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stats-hero-label { color: var(--text-muted); font-size: 0.9rem; margin: 4px 0 12px; }
.stats-progress-bar { height: 12px; background: var(--bg-secondary, #f0e6da); border-radius: 6px; overflow: hidden; margin: 0 20px; }
.stats-progress-fill { height: 100%; border-radius: 6px; transition: width 0.6s ease; }
.stats-hero-detail { color: var(--text-muted); font-size: 0.8rem; margin-top: 10px; }

.stats-row { display: flex; gap: 12px; margin-bottom: 16px; }
.stats-row-card { flex: 1; background: var(--card-bg); border-radius: 12px; padding: 16px; text-align: center; box-shadow: var(--card-shadow); }
.stats-row-emoji { font-size: 1.5rem; }
.stats-row-value { font-size: 1.8rem; font-weight: 700; color: var(--text-primary); }
.stats-row-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.stats-section-title { font-size: 1rem; font-weight: 600; margin: 20px 0 10px; color: var(--text-primary); }

.stats-grid-3 { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.stats-mini-card { flex: 1 1 30%; min-width: 90px; background: var(--card-bg); border-radius: 10px; padding: 12px 8px; text-align: center; box-shadow: var(--card-shadow); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stats-mini-emoji { font-size: 1.3rem; }
.stats-mini-value { font-size: 1.3rem; font-weight: 700; }
.stats-mini-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }

.stats-day-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.stats-day-row { background: var(--card-bg); border-radius: 12px; padding: 14px 16px; box-shadow: var(--card-shadow); cursor: pointer; transition: transform 0.15s; }
.stats-day-row:active { transform: scale(0.97); }
.stats-day-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.stats-day-date { font-weight: 700; font-size: 1rem; }
.stats-day-datestr { color: var(--text-muted); font-size: 0.8rem; flex: 1; }
.stats-day-pct { font-weight: 700; font-size: 1.1rem; }
.stats-day-bar { height: 6px; background: var(--bg-secondary, #f0e6da); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.stats-day-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.stats-day-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.day-chip { font-size: 0.75rem; padding: 3px 8px; border-radius: 12px; background: var(--bg-secondary, #f0e6da); color: var(--text-muted); white-space: nowrap; }
.day-chip.chip-good { background: #e8f5e9; color: #2e7d32; }
.day-chip.chip-miss { background: #fce4ec; color: #c62828; }

/* Line chart */
.trend-chart { background: var(--card-bg); border-radius: 12px; padding: 12px 8px; box-shadow: var(--card-shadow); }
.trend-line-svg { width: 100%; height: auto; display: block; }
.trend-axis-label { font-size: 10px; fill: var(--text-muted); font-family: inherit; }
.trend-dot-label { font-size: 11px; fill: var(--text-primary); font-weight: 600; font-family: inherit; }
