:root {
  --bg: #0b1420;
  --surface: #131f2d;
  --surface-2: #1b2b3c;
  --cell-away: #1c2f43;
  --cell-home: #0d1622;
  --line: rgba(255,255,255,0.08);
  --line-2: rgba(255,255,255,0.16);
  --text: #eef4f8;
  --text-2: #9fb3c2;
  --text-3: #6f8597;
  --accent: #4aa8e0;
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 520px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); -webkit-font-smoothing: antialiased; }
#app { max-width: var(--maxw); margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  background: linear-gradient(180deg, #0c1622 0%, rgba(11,20,32,0.92) 100%);
  border-bottom: 0.5px solid var(--line); backdrop-filter: blur(8px);
}
.eyebrow { margin: 0; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.app-header h1 { margin: 3px 0 0; font-size: 20px; font-weight: 600; }
.hstat { text-align: right; }
.hstat span { font-size: 22px; font-weight: 600; }
.hstat small { display: block; font-size: 11px; color: var(--text-3); }

main { flex: 1; padding: 16px 14px calc(92px + var(--safe-bottom)); }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 2px 16px; }
.legend span { font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.lg-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Calendar */
.month { margin-bottom: 22px; }
.month h2 { font-size: 16px; font-weight: 600; margin: 0 2px 10px; }
.dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.dow span { text-align: center; font-size: 10.5px; color: var(--text-3); padding: 2px 0; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cell { aspect-ratio: 1 / 1.12; border-radius: 8px; background: var(--cell-away); border: 0.5px solid var(--line); padding: 4px 3px 3px; display: flex; flex-direction: column; overflow: hidden; }
.cell.home { background: var(--cell-home); }
.cell.miss-church { border: 1px solid #d8202a; }
.cell.empty { background: transparent; border: none; }
.cell .num { font-size: 11px; color: var(--text-3); line-height: 1; }
.cell.today { border: 3px solid #000; }
.cell.today .num { color: var(--accent); font-weight: 700; }
.cell .chip { margin-top: auto; border-radius: 5px; font-size: 10px; font-weight: 700; color: #fff; text-align: center; padding: 3px 1px; letter-spacing: 0.02em; cursor: pointer; }
.cell .chip.tentative { background: transparent !important; border: 1px dashed currentColor; }
.cell .chip.powder { border: 1px dashed rgba(255,255,255,0.7); }
.cell .mk { margin-top: auto; font-size: 9px; color: var(--text-3); text-align: center; padding: 3px 0; border-radius: 5px; background: var(--surface-2); }

/* Trips */
.trip { background: var(--surface); border: 0.5px solid var(--line); border-radius: var(--radius); padding: 15px 16px; margin-bottom: 14px; border-left: 4px solid var(--accent); }
.trip .trip-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.trip .trip-head .htext { min-width: 0; }
.trip .trip-flag { flex: 0 0 auto; height: 46px; width: auto; max-width: 86px; object-fit: contain; border-radius: 3px; border: 0.5px solid var(--line-2); box-shadow: 0 1px 3px rgba(0,0,0,0.25); background: #fff; }
.trip h3 { margin: 0 0 3px; font-size: 16px; font-weight: 600; }
.trip .dates { font-size: 12.5px; color: var(--text-3); margin: 0 0 10px; }
.trip .row { font-size: 13px; color: var(--text-2); line-height: 1.55; margin: 4px 0; }
.trip .row b { color: var(--text); font-weight: 600; }
.trip .resorts { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 4px; }
.badge { font-size: 11px; font-weight: 700; color: #fff; padding: 3px 8px; border-radius: 999px; }
.pill { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.pill.tentative { background: rgba(224,160,32,0.18); color: #efb23a; }
.pill.planned { background: rgba(29,158,117,0.18); color: #5dcaa5; }
.pill.likely { background: rgba(74,168,224,0.16); color: #7ac0e8; }
.linkbtn { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 9px 13px; background: var(--surface-2); border: 0.5px solid var(--line-2); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; text-decoration: none; }
.mini-toggle { flex-shrink: 0; font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px; border: 0.5px solid var(--line-2); background: var(--surface-2); color: var(--text-2); cursor: pointer; }
.mini-toggle:hover { color: var(--text); border-color: var(--accent); }
.mini-toggle:active { transform: scale(0.96); }
.mini-toggle[aria-pressed="true"] { background: rgba(74,168,224,0.16); color: var(--accent); border-color: transparent; }

/* Tab bar */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--maxw); display: flex; background: rgba(12,22,34,0.96); backdrop-filter: blur(10px); border-top: 0.5px solid var(--line); padding-bottom: var(--safe-bottom); z-index: 20; }
.tabbar button { flex: 1; border: none; background: none; color: var(--text-3); padding: 12px 0; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.tabbar button.active { color: var(--accent); }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-inner { background: var(--surface); width: 100%; max-width: var(--maxw); margin: 0 auto; border-radius: 16px 16px 0 0; padding: 18px 18px calc(24px + var(--safe-bottom)); border-top: 0.5px solid var(--line-2); }
.sheet-inner .sh-date { font-size: 12.5px; color: var(--text-3); }
.sheet-inner h3 { margin: 4px 0 2px; font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.sheet-inner .sh-note { font-size: 14px; color: var(--text-2); line-height: 1.6; margin: 10px 0 0; }
.sheet-inner .sh-meta { font-size: 13px; color: var(--text-3); margin: 8px 0 0; }
.sq { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }

:root[data-theme="light"] { --bg:#f3f6f9; --surface:#fff; --surface-2:#eceff3; --line:rgba(0,0,0,0.08); --line-2:rgba(0,0,0,0.16); --text:#11222f; --text-2:#4a6070; --text-3:#7c93a2; --accent:#1f74b0; --cell-away:#ffffff; --cell-home:#dde3e9; }
:root[data-theme="light"] .app-header { background: linear-gradient(180deg,#fff 0%, rgba(243,246,249,0.92) 100%); }
:root[data-theme="light"] .tabbar { background: rgba(255,255,255,0.96); }

/* --- light/dark toggle --- */
/* Header is space-between; let the title column shrink so the toggle
   can't ride on top of a long, wrapping trip name. */
.app-header { gap: 12px; }
.app-header > div:first-child { flex: 1 1 auto; min-width: 0; }
.h-right { display: flex; align-items: center; gap: 10px; flex: none; }
.theme-toggle {
  flex: none; width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
  cursor: pointer; transition: color .15s, border-color .15s;
  -webkit-appearance: none; appearance: none;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 17px; height: 17px; display: block; }

/* --- Canes tickets + conflict flagging (Life Calendar) --- */
.chip-canes { background:#cc0000; color:#fff; font-size:9px; font-weight:700; border-radius:4px; padding:1px 3px; margin-top:2px; text-align:center; letter-spacing:.02em; }
/* CONFLICT: deliberately loud — this is an action item, not decoration. */
.cell.canes-conflict { border:2px solid #ff8c00; background:rgba(255,140,0,0.22); outline:2px solid rgba(255,140,0,0.45); outline-offset:-4px; }
.cell.canes-conflict .num { color:#ffb454; font-weight:700; }
.chip-swap { background:#ff8c00; color:#2a1400; font-size:8.5px; font-weight:800; border-radius:4px; padding:1px 2px; margin-top:2px; text-align:center; letter-spacing:.01em; }

.conflict-banner {
  background:rgba(255,140,0,0.16); border:1.5px solid #ff8c00; border-radius:var(--radius-sm);
  padding:11px 14px; margin:0 2px 14px; font-size:14px; font-weight:700; color:#ffb454; cursor:pointer;
}
.conflict-banner span { display:block; font-weight:400; font-size:12.5px; color:var(--text-2); margin-top:3px; }

.tk-row { display:flex; gap:12px; align-items:flex-start; background:var(--surface); border:0.5px solid var(--line);
  border-left:3px solid var(--line-2); border-radius:var(--radius-sm); padding:10px 13px; margin-bottom:8px; }
.tk-row.conflict { border-left-color:#ff8c00; background:rgba(255,140,0,0.10); }
.tk-row.pick { border-left-color:#1d9e75; }
.tk-row.pending { border-left-color:var(--accent); }
.tk-when { font-size:12.5px; font-weight:700; color:var(--text-2); min-width:74px; }
.tk-row.conflict .tk-when { color:#ffb454; }
.tk-main { flex:1; font-size:13.5px; }
.tk-main b { font-weight:600; }
.tk-main span { display:block; font-size:12.5px; color:var(--text-3); margin-top:2px; line-height:1.45; }

/* detail-sheet conflict alert */
.sh-alert { background:rgba(255,140,0,0.16); border:1.5px solid #ff8c00; border-radius:var(--radius-sm); padding:12px 14px; font-size:14px; color:#ffb454; font-weight:700; line-height:1.5; margin-bottom:10px; }
.sh-alert b { display:block; color:var(--text); font-size:15px; margin-top:4px; }
.sh-alert span { display:block; font-weight:400; font-size:12.5px; color:var(--text-2); margin-top:3px; }
