:root {
  --bg: #faf3e6;
  --paper: #fffdf8;
  --ink: #2b2a28;
  --muted: #7c7566;
  --border: #2b2a28;
  --coral: #ff6b6b;
  --coral-2: #ff8787;
  --teal: #2fb6a8;
  --yellow: #ffc857;
  --purple: #9b8cf2;
  --green: #4fb06a;
  --green-soft: #e4f5e4;
  --danger: #e8594f;
  --shadow-offset: 5px;
  --blob: 32px 12px 28px 14px / 14px 28px 12px 32px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(43, 42, 40, 0.08) 1px, transparent 0);
  background-size: 22px 22px;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Comfortable tap targets on touch devices */
@media (hover: none) and (pointer: coarse) {
  .btn, .slot-avatar, .slot-add-circle, .pm-btn, .pm-add-btn, .day-cell-compact { touch-action: manipulation; }
}

h1, h2, .brand, .period-label {
  font-family: "Kalam", cursive;
}

/* ---------- Hand-drawn scribble decorations ---------- */
.scribble {
  position: absolute;
  opacity: 0.9;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Auth screens ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-wrap.has-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px 24px 40px;
}
.auth-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.55;
}
.auth-blob-1 {
  width: 280px;
  height: 280px;
  top: -80px;
  left: -60px;
  background: var(--coral-2);
}
.auth-blob-2 {
  width: 240px;
  height: 240px;
  right: -50px;
  top: 18%;
  background: var(--yellow);
}
.auth-blob-3 {
  width: 300px;
  height: 300px;
  bottom: -100px;
  left: 20%;
  background: var(--teal);
  opacity: 0.4;
}
.auth-hero {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  text-align: center;
}
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-family: "Kalam", cursive;
  font-size: 34px;
  color: var(--ink);
}
.auth-brand svg {
  width: 36px;
  height: 36px;
  color: var(--coral);
  flex-shrink: 0;
}
.auth-tagline {
  margin: 0 auto;
  max-width: 440px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--muted);
}
.auth-steps {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.auth-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px 12px;
  background: rgba(255, 253, 248, 0.82);
  border: 2px solid var(--border);
  border-radius: 18px 8px 16px 10px / 10px 16px 8px 18px;
  box-shadow: 3px 3px 0 rgba(43, 42, 40, 0.12);
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}
.auth-step:nth-child(1) { transform: rotate(-1deg); }
.auth-step:nth-child(2) { transform: rotate(0.4deg); margin-top: 4px; }
.auth-step:nth-child(3) { transform: rotate(0.8deg); }
.auth-step strong {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
}
.auth-step-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--border);
  color: var(--coral);
  box-shadow: 2px 2px 0 rgba(43, 42, 40, 0.1);
}
.auth-step-icon svg { width: 18px; height: 18px; }
.auth-step:nth-child(2) .auth-step-icon { color: var(--teal); }
.auth-step:nth-child(3) .auth-step-icon { color: var(--purple); }
.auth-wrap.has-intro .card {
  transform: rotate(0.5deg);
  max-width: 420px;
}
.card {
  position: relative;
  background: var(--paper);
  border: 2.5px solid var(--border);
  border-radius: var(--blob);
  padding: 40px 34px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--ink);
  transform: rotate(-0.6deg);
  z-index: 1;
}
.logo { width: 56px; height: 56px; margin: 0 auto 10px; color: var(--coral); }
.logo svg { width: 100%; height: 100%; }
.card h1 {
  margin: 6px 0 6px; font-size: 30px; font-weight: 400;
  position: relative; display: inline-block;
}
.auth-card { padding: 36px 30px 32px; }
.auth-card .auth-title {
  margin: 0 0 4px;
  font-size: 34px;
  display: block;
}
.auth-card .auth-title::after { display: none; }
.auth-kicker {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--coral);
}
.auth-label {
  display: block;
  margin: 18px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
  text-align: left;
}
.auth-back {
  display: inline-block;
  margin-top: 20px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.auth-back:hover { color: var(--coral); text-decoration: underline; }
.auth-hint {
  margin: -4px 0 0;
  font-size: 13px;
  color: var(--coral);
}
.auth-notice {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  background: #fff8e8;
  border: 1.5px solid var(--yellow);
  color: var(--ink);
}
.pin-input {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.35em;
  padding: 14px 16px;
}
.card h1::after {
  content: "";
  display: block;
  width: 100%;
  height: 10px;
  margin-top: -2px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 16'><path d='M2 8 Q 20 0, 38 8 T 74 8 T 110 8 T 146 8 T 182 8' fill='none' stroke='%23ff6b6b' stroke-width='4' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.muted { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }

input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="number"] {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 2.5px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 3px 3px 0 rgba(43, 42, 40, 0.15);
}
input::placeholder { color: #b3ac9c; }
input:focus { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--coral); border-color: var(--coral); }

.btn {
  cursor: pointer;
  border: 2.5px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 14px;
  font-size: 14.5px;
  font-weight: 700;
  font-family: "Nunito", sans-serif;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--coral); border-color: var(--ink); color: #fff2ee; }
.btn.primary:hover { background: var(--coral-2); }
.btn.danger { background: #fff; border-color: var(--danger); color: var(--danger); box-shadow: 3px 3px 0 var(--danger); }
.btn.danger:hover { background: #fff0ee; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: rgba(43, 42, 40, 0.06); transform: none; box-shadow: none; }
.btn.sm { padding: 7px 12px; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); }
.btn.icon { padding: 7px 13px; font-size: 16px; line-height: 1; }

.link-sm { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px; text-decoration: underline wavy var(--coral); text-decoration-thickness: 1px; }
.link-sm:hover { color: var(--coral); }
.error {
  background: #fff0ee; color: var(--danger);
  border: 2px dashed var(--danger);
  padding: 10px 12px; border-radius: 12px; font-size: 13px; margin-top: 14px;
}
.code-display {
  margin: 4px 0 0;
  width: 100%;
  padding: 18px 16px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.2em;
  font-family: "Nunito", monospace, sans-serif;
  background: var(--yellow);
  border: 2.5px solid var(--border);
  border-radius: 16px;
  box-shadow: 3px 3px 0 var(--ink);
  display: block;
}
.code-hint { margin-top: 6px; font-size: 13px; }
.code-pill {
  font-family: "Nunito", monospace, sans-serif;
  letter-spacing: 0.08em;
}
.member-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.member-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.meta-item strong { color: var(--ink); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 2.5px solid var(--border);
  background: var(--paper);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 400; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.brand svg { width: 26px; height: 26px; color: var(--coral); flex-shrink: 0; align-self: flex-start; margin-top: 2px; }
.brand-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  line-height: 1.1;
}
.brand-name {
  font-family: "Kalam", cursive;
  font-size: 24px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand-context {
  font-family: "Nunito", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.brand-copy .tag { margin-top: 2px; }
.tag {
  font-size: 11px; background: var(--yellow); color: var(--ink);
  padding: 3px 10px; border-radius: 999px; font-weight: 700;
  border: 1.5px solid var(--ink); font-family: "Nunito", sans-serif;
}
.tag.soft { background: var(--paper); color: var(--muted); }
.topbar nav { display: flex; gap: 8px; }

@keyframes nav-pulse {
  0%, 100% {
    background: rgba(255, 107, 107, 0.14);
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.45);
  }
  50% {
    background: rgba(255, 107, 107, 0.28);
    box-shadow: 0 0 0 8px rgba(255, 107, 107, 0);
  }
}

.btn.nav-pulse {
  border-color: var(--coral);
  color: var(--coral);
  font-weight: 800;
  animation: nav-pulse 1.6s ease-in-out infinite;
}
.btn.nav-pulse:hover {
  background: rgba(255, 107, 107, 0.22);
  animation: nav-pulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .btn.nav-pulse { animation: none; }
}

/* ---------- Containers / panels ---------- */
.container { max-width: 1040px; margin: 0 auto; padding: 26px; }
.panel {
  background: var(--paper); border: 2.5px solid var(--border);
  border-radius: 22px; padding: 20px 22px; margin-bottom: 22px;
  box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--ink);
}
.panel h2 { margin: 0 0 14px; font-size: 20px; font-weight: 400; display: flex; align-items: center; gap: 10px; }
.count-pill {
  background: var(--purple); color: #fff; font-size: 12px; font-weight: 700;
  padding: 2px 10px; border-radius: 999px; border: 1.5px solid var(--ink);
  font-family: "Nunito", sans-serif;
}

.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.member-list li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 2px solid var(--border);
  padding: 10px 14px; border-radius: 14px;
}
.member-name { font-weight: 700; }
.member-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.member-actions form { margin: 0; }
.pin-reset-form {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pin-reset-form.is-hidden,
.pin-reset-toggle.is-hidden {
  display: none;
}
.pin-reset-input {
  width: 5.5em;
  padding: 7px 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
}
.pin-reset-input:focus {
  outline: none;
  border-color: var(--coral);
}
.error-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--coral);
  background: #fff0f0;
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Plans ---------- */
.plan-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.plan-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plan-field > span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.plan-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.member-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.member-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.member-check input { accent-color: var(--teal); }
.plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.plan-card {
  background: var(--paper);
  border: 2.5px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 3px 3px 0 var(--ink);
}
.plan-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.plan-title {
  margin: 0 0 4px;
  font-family: "Kalam", cursive;
  font-size: 22px;
  font-weight: 400;
}
.plan-subtitle {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}
.plan-date {
  margin: 0;
  font-weight: 800;
  font-size: 16px;
}
.plan-meta {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}
.plan-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.plan-card-info {
  flex: 1;
  min-width: 0;
}
.plan-cost {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--yellow);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.plan-cost-input {
  position: relative;
  display: flex;
  align-items: center;
}
.plan-cost-prefix {
  position: absolute;
  left: 16px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
  z-index: 1;
}
.plan-cost-input input[type="number"] {
  width: 100%;
  padding-left: 30px;
}
.plan-cost-input input[type="number"]::-webkit-inner-spin-button,
.plan-cost-input input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}
.plan-location { color: var(--teal); }
.plan-location a {
  color: var(--teal);
  text-decoration: underline wavy rgba(47, 182, 168, 0.5);
  text-underline-offset: 3px;
}
.plan-location a:hover { color: #248f84; }

.plan-map-showcase {
  margin-top: 10px;
  border: 2.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 3px 3px 0 rgba(43, 42, 40, 0.12);
}
.plan-map-showcase.is-hidden { display: none; }
.plan-map-showcase-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--paper);
  border-bottom: 2px solid var(--border);
}
.plan-map-showcase-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.plan-map-showcase-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
}
.plan-map-showcase-detail {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}
.plan-map-showcase-link {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--coral);
  text-decoration: none;
  text-align: right;
  line-height: 1.35;
  max-width: 42%;
}
.plan-map-showcase-link:hover { text-decoration: underline; }
.plan-map-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #e8e4dc;
}
.plan-map-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.member-plan .plan-map-showcase {
  margin-top: 12px;
}
.member-plan .plan-map-frame {
  aspect-ratio: 16 / 9;
}

