:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #e9edf1;
  --text: #1a2129;
  --text-dim: #647385;
  --accent: #17b085;
  --accent-dark: #0f8f6b;
  --accent-soft: rgba(23, 176, 133, 0.14);
  --danger: #d64550;
  --border: #dfe4ea;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app { height: 100%; }

/* App shell: fixed viewport height, panes scroll internally. Document scroll +
   sticky topbar got the bar pinned under the Android status bar (clipped tabs). */
.view {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* display:flex would otherwise override the hidden attribute */
.view[hidden] { display: none; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
#view-login {
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 360px;
  margin: auto; /* centers, and unlike flex centering doesn't clip when taller than the viewport */
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.logo {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.logo span { color: var(--accent); }
.logo-small { font-size: 1.2rem; }

.tagline {
  color: var(--text-dim);
  margin: 0 0 8px;
  line-height: 1.5;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
}
.btn-primary { background: var(--accent); color: #06281d; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost {
  background: none;
  color: var(--text-dim);
  padding: 8px 10px;
  min-height: 0;
  font-size: 0.85rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--surface-2);
}

.guest-form { display: flex; flex-direction: column; gap: 10px; }

input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px;
  font-size: 1rem;
  min-height: 48px;
}
input[type="text"]:focus { outline: 2px solid var(--accent); border-color: transparent; }

.note { color: var(--text-dim); font-size: 0.8rem; min-height: 1em; }

/* ---------- App bar (brand + today, on every view) ---------- */
.app-bar {
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 14px 0;
  padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--surface);
}
.app-bar .logo, .topbar .logo {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.app-bar .logo { font-size: 1.05rem; }
.app-date {
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.app-date:disabled { cursor: default; opacity: 1; } /* guests: plain date display */
.app-bar-right { display: flex; align-items: center; gap: 12px; }
.avatar-chip {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.account-menu {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 48px);
  right: 10px;
  z-index: 60;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(20, 30, 40, 0.18);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 200px;
}
.account-name-row { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.account-name-row .user-name { color: var(--text); font-size: 0.95rem; }
.account-menu .btn { min-height: 0; padding: 10px 14px; font-size: 0.9rem; }
.account-menu #btn-edit-name { padding: 6px 8px; font-size: 0.9rem; }
.edit-name-form { display: flex; gap: 8px; }
.edit-name-form input { flex: 1; min-width: 0; padding: 10px 12px; min-height: 0; font-size: 0.95rem; }
.edit-name-form .btn { min-height: 0; padding: 10px 14px; font-size: 0.9rem; }
/* a topbar sitting under an app-bar must not re-add the safe-area inset */
.app-bar + .topbar { padding-top: 6px; }

/* ---------- Topbar ---------- */
.topbar {
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-name { color: var(--text-dim); font-size: 0.9rem; }

.main-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Home ---------- */
.room-list { display: flex; flex-direction: column; gap: 10px; }
.room-item {
  background: var(--surface);
  border: none;
  color: var(--text);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.room-item .mode-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mode-sheet { display: flex; flex-direction: column; gap: 8px; }
.mode-option {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mode-option span { color: var(--text-dim); font-size: 0.82rem; }
.mode-option:active { border-color: var(--accent); }

/* ---------- Delete plan (home rows + in-room strip) ---------- */
.room-row { display: flex; align-items: stretch; gap: 8px; }
.room-row .room-item { flex: 1; min-width: 0; }
.room-del { font-size: 1rem; padding: 8px 12px; }
.room-del-q {
  flex: 1;
  align-self: center;
  min-width: 0;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-del { font-size: 1rem; }
.del-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
  font-size: 0.85rem;
}
.del-confirm span { flex: 1; min-width: 0; }
.del-confirm .btn { min-height: 0; padding: 8px 14px; font-size: 0.85rem; }

/* ---------- Room ---------- */
.members-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
  font-size: 0.8rem;
}
.member-chip {
  display: inline-block;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px 10px;
  margin-right: 6px;
  color: var(--text-dim);
}
.member-chip .cal { color: var(--accent); }
.room-title {
  flex: 1;
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-bar { display: flex; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.tab {
  border: none;
  background: none;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); }

.chat-pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px 90px;
}
.messages { display: flex; flex-direction: column; gap: 10px; max-width: 680px; margin: 0 auto; }

.msg { max-width: 86%; border-radius: var(--radius); padding: 10px 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; unicode-bidi: plaintext; }
.msg-mine { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 4px; }
.msg-agent { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 4px; }
.msg-other { align-self: flex-start; background: var(--surface); border-left: 3px solid var(--uc, var(--text-dim)); border-bottom-left-radius: 4px; }
.msg .author { font-size: 0.72rem; color: var(--text-dim); margin-bottom: 2px; font-weight: 600; }
.msg-other .author { color: var(--uc, var(--text-dim)); }
.msg-cont { margin-top: -4px; }
.msg-system { align-self: center; max-width: 92%; text-align: center; font-size: 0.78rem; color: var(--text-dim); background: var(--surface-2); border-radius: 12px; padding: 5px 12px; white-space: pre-wrap; unicode-bidi: plaintext; }
.msg-pending { opacity: 0.55; }

.proposals { display: flex; flex-direction: column; gap: 6px; align-self: stretch; }
.proposal-card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.proposal-card .pc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.proposal-card .slot-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.proposal-card .slot-when { font-weight: 700; font-size: 0.88rem; white-space: nowrap; }
.proposal-card .slot-title {
  color: var(--text-dim);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proposal-card .btn-confirm {
  flex-shrink: 0;
  padding: 7px 14px;
  min-height: 34px;
  font-size: 0.85rem;
}
.confirmed-banner {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* ---------- Input bar ---------- */
.input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
  z-index: 10;
}
.input-bar form { display: flex; gap: 8px; max-width: 680px; margin: 0 auto; }
.input-bar input { flex: 1; min-width: 0; }
.btn-send { min-width: 52px; padding: 0; }

/* ---------- Week grid ---------- */
.week-pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 8px 90px;
}
.week-grid {
  display: grid;
  /* minmax(0,1fr): a 44px column floor overflowed the pane on 360px-wide phones
     (34+7*44+14 gaps+16 pane padding = 372px) causing a slight sideways pan */
  grid-template-columns: 34px repeat(7, minmax(0, 1fr));
  gap: 2px;
  max-width: 680px;
  margin: 0 auto;
}
.wg-corner { }
/* The container splits into a sticky head grid + body grid (paintWeek) — a
   sticky grid ITEM can only stick within its own row, so the head must be a
   sibling grid, not a grid row. Both inherit .week-grid's column template. */
.week-grid.week-wrap { display: block; }
.week-wrap .wg-headgrid {
  position: sticky;
  /* -10px = .week-pane's padding-top: sticky pins at the pane's CONTENT edge,
     which would leave a 10px strip of scrolling events peeking above the
     header — pull it up flush with the pane's border edge instead. */
  top: -10px;
  z-index: 6; /* above stacked event blocks (lane z-index reaches ~4) */
  background: var(--bg);
  padding-bottom: 2px;
}
.wg-dayhead {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
  padding: 4px 0;
  background: var(--bg);
}
.wg-dayhead.today { color: var(--accent); font-weight: 700; }
.wg-hours { position: relative; }
.wg-hourlabel {
  position: absolute;
  right: 4px;
  font-size: 0.62rem;
  color: var(--text-dim);
  transform: translateY(-50%);
}
.wg-daycol {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.wg-block {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 5px;
  font-size: 0.6rem;
  overflow: hidden;
  padding: 2px 4px;
  line-height: 1.2;
  box-shadow: 0 0 0 1px var(--bg); /* hairline gap so adjacent events separate */
}
.wg-blocktime { display: block; font-size: 0.55rem; opacity: 0.7; font-weight: 600; }
.wg-busy { background: #ccd4dd; color: #5a6774; }
.wg-prop { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); }
.wg-conf { background: var(--accent); color: #06281d; font-weight: 700; }
/* Times view marks: mine = bold accent outline; others = tinted with their
   member color (set inline via applyBlockColor). */
.wg-mark { font-weight: 700; }
.wg-mark-mine {
  background: #fff8e1;
  border: 2px solid #e6a700;
  color: #8a6400;
}
.wg-mark-other {
  background: var(--surface);
  border: 1px dashed var(--text-dim);
  color: var(--text-dim);
}
.wg-hourline { position: absolute; left: 0; right: 0; height: 1px; background: rgba(0,0,0,0.05); }

.legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 0.75rem;
}
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.sw-busy { background: #ccd4dd; }
.sw-prop { background: var(--accent-soft); border: 1px solid var(--accent); }
.sw-conf { background: var(--accent); }
.sw-mark-mine { background: #fff8e1; border: 2px solid #e6a700; }
.sw-mark-other { background: var(--surface); border: 1px dashed var(--text-dim); }

/* ---------- room Times bar ---------- */
.times-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 680px;
  margin: 0 auto 4px;
}
.times-sub .tab { padding: 4px 10px; font-size: 0.8rem; }
.times-layers {
  border-top: none;
  background: none;
  padding: 0 0 6px;
  max-width: 680px;
  margin: 0 auto;
}
.times-hint {
  max-width: 680px;
  margin: 0 auto 6px;
  font-size: 0.72rem;
  text-align: center;
}

/* ---------- chat week dock (pinned above the composer) ---------- */
.chat-week-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(66px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.07);
  z-index: 9;
  display: flex;
  flex-direction: column;
}
.dock-grip {
  /* Generous touch target; touch-action none ONLY here so dragging resizes
     without scrolling — taps elsewhere stay untouched. */
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ns-resize;
  touch-action: none;
}
.dock-grip span {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.dock-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 2px;
}
.dock-label {
  flex: 1;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}
.dock-x { margin-left: 2px; }
#chat-week-toggle.on { color: var(--accent); border-color: var(--accent); }
.dock-wrap {
  overflow-y: auto;
  overscroll-behavior: contain; /* dock scroll must not chain into chat scroll */
  padding: 0 8px 8px;
}

.privacy-note {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.4;
}
.avail-chip {
  margin-left: auto;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.avail-chip.all { background: var(--accent-soft); color: var(--accent); }
.confirmed-banner a { color: var(--accent); }

.week-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-bottom: 6px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.week-nav .btn { font-size: 1.2rem; padding: 4px 14px; }
.tz-note { padding: 4px 12px; margin: 0; background: var(--surface); }

.confirmed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 0;
}
.btn-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 34px;
  min-height: 30px;
}
.btn-remove:active { color: var(--danger); }

/* ---------- calendar picker ---------- */
.cal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cal-card-head { display: flex; align-items: center; justify-content: space-between; }
.cal-title { font-weight: 600; }
.cal-status { color: var(--text-dim); font-size: 0.8rem; }
.cal-list { display: flex; flex-direction: column; gap: 2px; }
.cal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  cursor: pointer;
  border-radius: 8px;
}
.cal-row:active { background: var(--surface-2); }
.cal-row input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cal-name { font-size: 0.95rem; }
#btn-cal-toggle { align-self: flex-start; padding: 4px 0; }

/* ---------- my-calendar view ---------- */
.cal-actions { display: flex; gap: 14px; align-items: center; }
#btn-view-cal { align-self: flex-start; padding: 4px 0; color: var(--accent); }
.week-nav-inline { flex: 1; justify-content: flex-end; }
.wg-cal {
  background: var(--accent-soft);
  color: var(--text);
  border-left: 3px solid var(--accent);
  font-weight: 500;
}
.wg-allday {
  min-height: 22px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 1px;
  background: var(--bg);
}
.wg-allday-chip {
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 4px;
  font-size: 0.58rem;
  padding: 1px 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- week overlap-mode switcher + badge ---------- */
.overlap-seg {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.seg-label { margin-right: 2px; }
.seg-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.seg-chip.active { background: var(--surface-2); color: var(--text); border-color: var(--text-dim); }
/* extra per-calendar bar on deduped multi-calendar events */
.wg-dupbar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
}
.pop-copies {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.pop-copies .seg-chip { display: inline-flex; align-items: center; gap: 5px; }
.pop-copies .seg-chip.active { border-color: var(--accent); color: var(--text); }

.wg-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--text-dim);
  color: #fff;
  border-radius: 8px;
  padding: 1px 5px;
  font-size: 0.58rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 3;
}

/* ---------- day peek bottom sheet (week view) ---------- */
.wg-peek {
  display: block;
  margin: 2px auto 0;
  width: 30px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}
.wg-peek:active { color: var(--accent); border-color: var(--accent); }

#day-sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 32, 0.35);
  z-index: 24;
}
#day-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50vh; /* default; drag handle adjusts via style.height */
  min-height: 80px;
  max-height: 92vh;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
  z-index: 25;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 6px 16px;
  cursor: grab;
  touch-action: none; /* head drags resize the sheet; don't let the page scroll */
  flex-shrink: 0;
}
.sheet-grip {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.sheet-title { flex: 1; font-weight: 700; font-size: 0.95rem; }
.sheet-close {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 1rem;
  padding: 8px 14px;
  cursor: pointer;
}
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 16px;
}
/* Event details card must open above the sheet */
#event-pop { z-index: 30; }

/* ---------- my-calendar day view + nav ---------- */
.mycal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
}
.mycal-label { font-weight: 600; color: var(--text); font-size: 0.95rem; flex: 1; text-align: center; }
.mycal-today { color: var(--accent); font-weight: 600; }
.mycal-nav .btn { font-size: 1.15rem; padding: 4px 14px; }

.week-grid.day-grid { grid-template-columns: 44px 1fr; }
.wg-dayblock { font-size: 0.78rem; padding: 4px 6px; }
.wg-dayblock .wg-blocktime { font-size: 0.66rem; }
.wg-dayhead.tappable { cursor: pointer; }
.wg-dayhead.tappable:active { color: var(--accent); }

/* ---------- month view ---------- */
.week-grid.month-grid {
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.mg-wd {
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-dim);
  padding: 4px 0 2px;
  position: sticky;
  top: 0;
  background: var(--bg);
}
.mg-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 86px;
  padding: 2px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mg-cell:active { border-color: var(--accent); }
.mg-out { opacity: 0.45; }
.mg-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}
.mg-today { border-color: var(--accent); }
.mg-today .mg-num {
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  margin: 0 auto;
  line-height: 20px;
}
.mg-chip {
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  color: var(--text);
  border-radius: 3px;
  font-size: 0.55rem;
  line-height: 1.35;
  padding: 1px 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.mg-more { font-size: 0.58rem; color: var(--text-dim); text-align: center; }

/* ---------- my-calendar command box ---------- */
.cmd-preview {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  max-width: 656px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  padding: 12px 14px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cmd-reply { font-size: 0.9rem; }
.cmd-detail { font-size: 0.9rem; line-height: 1.5; color: var(--text); }
.cmd-badge {
  display: inline-block;
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 4px;
  color: #fff;
}
.cmd-add { background: var(--accent); }
.cmd-edit { background: #e2a63d; }
.cmd-del { background: var(--danger); }
.cmd-actions { display: flex; justify-content: flex-end; gap: 8px; }
.cmd-confirm { min-height: 40px; padding: 8px 22px; font-size: 0.9rem; }
.cmd-err { color: var(--danger); font-size: 0.8rem; }

/* ---------- calendar legend + event popup ---------- */
.mycal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.legend-chip { display: inline-flex; align-items: center; gap: 5px; }
.event-pop .pop-title { font-weight: 700; font-size: 1rem; }
.event-pop .pop-line { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--text); }
.wg-block { cursor: pointer; }

/* ---------- home restructure: sections, settings strip, plan sheet ---------- */
.section-label {
  margin: 4px 0 -4px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.section-label-dim { margin-top: 14px; opacity: 0.8; }

.empty-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  color: var(--text-dim);
  line-height: 1.55;
}
.empty-card .empty-emoji { font-size: 2rem; margin-bottom: 6px; }
.empty-card p { margin: 4px 0; }
.empty-card strong { color: var(--text); }

.settings-strip { display: flex; gap: 8px; }
.settings-chip {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 56px;
}
.settings-chip .chip-sub { font-size: 0.72rem; font-weight: 500; color: var(--text-dim); }
.settings-chip.open { border-color: var(--accent); }

#plan-sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 24, 0.45);
  z-index: 24;
}
#plan-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  max-height: 88dvh;
  overflow-y: auto;
}
.plan-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 16px 8px;
}
.plan-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ---------- proposal legend + preferred chips ---------- */
.prop-legend {
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 0 4px;
}
.pref-chip {
  background: #fdf3d7;
  border: 1px solid #ecd699;
  color: #7a5c00;
  border-radius: 8px;
  padding: 1px 7px;
  font-size: 0.72rem;
}

