/* HenryLabs Calendar — house CSS-var theming (dark default, light override) */

:root {
  --bg: #121418;
  --bg-raised: #1b1f26;
  --bg-modal: #20252e;
  --border: #2d3440;
  --text: #ffffff;
  --text-dim: #6b7482;        /* grey spillover date numbers */
  --text-muted: #9aa4b2;
  --accent: #4f8ef7;
  --danger: #e5534b;
  --pill-bg: #262c36;
  --pill-text: #e8ecf2;
  --cell-line: #242a33;
  --today-ring: #4f8ef7;
  --overlay: rgba(0,0,0,.55);
  --sel-ring: #ffd166;
}
:root[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-raised: #ffffff;
  --bg-modal: #ffffff;
  --border: #d9dee6;
  --text: #15181d;
  --text-dim: #a8b0bc;
  --text-muted: #5b6572;
  --pill-bg: #e9edf3;
  --pill-text: #20242b;
  --cell-line: #e3e7ee;
  --overlay: rgba(20,24,30,.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
button { font: inherit; cursor: pointer; }

/* ---------- login ---------- */
#login-view { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; }
.login-card h1 { font-size: 20px; margin: 0 0 14px; }
.login-card label { display: block; margin: 10px 0 4px; color: var(--text-muted); font-size: 12px; }
.login-card input { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px; }
.login-card .btn { width: 100%; margin-top: 12px; }
.form-msg { min-height: 18px; font-size: 13px; color: var(--danger); margin: 8px 0 0; }
.invite-banner { background: color-mix(in srgb, var(--accent) 18%, transparent); border: 1px solid var(--accent);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--border); background: var(--pill-bg); color: var(--pill-text);
  border-radius: 10px; padding: 9px 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.pill { border: 1px solid var(--border); background: var(--pill-bg); color: var(--pill-text);
  border-radius: 999px; padding: 9px 18px; font-weight: 600; }
.pill.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--pill-bg); color: var(--pill-text); }

/* ---------- main layout ---------- */
#app-view { display: flex; flex-direction: column; height: 100dvh; }
#topbar { padding: 10px 16px 6px; text-align: center; }
#topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
#weekday-bar { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 2px;
  color: var(--text-muted); font-size: 11px; text-align: center; border-bottom: 1px solid var(--cell-line); }
#weekday-bar div { padding: 2px 0 4px; }
#scroller { flex: 1; overflow-y: auto; position: relative; }
#canvas { position: relative; }
#bottombar { display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.footer-spacer { flex: 1; }

/* ---------- week rows & cells ---------- */
.week-row { position: absolute; left: 0; right: 0; display: grid; grid-template-columns: repeat(7, 1fr); }
.day-cell { border-right: 1px solid var(--cell-line); border-bottom: 1px solid var(--cell-line);
  position: relative; overflow: hidden; }
.day-cell:last-child { border-right: none; }
.day-num { font-size: 11px; line-height: 1; padding: 4px 0 0 5px; color: var(--text-dim); user-select: none;
  position: relative; z-index: 3; pointer-events: none; display: inline-block; }
.day-num.cur { color: var(--text); }
.day-num.today { background: var(--accent); color: #fff !important; border-radius: 9px;
  padding: 3px 6px; margin: 2px 0 0 3px; }

/* event pills are positioned over the row, not inside cells */
.ev-pill { position: absolute; z-index: 2; border-radius: 5px; font-size: 11px; line-height: 1;
  color: #fff; padding: 3px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; border: 1px solid rgba(0,0,0,.25); }
:root[data-theme="light"] .ev-pill { border-color: rgba(255,255,255,.35); }
.ev-pill.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.ev-pill.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ev-pill.selected { box-shadow: 0 0 0 2px var(--sel-ring); filter: brightness(1.15); }
.ev-pill.more { background: var(--pill-bg); color: var(--text-muted); text-align: center; border-style: dashed; }

/* ---------- modals ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: flex;
  align-items: center; justify-content: center; padding: 14px; z-index: 50; }
.modal { background: var(--bg-modal); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 480px; max-height: calc(100dvh - 40px); display: flex; flex-direction: column; }
.modal.wide { max-width: 680px; }
.modal-head { padding: 14px 18px 8px; font-size: 17px; font-weight: 700; }
.modal-body { padding: 4px 18px 10px; overflow-y: auto; }
.modal-foot { padding: 10px 18px 16px; display: flex; gap: 8px; justify-content: flex-end; }
.modal label { display: block; margin: 10px 0 4px; color: var(--text-muted); font-size: 12px; }
.modal input[type=text], .modal input[type=email], .modal input[type=date], .modal input[type=time],
.modal input[type=number], .modal textarea, .modal select {
  width: 100%; padding: 9px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px; color-scheme: dark; }
:root[data-theme="light"] .modal input, :root[data-theme="light"] .modal textarea,
:root[data-theme="light"] .modal select { color-scheme: light; }
.modal textarea { min-height: 70px; resize: vertical; }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; }

/* toggle chips (one-time / recurring, calendar picks) */
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; margin: 3px 4px 3px 0; background: var(--pill-bg);
  color: var(--pill-text); font-size: 13px; user-select: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }

/* calendar manager table */
.cal-table { width: 100%; border-collapse: collapse; }
.cal-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cal-name { font-weight: 600; }
.cal-shared { color: var(--text-muted); font-size: 12px; word-break: break-word; }
.toggle-circle { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--accent);
  background: transparent; display: inline-block; cursor: pointer; }
.toggle-circle.on { background: var(--accent); }
.linklike { background: none; border: none; color: var(--accent); padding: 4px; font-size: 13px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.on { border-color: var(--text); }
.member-row { display: flex; align-items: center; justify-content: space-between; padding: 5px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px; }
.badge { font-size: 11px; color: var(--text-muted); }

/* day zoom */
.zoom-list { display: flex; flex-direction: column; gap: 6px; }
.zoom-pill { border-radius: 8px; color: #fff; padding: 10px 10px; cursor: pointer;
  border: 1px solid rgba(0,0,0,.25); }
.zoom-pill.selected { box-shadow: 0 0 0 2px var(--sel-ring); }
.zoom-sub { font-size: 11px; opacity: .85; }

/* invites section */
.invite-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.invite-row .grow { flex: 1; }

@media (max-width: 480px) {
  .pill { padding: 8px 13px; font-size: 13px; }
  #topbar h1 { font-size: 17px; }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