.plan-invite-form {
  margin: 14px 0;
  padding-top: 14px;
  border-top: 1.5px dashed rgba(43, 42, 40, 0.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-invite-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.plan-date-trigger {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  font-weight: 600;
  color: var(--muted);
}
.plan-date-trigger.has-date {
  color: var(--ink);
  background: var(--bg);
}

.plan-date-overlay .plan-date-modal { max-width: 360px; }
.plan-date-icon {
  background: #fff8e8;
  color: var(--coral);
}
.plan-date-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.plan-date-month {
  margin: 0;
  flex: 1;
  text-align: center;
  font-family: "Kalam", cursive;
  font-size: 20px;
  font-weight: 400;
}
.plan-date-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.plan-date-weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.plan-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.plan-date-cell {
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--paper);
  font-family: "Nunito", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.plan-date-cell:hover {
  background: var(--bg);
  transform: translate(-1px, -1px);
}
.plan-date-cell.dim {
  opacity: 0.38;
}
.plan-date-cell.today {
  border-color: var(--coral);
  color: var(--coral);
}
.plan-date-cell.selected {
  background: var(--coral);
  border-color: var(--ink);
  color: #fff2ee;
  box-shadow: 2px 2px 0 var(--ink);
}
.plan-date-footer {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.plan-votes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.vote-group {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.vote-group .vote-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.vote-group .count-pill { font-size: 10px; padding: 1px 7px; }
.vote-in .vote-label { color: #2f7d45; }
.vote-out .vote-label { color: var(--danger); }
.vote-pending .vote-label { color: var(--muted); }
.vote-names { font-size: 13px; font-weight: 600; line-height: 1.35; }
.member-plan {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}
.plan-card-body { flex: 1; min-width: 0; }
.plan-card-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1.5px dashed rgba(43, 42, 40, 0.2);
}
.plan-vote-actions {
  display: flex;
  justify-content: flex-end;
}
.plan-vote-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}
.plan-vote-btns {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.vote-btn {
  padding: 8px 22px;
  font-size: 14px;
  min-width: 72px;
}
.plan-vote-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}
.plan-vote-right .vote-right-num {
  font-size: 20px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1;
}
.plan-vote-right .vote-right-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #2f7d45;
}
.vote-in-btn.active {
  background: var(--green-soft);
  border-color: var(--green);
  color: #2f7d45;
  box-shadow: 3px 3px 0 var(--green);
}
.vote-out-btn.active {
  background: #fff0ee;
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 3px 3px 0 var(--danger);
}

/* ---------- Calendar controls ---------- */
.cal-controls {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 6px;
}
.nav-group { display: flex; gap: 6px; align-items: center; }
.period-label { font-size: 24px; font-weight: 400; margin: 0; flex: 1; text-align: center; min-width: 180px; }
.view-toggle { display: flex; background: var(--paper); border: 2.5px solid var(--border); border-radius: 14px; padding: 4px; gap: 4px; }
.btn.toggle { border: none; background: transparent; padding: 8px 16px; box-shadow: none; }
.btn.toggle:hover { transform: none; box-shadow: none; }
.btn.toggle.active { background: var(--teal); color: #fff; box-shadow: none; }
.hint { color: var(--muted); font-size: 13.5px; margin: 8px 0 18px; }

/* ---------- Calendar grid ---------- */
.calendar { }
.weekday-row {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px;
}
.weekday { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day-cell {
  position: relative;
  background: var(--paper); border: 2px solid var(--border);
  border-radius: 14px; padding: 6px; height: 128px;
  display: flex; flex-direction: column; gap: 3px;
  overflow: hidden; min-width: 0; max-width: 100%;
}
.day-cell.dim {
  opacity: 0.4;
  background: #e5e0d5;
  border-color: rgba(43, 42, 40, 0.2);
}
.day-cell.today { border-color: var(--coral); box-shadow: 2px 2px 0 var(--coral); }
.day-cell.day-past:not(.dim) {
  background: var(--paper);
  border-color: rgba(124, 117, 102, 0.35);
}
.day-cell.day-past:not(.dim) .day-num { color: var(--muted); }
.day-num { font-size: 12px; font-weight: 700; color: var(--muted); line-height: 1; flex-shrink: 0; }
.day-cell.today .day-num { color: var(--coral); }

.slots { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
body:not(.is-admin) .slots { overflow: visible; }
.slot {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  flex: 1; min-height: 0; min-width: 0; box-sizing: border-box;
  padding: 4px 6px; border-radius: 8px; font-size: 12px;
  background: var(--bg); border: 2px dashed var(--border);
  cursor: pointer; user-select: none; transition: background 0.12s, border 0.12s, transform 0.08s;
}
.slot:hover { transform: translate(-1px, -1px); }
.slot .slot-label { display: flex; align-items: center; gap: 4px; color: var(--muted); min-width: 0; flex: 1; }
.slot .slot-label .txt { display: flex; flex-direction: column; gap: 0; min-width: 0; line-height: 1.15; }
.slot .slot-title { font-weight: 700; }
.slot-timing { font-size: 10px; font-weight: 700; line-height: 1.2; }
.slot .slot-sub { font-size: 10px; opacity: 0.85; line-height: 1.2; }
.slot.mine .slot-timing { color: #2f7d45; }
.slot.mine .slot-sub { opacity: 1; font-weight: 600; color: #2f7d45; }
.slot-meta {
  position: relative; width: 20px; height: 20px; flex-shrink: 0; margin-left: 4px;
}
.slot-meta.has-copy {
  display: flex; align-items: center; gap: 2px;
  width: 40px; height: 20px;
}
.slot-meta.has-copy .slot-edit-btn,
.slot-meta.has-copy .slot-copy-btn {
  position: static; flex: 1; width: 18px; height: 18px;
}
.slot-copy-btn {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid rgba(47, 125, 69, 0.4); background: var(--paper);
  cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center;
  color: #2f7d45; transition: background 0.12s, border-color 0.12s, visibility 0.12s;
}
.slot-copy-btn svg { width: 10px; height: 10px; display: block; }
.slot-copy-btn:hover { background: #d8f0dc; border-color: var(--green); }
.slot-copy-btn.is-inert { visibility: hidden; pointer-events: none; }
.slot-edit-btn {
  position: absolute; inset: 0;
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid rgba(47, 125, 69, 0.4); background: var(--paper);
  cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center;
  color: #2f7d45; transition: background 0.12s, border-color 0.12s, color 0.12s, visibility 0.12s;
}
.slot-edit-btn svg { width: 11px; height: 11px; display: block; }
.slot-edit-btn:hover { background: #d8f0dc; border-color: var(--green); }
.slot-edit-btn.has-details { background: #d8f0dc; border-color: var(--green); color: var(--green); }
.slot-edit-btn.is-inert { visibility: hidden; pointer-events: none; }
.pm-name-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pm-note { font-size: 11px; font-weight: 500; color: var(--muted); line-height: 1.25; white-space: normal; }
.pm-time { font-size: 10px; font-weight: 700; color: var(--teal); line-height: 1.25; }
.slot .slot-icon { width: 14px; height: 14px; flex-shrink: 0; }
.slot .slot-icon svg { width: 100%; height: 100%; display: block; }
.slot .slot-count {
  position: absolute; top: 0; right: 0; z-index: 4;
  transform: translate(50%, -50%);
  min-width: 15px; height: 15px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-weight: 700; font-size: 9px; line-height: 1;
  background: var(--yellow); color: var(--ink);
  border: 1.5px solid var(--border); border-radius: 8px;
  pointer-events: none; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.slot .slot-count:empty { display: none; }
.slot.has:not(.mine) { border-style: solid; }
.slot.mine { background: var(--green-soft); border-style: solid; border-color: var(--green); }
.slot.mine .slot-label { color: #2f7d45; }
.slot.mine .slot-count { background: var(--green); color: #fff; border-color: var(--green); }
/* When the user is available, the edit button shows on the right.
   Keep the count on the true corner and move the button down instead. */
.slot.mine .slot-meta { align-self: flex-end; }

.slot.is-past {
  cursor: default; pointer-events: none;
  background: #f2ede4;
  border-color: rgba(43, 42, 40, 0.2);
  border-style: dashed;
}
.slot.is-past .slot-label { color: rgba(124, 117, 102, 0.8); }
.slot.is-past .slot-icon { opacity: 0.55; }
.slot.is-past:hover { transform: none; }
.slot.is-past-mine {
  cursor: pointer;
  background: #e4f0e6;
  border-color: rgba(79, 176, 106, 0.55);
  border-style: solid;
}
.slot.is-past-mine .slot-label { color: #4a8f5c; }
.slot.is-past-mine .slot-meta { pointer-events: none; }

/* Month view: icon + timing text */
.is-month .slot { justify-content: space-between; gap: 2px; padding: 2px 4px; }
.is-month .slot-label { flex: 1; min-width: 0; gap: 3px; }
.is-month .slot-title { display: none; }
.is-month .slot-sub { display: none; }
.is-month .slot-timing { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-month .slot .slot-icon { width: 12px; height: 12px; flex-shrink: 0; }
.is-month .slot-meta { width: 18px; height: 18px; }
.is-month .slot-meta.has-copy { width: 38px; height: 18px; }
.is-month .slot-meta.has-copy .slot-edit-btn,
.is-month .slot-meta.has-copy .slot-copy-btn { width: 17px; height: 17px; }
.is-month .slot-edit-btn { width: 18px; height: 18px; }
.is-month .slot-copy-btn { width: 18px; height: 18px; }
.is-month .slot-copy-btn svg { width: 9px; height: 9px; }
.is-month .slot-edit-btn svg { width: 10px; height: 10px; }
.is-month .slot .slot-count { min-width: 13px; height: 13px; font-size: 8px; }

/* Week view: full labels */
.is-week .slot { flex: 0 0 auto; min-height: 36px; padding: 6px 8px; border-radius: 10px; }
.is-week .slot-title { display: block; white-space: nowrap; }
.is-week .slot-timing { display: none; }
.is-week .slot-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.admin-slot {
  cursor: default; flex-direction: row; align-items: center;
  justify-content: flex-start; gap: 4px; padding: 3px 5px;
  border-style: solid; min-height: 0; overflow: hidden;
}
.slot.admin-slot:hover { transform: none; }
.slot.admin-slot .slot-label { flex: 0 1 auto; width: auto; min-width: 0; max-width: 42%; overflow: hidden; }
.slot.admin-slot .slot-label .txt { flex-direction: row; align-items: center; gap: 3px; }
.slot.admin-slot[data-period="morning"] {
  background: #fff8e8; border-color: #e9b84a;
}
.slot.admin-slot[data-period="morning"] .slot-label { color: #8a5a00; }
.slot.admin-slot[data-period="morning"] .slot-icon { color: #c47f00; }
.slot.admin-slot[data-period="evening"] {
  background: #eceef8; border-color: #8b7fad;
}
.slot.admin-slot[data-period="evening"] .slot-label { color: #4a3f6b; }
.slot.admin-slot[data-period="evening"] .slot-icon { color: #5c4d8a; }
.slot.admin-slot[data-period="custom"] {
  background: #edf7f2; border-color: #5a9e87;
}
.slot.admin-slot[data-period="custom"] .slot-label { color: #2d5c4a; }
.slot.admin-slot[data-period="custom"] .slot-icon { color: #3d8b7a; }
.slot.admin-slot .slot-title { display: block; font-weight: 800; line-height: 1.1; }
.slot.admin-slot .slot-sub { display: block; font-size: 9px; opacity: 0.85; line-height: 1.1; }

/* Admin month: compact horizontal rows inside fixed-height cells */
.is-admin.is-month .day-cell:not(.day-cell-compact) {
  height: 128px; overflow: hidden;
}
.is-admin.is-month .slots { gap: 2px; overflow: hidden; flex: 1; min-height: 0; min-width: 0; }
.is-admin.is-month .slots .slot-wrap {
  flex: 1 1 0; min-height: 0; min-width: 0; display: flex;
}
.is-admin.is-month .slot.admin-slot {
  flex: 1; width: 100%; min-height: 0; min-width: 0; padding: 2px 4px; gap: 3px;
}
.is-admin.is-month .slot.admin-slot .slot-label { gap: 3px; min-width: 0; flex-shrink: 1; }
.is-admin.is-month .slot.admin-slot .slot-title {
  font-size: 9px; white-space: nowrap; line-height: 1;
  overflow: hidden; text-overflow: ellipsis;
}
.is-admin.is-month .slot.admin-slot .slot-sub { display: none; }
.is-admin.is-month .slot.admin-slot .slot-icon { width: 11px; height: 11px; }
.is-admin.is-month .slot.admin-slot .slot-timing { display: none; }

.is-admin.is-week .day-cell { height: 180px; overflow: hidden; }
.is-admin.is-week .slots { gap: 4px; overflow: hidden; flex: 1; min-height: 0; min-width: 0; }
.is-admin.is-week .slots .slot-wrap {
  flex: 1 1 0; min-height: 0; min-width: 0; display: flex;
}
.is-admin.is-week .slot.admin-slot { flex: 1; width: 100%; min-height: 0; min-width: 0; padding: 5px 7px; gap: 5px; }
.is-admin.is-week .slot.admin-slot .slot-label { min-width: 0; flex-shrink: 1; }
.is-admin.is-week .slot.admin-slot .slot-title {
  font-size: 11px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.is-admin.is-week .slot.admin-slot .slot-sub { display: none; }
.is-admin.is-week .slot.admin-slot .slot-icon { width: 14px; height: 14px; }

.slot-avatars {
  display: flex; flex-wrap: wrap; gap: 3px; align-items: center;
  justify-content: flex-end; margin-left: auto; max-width: 100%;
}
.is-admin .slot-avatars {
  display: flex; align-items: center; gap: 3px;
  justify-content: flex-end; margin-left: auto;
  flex: 1 1 0; min-width: 0; max-width: 58%;
  flex-wrap: nowrap; overflow: hidden;
}
.slot-avatar-group {
  display: flex; align-items: center; flex-wrap: nowrap;
  flex: 1 1 0; min-width: 0; overflow: hidden;
}
.slot-avatar-group.avatars-collapsed { gap: 0; }
.slot-avatar-group.avatars-stacked { gap: 0; }
.slot-avatar-group.avatars-stacked .slot-avatar {
  width: 20px; height: 20px; font-size: 8px;
  box-shadow: -1px 0 0 var(--paper);
}
.slot-avatar-group.avatars-stacked .slot-avatar:not(:first-child) {
  margin-left: -8px;
}
.slot-avatar-group .slot-avatar:nth-child(1) { z-index: 5; }
.slot-avatar-group .slot-avatar:nth-child(2) { z-index: 4; }
.slot-avatar-group .slot-avatar:nth-child(3) { z-index: 3; }
.slot-avatar-group .slot-avatar:nth-child(4) { z-index: 2; }
.slot-avatar-group .slot-avatar:nth-child(5) { z-index: 1; }
.is-admin .slot-add-circle {
  flex-shrink: 0; margin-left: 0;
  position: relative; z-index: 5;
}
.is-admin .slots .slot-wrap { isolation: isolate; min-width: 0; }
.is-admin .slots .slot-wrap:has(.slot-popover) { z-index: 40; }
/* !important is intentional here: day-cell/slots rules elsewhere set fixed
   heights with overflow:hidden to keep the grid compact, and those rules
   can outrank plain overflow:visible on specificity. When a popover is
   open, clipping/stacking must always lose, so this stays !important. */
.is-admin .slots:has(.slot-popover) { overflow: visible !important; }
.is-admin .day-cell:has(.slot-popover) {
  position: relative; overflow: visible !important; z-index: 30;
}
.slot-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff; flex-shrink: 0;
  cursor: pointer; border: 1.5px solid rgba(0,0,0,0.12);
  padding: 0; font-family: inherit; line-height: 1;
  transition: transform 0.08s, box-shadow 0.08s;
}
.slot-avatar:hover { transform: scale(1.08); box-shadow: 0 1px 4px rgba(0,0,0,0.18); }
.slot-avatar-sm { width: 18px; height: 18px; font-size: 8px; cursor: default; }
.slot-avatar-sm:hover { transform: none; box-shadow: none; }
.slot-avatar-overflow,
.slot-avatar-total {
  background: var(--yellow); color: var(--ink); border-color: var(--border);
  font-size: 8px; font-weight: 800;
}
.slot-avatar-total { min-width: 22px; padding: 0 2px; }
.slot-add-circle {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px dashed var(--border); background: var(--bg);
  cursor: pointer; font-size: 15px; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  padding: 0; flex-shrink: 0; font-family: inherit; line-height: 1;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.slot-add-circle:hover { background: var(--teal-soft, #e8f4f1); border-color: var(--teal); color: var(--teal); }

.slot-wrap { position: relative; overflow: visible; }
.slot-wrap:has(.slot-popover) { z-index: 40; }

.slot-popover {
  position: absolute; z-index: 30; right: 0; top: calc(100% + 5px);
  background: var(--paper); border: 2px solid var(--border); border-radius: 14px;
  padding: 6px; min-width: 280px; max-width: 340px; width: max-content;
  box-shadow: 3px 3px 0 var(--ink);
  display: flex; flex-direction: column; max-height: min(320px, 70vh);
}
.is-admin.is-month .slot-popover {
  top: calc(100% + 5px); bottom: auto;
  left: 0; right: auto;
  width: max-content; min-width: 280px;
  max-width: min(340px, calc(100vw - 24px));
}
.pm-list {
  overflow-y: auto; min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.is-admin.is-month .pm-guest-input { font-size: 12px; padding: 6px 8px; }
.is-admin.is-month .pm-add-btn { width: 26px; height: 26px; font-size: 16px; }

/* Guest add row - always first */
.pm-guest-row {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 4px 5px; flex-shrink: 0;
}
.pm-guest-input {
  flex: 1; min-width: 0; border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--bg); outline: none; font-size: 13px; font-family: inherit;
  color: var(--ink); padding: 7px 9px; -webkit-appearance: none;
}
.pm-guest-input::placeholder { color: var(--muted); }
.pm-guest-input:focus { border-color: var(--teal); }
.pm-add-btn {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: 20px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0; font-family: inherit; color: var(--ink);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.pm-add-btn:hover, .pm-add-btn:active { background: #e4f5e4; border-color: var(--green); color: var(--green); }

.pm-divider { height: 1px; background: var(--border); margin: 2px 4px 4px; opacity: 0.25; }

/* People rows */
.pm-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 8px;
}
.pm-row:hover { background: var(--bg); }
.pm-row-add { opacity: 0.5; }
.pm-row-add:hover { opacity: 1; }
.pm-dot { flex-shrink: 0; pointer-events: none; }
.pm-name {
  flex: 1; font-size: 13px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pm-btn {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: 16px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0; font-family: inherit; color: var(--ink);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.pm-minus:hover, .pm-minus:active { background: #ffeaea; border-color: var(--danger); color: var(--danger); }
.pm-plus:hover, .pm-plus:active  { background: #e4f5e4; border-color: var(--green); color: var(--green); }

.slot-avatar-guest { border-style: dashed; border-color: rgba(255,255,255,0.7); }

body.modal-open { overflow: hidden; }
.slot-modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(43, 42, 40, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.slot-modal {
  width: 100%; max-width: 400px;
  background: var(--paper); border: 2.5px solid var(--border);
  border-radius: 18px; padding: 20px;
  box-shadow: 5px 5px 0 var(--ink);
}
.slot-modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.slot-modal-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px;
  background: var(--green-soft); color: var(--green);
  display: flex; align-items: center; justify-content: center;
}
.slot-modal-icon svg { width: 22px; height: 22px; display: block; }
.slot-modal-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.slot-modal-title { margin: 0; font-size: 22px; font-weight: 400; line-height: 1.1; }
.slot-modal-date { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.slot-modal-x {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--muted); padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.slot-modal-x:hover { background: var(--bg); color: var(--ink); }
.slot-modal-status {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  padding: 9px 12px; border-radius: 12px; background: var(--green-soft);
  font-size: 13.5px; font-weight: 700; color: #2f7d45;
}
.slot-modal-status svg {
  width: 15px; height: 15px; flex-shrink: 0; padding: 2px; border-radius: 50%;
  background: var(--green); color: #fff; box-sizing: content-box;
}
.slot-modal-status.is-setup {
  background: #e8f4f1; color: #1f6b62;
}
.slot-modal-status.is-setup svg {
  background: var(--teal); color: #fff;
}
.slot-modal-error {
  margin: 0; font-size: 13px; font-weight: 700; color: var(--danger);
}
.slot-modal-fields { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.slot-modal-section-head {
  display: flex; flex-direction: column; gap: 8px;
}
.slot-modal-section-head .slot-modal-section-label { margin-bottom: 0; }
.slot-modal-section-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: -4px;
}
.slot-modal-section-label svg { width: 15px; height: 15px; }
.slot-modal-section-sub {
  margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; font-weight: 600;
}
.slot-modal-hint {
  margin: -6px 0 4px; font-size: 12.5px; color: var(--muted); line-height: 1.4;
}
.slot-modal-times { display: flex; flex-direction: column; gap: 12px; }
.slot-modal-times-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: -4px;
}
.slot-modal-times-label {
  font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.slot-until-select {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--paper); outline: none; font-size: 14px; font-family: inherit;
  color: var(--ink); padding: 10px 10px; -webkit-appearance: none;
  cursor: pointer; max-height: 42px;
}
.slot-until-select:disabled { opacity: 0.55; cursor: not-allowed; background: var(--bg); }
.slot-until-select:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(47, 182, 168, 0.2); }
.time-block {
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--bg); padding: 10px 10px 12px;
}
.time-block-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.time-block-name { font-size: 13px; font-weight: 800; color: var(--ink); }
.time-preview { font-size: 12px; font-weight: 700; color: var(--muted); }
.time-preview.is-set { color: var(--green); }
.slot-time-picker {
  display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 8px;
}
.time-select-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.time-select-label {
  font-size: 10px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.slot-time-part {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--paper); outline: none; font-size: 14px; font-family: inherit;
  color: var(--ink); padding: 10px 8px; -webkit-appearance: none;
  cursor: pointer;
}
.slot-time-part:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(47, 182, 168, 0.2); }
.slot-modal-field { display: flex; flex-direction: column; gap: 5px; }
.slot-modal-field > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.slot-modal-note {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--bg); outline: none; font-size: 14px; font-family: inherit;
  color: var(--ink); padding: 9px 10px; -webkit-appearance: none;
}
.slot-modal-note { resize: vertical; min-height: 72px; line-height: 1.4; }
.slot-modal-note:focus { border-color: var(--teal); }
.slot-modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn.ghost.danger { color: var(--danger); border-color: transparent; }
.btn.ghost.danger:hover { background: #ffeaea; border-color: var(--danger); }
.slot-modal-save { min-width: 96px; }

/* Copy panel (separate from edit modal) */
.slot-copy-panel {
  width: 100%; max-width: 420px;
  background: var(--paper); border: 2.5px solid var(--border);
  border-radius: 18px; padding: 20px;
  box-shadow: 5px 5px 0 var(--ink);
}
.slot-copy-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.slot-copy-title { margin: 0 0 4px; font-size: 22px; font-weight: 400; line-height: 1.1; }
.slot-copy-sub { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.slot-copy-quick {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
}
.slot-copy-scroll-wrap {
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--bg); overflow: hidden; margin-bottom: 16px;
}
.slot-copy-scroll-label {
  padding: 8px 12px; font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1.5px solid var(--border); background: var(--paper);
}
.slot-copy-scroll {
  max-height: 220px; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.slot-copy-day {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
  padding: 8px 10px; border-radius: 8px; background: var(--paper);
  border: 1.5px solid transparent; cursor: pointer;
}
.slot-copy-day:hover { border-color: var(--border); }
.slot-copy-day input { accent-color: var(--teal); width: 16px; height: 16px; flex-shrink: 0; }
.slot-copy-actions {
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
}

@media (max-width: 720px) {
  .slot-popover { min-width: 280px; max-width: min(340px, 90vw); right: auto; left: 0; }
  .pm-guest-input { font-size: 16px; padding: 9px 10px; }
  .pm-add-btn { width: 38px; height: 38px; font-size: 22px; }
  .pm-btn { width: 30px; height: 30px; font-size: 18px; }
  .pm-name { font-size: 14px; }
}

/* ---------- Week view ---------- */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week-grid .day-cell { height: 180px; }

@media (max-width: 720px) {
  .month-grid, .week-grid, .weekday-row { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .day-cell:not(.day-cell-compact) { height: 102px; padding: 4px; gap: 2px; }
  .week-grid .day-cell { height: 148px; }
  .is-month .slot-timing { font-size: 8px; }
  .slot-avatar, .slot-add-circle { width: 18px; height: 18px; font-size: 8px; }
  .slot-add-circle { font-size: 12px; }
  .is-admin.is-month .day-cell:not(.day-cell-compact) { height: 102px; }
  .is-admin.is-week .day-cell { height: 148px; }
  .period-label { font-size: 18px; }
  .container { padding: 14px; }

  /* Topbar wraps cleanly on small screens */
  .topbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .brand { gap: 8px; }
  .brand-name { font-size: 21px; }
  .brand svg { width: 22px; height: 22px; }
  .topbar nav { gap: 6px; }

  /* Calendar controls stack sensibly */
  .cal-controls { gap: 10px; }
  .nav-group { flex: 0 0 auto; }
  .view-toggle { flex: 0 0 auto; }
  .period-label { order: -1; flex-basis: 100%; min-width: 0; }

  /* iOS zooms inputs under 16px on focus; keep modal inputs readable */
  .slot-time-part, .slot-until-select, .slot-modal-note { font-size: 16px; }
  .slot-copy-scroll { max-height: 180px; }

  /* Admin member rows stack instead of overflowing */
  .member-list li { flex-wrap: wrap; gap: 8px; }
  .member-actions { margin-left: auto; }

  .plan-field-row { grid-template-columns: 1fr; }
  .plan-votes { grid-template-columns: 1fr; }
  .plan-map-showcase-link { max-width: none; }
  .plan-map-showcase-head { flex-direction: column; align-items: stretch; }
  .plan-map-showcase-link { text-align: left; }
}

@media (max-width: 480px) {
  .container { padding: 10px; }
  .topbar { padding: 10px 12px; }
  .brand .tag { font-size: 10px; padding: 2px 8px; }
  .btn { padding: 10px 14px; }
  .btn.sm { padding: 8px 12px; }
  .btn.ghost.icon { padding: 8px 12px; }

  .weekday { font-size: 10px; }
  .day-cell:not(.day-cell-compact) { height: 94px; padding: 3px; gap: 2px; }
  .day-num { font-size: 11px; }
  .is-month .day-cell-compact .day-num { font-size: 12px; }
  .is-month .slot-timing { font-size: 7.5px; }
  .slot .slot-count { min-width: 15px; font-size: 10px; padding: 0 3px; }

  /* Auth screens fit narrow phones without overflow */
  .auth-wrap { padding: 16px; }
  .auth-wrap.has-intro { padding: 20px 16px 28px; gap: 22px; }
  .auth-brand { font-size: 28px; }
  .auth-brand svg { width: 30px; height: 30px; }
  .auth-tagline { font-size: 14.5px; }
  .auth-steps { gap: 8px; }
  .auth-step { padding: 12px 8px 10px; font-size: 11.5px; }
  .auth-step strong { font-size: 12.5px; }
  .auth-step-icon { width: 30px; height: 30px; }
  .auth-step-icon svg { width: 16px; height: 16px; }
  .auth-blob-1 { width: 200px; height: 200px; }
  .auth-blob-2 { width: 180px; height: 180px; }
  .auth-blob-3 { width: 220px; height: 220px; }
  .card { padding: 30px 22px; transform: none; }
  .card h1 { font-size: 26px; }
  .auth-card .auth-title { font-size: 28px; }
  .code-display { font-size: 26px; letter-spacing: 0.12em; padding: 16px 12px; }
  .pin-input { font-size: 24px; letter-spacing: 0.25em; }
}

/* Give buttons real height for touch */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; }
  .btn.toggle { min-height: 0; }
}

/* On phones, week view becomes a vertical, scroll-down list of days */
@media (max-width: 600px) {
  .is-week .weekday-row { display: none; }
  .is-week .week-grid { grid-template-columns: 1fr; gap: 10px; }
  .is-week .week-grid .day-cell {
    height: auto; min-height: 0; padding: 12px 14px; gap: 8px;
  }
  .is-week .day-num {
    font-size: 15px; color: var(--ink); text-transform: uppercase;
    letter-spacing: 0.03em; padding-bottom: 6px;
    border-bottom: 1.5px dashed rgba(43, 42, 40, 0.18);
  }
  .is-week .day-cell.today .day-num { color: var(--coral); }
  .is-week .slots { gap: 8px; margin-top: 0; }
  .is-week .slot { font-size: 14px; padding: 11px 12px; border-radius: 12px; min-height: 44px; }
  .is-week .slot .slot-icon { width: 16px; height: 16px; }
  .is-week .slot .slot-sub { display: inline; font-size: 11px; }
  .is-week .slot .slot-count { min-width: 26px; font-size: 14px; padding: 2px 8px; }
  .is-week .slot-avatar { width: 26px; height: 26px; font-size: 10px; }
  .is-week .slot-add-circle { width: 26px; height: 26px; font-size: 14px; }
  .is-admin.is-week .slots .slot-wrap { flex: 0 0 auto; }
  .is-admin.is-week .slot.admin-slot { flex: 0 0 auto; min-height: 44px; }
  .slot-modal-fields { grid-template-columns: 1fr; }

  /* Month view: compact tap-friendly day grid, slots open in a sheet */
  .is-month .weekday-row { margin-bottom: 6px; }
  .is-month .weekday { font-size: 10px; }
  .is-month .month-grid { gap: 5px; }
  .is-month .day-cell-compact {
    height: auto; min-height: 58px; padding: 6px 4px 8px; gap: 4px;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s, background 0.1s;
  }
  .is-month .day-cell-compact .day-num {
    font-size: 13px; text-align: center; width: 100%;
  }
  .is-month .day-cell-compact.today .day-num { font-size: 14px; }
  .is-month .day-cell-compact.is-selected {
    border-color: var(--teal); background: #e8f7f5;
    box-shadow: 2px 2px 0 var(--teal);
  }
  .is-month .day-cell-compact:active {
    transform: scale(0.96);
    background: #f0ebe0;
  }
  .day-indicators {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 3px; min-height: 10px;
  }
  .day-dots {
    display: flex; justify-content: center; align-items: center;
    gap: 4px; flex-wrap: wrap;
  }
  .day-total {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 14px; padding: 0 4px;
    font-size: 9px; font-weight: 800; line-height: 1;
    background: var(--yellow); color: var(--ink);
    border: 1.5px solid var(--border); border-radius: 7px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  }
  .day-cell-compact.today .day-total {
    background: var(--coral); color: #fff; border-color: var(--coral);
  }
  .day-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: rgba(43, 42, 40, 0.12);
    border: 1.5px solid rgba(43, 42, 40, 0.18);
    flex-shrink: 0;
  }
  .day-dot[data-period="morning"].has { background: #f2cc8f; border-color: #e9b84a; }
  .day-dot[data-period="evening"].has { background: #d8d4ec; border-color: #8b7fad; }
  .day-dot[data-period="custom"].has { background: #c8e8dc; border-color: #5a9e87; }
  .day-dot.mine { background: var(--green); border-color: var(--green); }
}

/* Day sheet: full-size slots for mobile month view */
.day-sheet-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(43, 42, 40, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.day-sheet {
  width: 100%; max-width: 520px; max-height: 88vh;
  background: var(--paper); border: 2.5px solid var(--border);
  border-bottom: none; border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 24px rgba(43, 42, 40, 0.18);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: day-sheet-in 0.22s ease-out;
}
@keyframes day-sheet-in {
  from { transform: translateY(100%); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
.day-sheet-grab {
  width: 36px; height: 4px; border-radius: 4px;
  background: rgba(43, 42, 40, 0.18); margin: 0 auto 12px;
}
.day-sheet-head {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1.5px dashed rgba(43, 42, 40, 0.18);
}
.day-sheet-heading { flex: 1; min-width: 0; }
.day-sheet-title {
  margin: 0; font-size: 20px; font-weight: 400; line-height: 1.15;
  font-family: "Kalam", cursive;
}
.day-sheet-sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.day-sheet-close {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: 24px; line-height: 1; color: var(--muted);
  padding: 0; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s, transform 0.08s;
}
.day-sheet-close:active { transform: scale(0.94); background: #f0ebe0; color: var(--ink); }
.day-sheet-slots { display: flex; flex-direction: column; gap: 10px; }
.day-sheet .slot {
  flex: 0 0 auto; min-height: 52px; padding: 12px 14px;
  border-radius: 12px; font-size: 14px; gap: 8px;
}
.day-sheet .slot .slot-title { display: block; white-space: nowrap; font-size: 14px; }
.day-sheet .slot .slot-timing { display: none; }
.day-sheet .slot .slot-sub { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-sheet .slot .slot-icon { width: 18px; height: 18px; }
.day-sheet .slot .slot-count { min-width: 26px; height: 22px; font-size: 13px; padding: 0 6px; }
.day-sheet .slot-meta { width: 36px; height: 36px; margin-left: 8px; }
.day-sheet .slot-meta.has-copy { width: 76px; height: 36px; gap: 4px; }
.day-sheet .slot-edit-btn,
.day-sheet .slot-copy-btn { width: 34px; height: 34px; border-radius: 10px; }
.day-sheet .slot-meta.has-copy .slot-edit-btn,
.day-sheet .slot-meta.has-copy .slot-copy-btn { width: 34px; height: 34px; }
.day-sheet .slot-edit-btn svg { width: 15px; height: 15px; }
.day-sheet .slot-copy-btn svg { width: 14px; height: 14px; }
.day-sheet .slot-avatar { width: 30px; height: 30px; font-size: 10px; }
.day-sheet .slot-add-circle { width: 30px; height: 30px; font-size: 16px; }
.day-sheet .slot.admin-slot { padding: 10px 12px; gap: 6px; min-height: 56px; }
.day-sheet .slot.admin-slot .slot-title { font-size: 13px; }
.day-sheet .slot.admin-slot .slot-sub { font-size: 11px; }
.day-sheet .slot-popover {
  position: fixed; left: 16px; right: 16px; bottom: auto; top: 50%;
  transform: translateY(-50%); width: auto; min-width: 0; max-width: none;
  z-index: 110; box-shadow: 4px 4px 0 var(--ink);
}
.day-sheet .pm-guest-input { font-size: 16px; padding: 10px 12px; }
.day-sheet .pm-add-btn { width: 40px; height: 40px; font-size: 22px; }
.day-sheet .pm-btn { width: 34px; height: 34px; font-size: 18px; }
.day-sheet .pm-name { font-size: 14px; }

/* Touch feedback on slots */
@media (hover: none) and (pointer: coarse) {
  .slot:not(.admin-slot):active {
    transform: scale(0.98);
    background: #f0ebe0;
  }
  .slot.mine:active { background: #d4edd8; }
  .day-sheet .slot:active { transform: scale(0.99); }
}