/* Coordinate confirm guard: shown when the organizer confirms before everyone answered */
.confirm-warn { color: #b45309; font-size: 0.78rem; margin-top: 4px; }

/* ---------- my ranked options ---------- */
.my-options {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.my-options-head { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 4px; }
.my-option-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.opt-when { flex: 1; font-size: 0.88rem; min-width: 0; }
/* priority stepper: −  N  + */
.opt-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.opt-step {
  border: none;
  background: var(--surface);
  color: var(--accent-dark);
  width: 34px;
  height: 34px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
}
.opt-step:active { background: var(--accent-soft); }
.opt-step:disabled { color: var(--border); cursor: default; }
.opt-weight {
  min-width: 26px;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}
.opt-del { font-size: 1rem; padding: 6px 8px; }
.btn-approve {
  background: var(--surface);
  color: var(--accent-dark);
  border: 1px solid var(--accent);
  font-size: 0.85rem;
  padding: 8px 12px;
  min-height: 40px;
  white-space: nowrap;
}
.btn-approve.on { background: var(--accent-soft); font-weight: 700; }
.prop-heading { font-size: 0.82rem; font-weight: 700; color: var(--text); margin: 2px 2px 4px; }
.pc-actions { display: flex; flex-direction: column; gap: 6px; }
.btn-pick {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  padding: 8px 12px;
  min-height: 40px;
  white-space: nowrap;
}
.btn-pick.on { background: var(--accent); color: #06281d; border-color: var(--accent); font-weight: 700; }
.btn-force { font-size: 0.75rem; align-self: center; }
.pick-chip {
  display: inline-block;
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--accent-dark);
  margin-top: 2px;
  align-self: flex-start;
}
.pick-prompt {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.45;
  margin-bottom: 8px;
}
/* ---------- Voice dictation (mic) ---------- */
.btn-mic {
  min-width: 48px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-mic svg { width: 22px; height: 22px; }
.btn-mic.recording {
  color: var(--danger);
  border-color: var(--danger);
  animation: mic-pulse 1s ease-in-out infinite;
}
.btn-mic.transcribing {
  color: #c99700;
  border-color: #c99700;
  animation: mic-pulse 0.6s ease-in-out infinite;
}
.btn-mic.denied { color: var(--danger); }
.btn-mic-cancel {
  color: var(--text-dim);
  font-size: 1.05rem;
  font-weight: 600;
  min-width: 42px;
}
.btn-mic-cancel:active { color: var(--danger); border-color: var(--danger); }
/* week-start picker reuses the seg chips, minus the toolbar chrome */
.week-start-seg { border-top: none; background: none; padding: 4px 0 2px; }

/* availability chip: members whose answer we don't have yet */
.avail-unk { opacity: 0.65; font-weight: 600; margin-left: 1px; }
@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
