:root {
  --bg: #f4efe7;
  --bg-2: #efe7dd;
  --surface: rgba(255,255,255,0.88);
  --surface-2: #fffdf9;
  --text: #2a241f;
  --text-dim: #7d7168;
  --border: rgba(74, 56, 45, 0.08);
  --shadow-sm: 0 2px 8px rgba(82, 59, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(82, 59, 40, 0.08);
  --shadow-lg: 0 18px 50px rgba(82, 59, 40, 0.10);
  --accent: #c77f4c;
  --accent-light: rgba(199,127,76,0.12);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;

  /* Person colors */
  --c-oscar: #dddaf0;
  --c-oscar-text: #514a7a;
  --c-ingeline: #efd2d7;
  --c-ingeline-text: #8f5563;
  --c-hedda: #d7e7ef;
  --c-hedda-text: #44697c;
  --c-thea: #d8eadf;
  --c-thea-text: #44654f;
  --c-family: #ece1d3;
  --c-family-text: #7b6048;

  /* Chore/schedule/free */
  --tag-schedule: #e8edf4;
  --tag-chore: #fef0e0;
  --tag-chore-text: #8b5e1a;
  --tag-free: #e8f5ec;
  --tag-done: #f0eeeb;
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }

/* App shell */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 12px 88px;
  min-height: 100dvh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
}
.header-nav {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease;
}
.header-nav:active { transform: scale(0.95); }
.header-center { text-align: center; }
.header-label { font-size: 13px; color: var(--text-dim); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.header-dates { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }

/* Week section */
.week-section { margin-bottom: 4px; }
.week-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.legend-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid transparent;
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  font-size: 14px;
}
.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.75);
}
.legend-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-section { }
.day-strip {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

/* Google Calendar style week view */
.wcal-scroll {
  overflow-y: auto;
  max-height: calc(100dvh - 210px);
  border: 1px solid rgba(74, 56, 45, 0.16);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.wcal {}
.wcal-header {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.wcal-corner {
  padding: 8px;
  border-right: 1px solid rgba(74, 56, 45, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wcal-axis-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.wcal-day-header {
  text-align: center;
  padding: 10px 4px;
  border-right: 2px solid rgba(74, 56, 45, 0.12);
  background: rgba(255,255,255,0.7);
}
.wcal-day-header:last-child { border-right: none; }
.wcal-day-header.wcal-today {
  background: var(--accent-light);
}
.wcal-day-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wcal-day-num {
  display: block;
  font-size: 20px;
  font-weight: 800;
  margin-top: 2px;
}
.wcal-today .wcal-day-num { color: var(--accent); }

.wcal-body {
  position: relative;
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
}
.wcal-day-column {
  position: absolute;
  z-index: 0;
  border-right: 2px solid rgba(74, 56, 45, 0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.34), rgba(255,255,255,0.18));
}
.wcal-day-column-today {
  background: linear-gradient(180deg, rgba(199,127,76,0.12), rgba(199,127,76,0.04));
}
.wcal-hour-label {
  position: absolute;
  left: 0;
  width: 52px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-align: right;
  padding-right: 8px;
  transform: translateY(-7px);
  z-index: 2;
}
.wcal-hour-line {
  position: absolute;
  left: 52px;
  right: 0;
  height: 1px;
  background: rgba(74, 56, 45, 0.12);
  z-index: 1;
}
.wcal-now-line {
  position: absolute;
  left: 48px;
  right: 0;
  height: 2px;
  background: #e05555;
  z-index: 5;
}
.wcal-now-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e05555;
}

.wcal-event {
  position: absolute;
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 11px;
  overflow: hidden;
  cursor: pointer;
  z-index: 3;
  transition: opacity 0.12s ease, filter 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.wcal-event:hover { filter: brightness(0.95); z-index: 6; }
.wcal-event.wcal-done { opacity: 0.35; text-decoration: line-through; }
.wcal-event.wcal-chore { cursor: pointer; }
.wcal-event-person {
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}
.wcal-event-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  line-height: 1.2;
}
.wcal-event-time {
  font-size: 10px;
  opacity: 0.8;
}
.wcal-event-pts {
  font-size: 10px;
  font-weight: 800;
}

/* Week strip (kept for day view) */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}
.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  min-height: 72px;
}
.day-cell:active { transform: scale(0.96); }
.day-cell:hover { background: rgba(255,255,255,0.5); }
.day-cell.today { background: var(--accent-light); }
.day-cell.selected {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border-bottom: 3px solid var(--accent);
}
.day-name { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.day-number { font-size: 18px; font-weight: 800; }
.day-dots { display: flex; gap: 3px; min-height: 8px; }
.day-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.day-dot.schedule { background: #7b9cc0; }
.day-dot.chore { background: #d4944c; }
.day-dot.free { background: #6ea87a; }

/* Day detail */
.day-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 12px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.2s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Person tabs */
.person-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.person-tabs::-webkit-scrollbar { display: none; }
.person-tab {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  transition: all 0.15s ease;
  position: relative;
}
.person-tab.active {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.person-tab .tab-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d4944c;
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.time-block {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease;
  min-height: 52px;
}
.time-block:hover { background: rgba(0,0,0,0.02); }
.time-block:active { background: rgba(0,0,0,0.04); }
.time-block.completed { opacity: 0.5; }
.time-block.completed .block-title { text-decoration: line-through; }

.block-time {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.block-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.block-title { font-size: 15px; font-weight: 600; }
.block-chore-icon { font-size: 14px; }
.block-points {
  font-size: 12px;
  font-weight: 800;
  color: var(--tag-chore-text);
  background: var(--tag-chore);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.block-check {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.block-check.done {
  background: #e8f5ec;
  border-color: #6ea87a;
  color: #3d7a4a;
}

/* Add block button */
.add-block-btn {
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 14px;
  background: transparent;
  transition: all 0.15s ease;
}
.add-block-btn:hover { background: rgba(0,0,0,0.02); border-color: var(--accent); color: var(--text); }

/* Month overlay */
.month-overlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 239, 231, 0.97);
  backdrop-filter: blur(12px);
  z-index: 35;
  padding: 16px 16px 72px;
  overflow-y: auto;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.month-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.month-header h2 { font-size: 20px; font-weight: 800; }
.close-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.month-day-header {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 0;
}
.month-cell {
  min-height: 64px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(255,255,255,0.5);
}
.month-cell:hover { background: rgba(255,255,255,0.8); }
.month-cell.empty { background: transparent; cursor: default; min-height: 0; }
.month-cell.today { background: var(--accent-light); border-color: var(--accent); }
.month-cell.selected { border-color: var(--accent); box-shadow: var(--shadow-sm); background: white; }
.month-number { font-size: 13px; font-weight: 800; padding: 1px 4px; }
.month-events { display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.month-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.month-pill.person-oscar { background: var(--c-oscar); color: var(--c-oscar-text); }
.month-pill.person-ingeline { background: var(--c-ingeline); color: var(--c-ingeline-text); }
.month-pill.person-hedda { background: var(--c-hedda); color: var(--c-hedda-text); }
.month-pill.person-thea { background: var(--c-thea); color: var(--c-thea-text); }
.month-pill.person-family { background: var(--c-family); color: var(--c-family-text); }
.month-more { font-size: 10px; color: var(--text-dim); padding: 0 4px; }

/* Month day detail (person lanes inside month view) */
.month-day-detail {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.2s ease-out;
}
.month-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.month-detail-header h3 { font-size: 18px; font-weight: 800; margin: 0; }
.month-person-lanes { display: flex; flex-direction: column; gap: 12px; }
.month-person-lane {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.month-person-header {
  padding: 8px 12px;
  font-weight: 800;
  font-size: 13px;
}
.month-lane-block {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.month-lane-block.chore-block { background: rgba(254,240,224,0.4); }
.month-lane-time { font-weight: 800; color: var(--text-dim); font-size: 12px; width: 44px; flex-shrink: 0; }

/* Rewards panel */
.rewards-panel {
  position: fixed;
  bottom: 52px;
  left: 0;
  right: 0;
  background: var(--surface-2);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 12px 20px 24px;
  box-shadow: 0 -8px 40px rgba(82, 59, 40, 0.12);
  z-index: 45;
  max-height: calc(70dvh - 24px);
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.rewards-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 12px;
}
.rewards-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.rewards-header h2 { font-size: 20px; font-weight: 800; }
.rewards-balances {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.rewards-balances::-webkit-scrollbar { display: none; }
.balance-chip {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 100px;
  text-align: center;
}
.balance-name { font-size: 12px; font-weight: 600; opacity: 0.8; }
.balance-pts { font-size: 20px; font-weight: 900; margin-top: 2px; }
/* Rewards stats */
.rewards-stats { margin-bottom: 16px; }
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-item {
  text-align: center;
  padding: 12px 8px;
  background: rgba(255,255,255,0.7);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.stat-number { font-size: 24px; font-weight: 900; color: var(--accent); }
.stat-label { font-size: 11px; color: var(--text-dim); font-weight: 600; margin-top: 2px; }

.rewards-list { display: flex; flex-direction: column; gap: 10px; }
.reward-card {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid var(--border);
  gap: 12px;
  transition: opacity 0.15s ease;
}
.reward-card.redeemed { opacity: 0.5; }
.reward-icon { font-size: 24px; flex-shrink: 0; }
.reward-info { flex: 1; }
.reward-title { font-weight: 700; font-size: 15px; }
.reward-cost { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.reward-btn {
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff6e3;
  border: 1px solid rgba(199,127,76,0.2);
  font-weight: 800;
  font-size: 13px;
  color: var(--tag-chore-text);
  transition: all 0.12s ease;
}
.reward-btn:active { transform: scale(0.96); }
.reward-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.reward-btn.redeemed { background: #e8f5ec; color: #3d7a4a; border-color: #6ea87a; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: rgba(255,253,249,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 4px 6px calc(env(safe-area-inset-bottom, 0px) + 4px);
  z-index: 60;
  gap: 2px;
}
.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  padding: 6px 2px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
  transition: color 0.12s ease;
}
.nav-tab.active { color: var(--accent); }
.nav-icon { font-size: 18px; line-height: 1; }
.nav-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Silo view (ALLA) */
.person-silos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.silo-column {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255,255,255,0.5);
}
.silo-header {
  padding: 8px 6px;
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.02em;
}
.silo-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px;
  min-height: 120px;
}
.silo-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 6px;
  font-size: 12px;
  transition: opacity 0.12s ease;
}
.silo-block.completed { opacity: 0.4; text-decoration: line-through; }
.silo-block.chore-block { background: rgba(254,240,224,0.5); }
.silo-block-time { font-weight: 800; color: var(--text-dim); font-size: 11px; }
.silo-block-title { font-weight: 600; font-size: 12px; }

/* Faded peek days */
.day-cell.faded {
  opacity: 0.4;
}
.day-cell.faded:hover { opacity: 0.6; }

/* Month silo grid (ALLA in month day detail) */
.month-silo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.month-filter-tabs {
  margin-bottom: 12px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-dim);
}
.empty-state p { font-size: 14px; margin-bottom: 12px; }

/* Utility */
.hidden { display: none !important; }

/* Desktop: wider layout */
@media (min-width: 768px) {
  .app { max-width: 720px; padding: 24px 24px 88px; }
  .day-cell { padding: 12px 8px 10px; }
  .day-number { font-size: 20px; }
}

/* Mobile: stack silos */
@media (max-width: 640px) {
  .person-silos { grid-template-columns: repeat(2, 1fr); }
  .week-strip { grid-template-columns: repeat(9, 1fr); overflow-x: auto; scrollbar-width: none; }
  .week-strip::-webkit-scrollbar { display: none; }
  .week-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legend-chip { padding: 8px 10px; font-size: 13px; }
}

/* Wall/kiosk: large screen */
@media (min-width: 1200px) {
  .app { max-width: 1100px; }
  .week-strip { gap: 10px; }
  .day-cell { min-height: 88px; }
  .day-number { font-size: 24px; }
  .header-dates { font-size: 26px; }
}
