/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:         #0f2d52;
  --navy-mid:     #1a3a5c;
  --accent:       #2563eb;
  --green:        #059669;
  --green-bg:     #d1fae5;
  --green-border: #059669;
  --blue-bg:      #dbeafe;
  --blue-border:  #2563eb;
  --amber-bg:     #fef3c7;
  --amber-border: #d97706;
  --blocked-a:    #e8edf2;
  --blocked-b:    #d4dae0;
  --cell-border:  #e2e8f0;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --radius:       10px;
  --radius-sm:    7px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Login page ─────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #0f2d52 0%, #1e4d82 100%);
  padding: 1.5rem;
}

.login-wrap {
  width: 100%;
  max-width: 360px;
}

.login-card {
  background: #fff;
  border-radius: 22px;
  padding: 2.75rem 2rem 2.25rem;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,0.35);
  animation: fade-up 0.3s ease;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

.login-emoji  { font-size: 3.5rem; line-height: 1; margin-bottom: 0.6rem; }
.login-title  { font-size: 2rem; font-weight: 900; color: var(--navy); margin-bottom: 0.3rem; letter-spacing: -0.5px; }
.login-sub    { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1.75rem; }

.login-rules {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin-bottom: 1.75rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.login-rule {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  color: #374151;
}

.lr-icon { font-size: 1rem; flex-shrink: 0; }

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  background: #fff;
  color: #3c4043;
  border: 1.5px solid #dadce0;
  border-radius: 8px;
  padding: 0.8rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  letter-spacing: 0.01em;
}
.google-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.google-btn:active { background: #f1f3f4; }
.google-logo { flex-shrink: 0; }

.login-error {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #dc2626;
}

/* ── App shell ──────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  background: #f1f5f9;
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.2px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 100px;
  padding: 0.25rem 0.6rem 0.25rem 0.3rem;
  max-width: 180px;
}

.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
}

.user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
}

.logout-link {
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 0.7rem;
  line-height: 1;
  padding: 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.logout-link:hover { color: #fff; }

/* ── Info strip ─────────────────────────────────────────────── */
.info-strip {
  background: #fff;
  border-bottom: 1px solid var(--cell-border);
}

.info-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.info-toggle:hover { color: var(--navy); }

.info-icon   { font-size: 0.9rem; }
.info-label  { flex: 1; }
.info-chevron {
  font-size: 1.1rem;
  transition: transform 0.2s;
  color: var(--text-muted);
}
.info-toggle[aria-expanded="true"] .info-chevron { transform: rotate(90deg); }

.info-body {
  padding: 0 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: slide-down 0.18s ease;
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

.info-rule {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.83rem;
  color: #374151;
  line-height: 1.4;
}
.info-rule span:first-child { flex-shrink: 0; font-size: 0.95rem; }

/* ── Month nav ───────────────────────────────────────────────── */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem 0.4rem;
}

.month-label {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy);
  min-width: 165px;
  text-align: center;
  letter-spacing: -0.3px;
}

.nav-btn {
  background: #fff;
  border: 1.5px solid var(--cell-border);
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  flex-shrink: 0;
}
.nav-btn:hover:not(:disabled) { border-color: var(--navy); background: var(--navy); color: #fff; }
.nav-btn:disabled { opacity: 0.25; cursor: default; box-shadow: none; }

/* ── Calendar ────────────────────────────────────────────────── */
.cal-wrap { padding: 0 0.65rem 0.5rem; }

.cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  padding: 0.55rem 0 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-cell {
  background: #fff;
  border: 1.5px solid var(--cell-border);
  border-radius: var(--radius-sm);
  min-height: 72px;
  padding: 5px 4px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
}

.cal-cell.empty   { background: transparent; border-color: transparent; cursor: default; }

.cal-cell.today   { border-color: var(--accent); border-width: 2px; }
.cal-cell.today .cell-date::after {
  content: '';
  display: block;
  width: 4px; height: 4px;
  background: var(--accent);
  border-radius: 50%;
  margin: 1px auto 0;
}

.cal-cell.past    { background: #f8fafc; cursor: default; }
.cal-cell.past .cell-date { color: #b0bec5; }

.cal-cell.blocked {
  background: repeating-linear-gradient(
    45deg,
    var(--blocked-a) 0, var(--blocked-a) 5px,
    var(--blocked-b) 5px, var(--blocked-b) 10px
  );
  border-color: #c4ced8;
  cursor: not-allowed;
}
.cal-cell.blocked .cell-date { color: #94a3b8; }

.cal-cell.partial { background: var(--amber-bg); border-color: var(--amber-border); }
.cal-cell.partial .cell-date { color: #78350f; }

.cal-cell.voted   { background: var(--blue-bg); border-color: var(--blue-border); border-width: 2px; }
.cal-cell.voted .cell-date { color: #1e40af; }

.cal-cell.locked  { background: var(--green-bg); border-color: var(--green-border); border-width: 2px; cursor: pointer; }
.cal-cell.locked:active { transform: scale(0.93); }
.cal-cell.locked .cell-date { color: #064e3b; }

.cal-cell:not(.empty):not(.past):not(.blocked):not(.locked):active { transform: scale(0.92); }

.cal-cell.tap-flash { animation: tap 0.2s ease-out; }
@keyframes tap {
  0%  { transform: scale(1); }
  40% { transform: scale(0.9); }
  100%{ transform: scale(1); }
}

/* Cell content */
.cell-date {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  align-self: flex-start;
  padding-left: 2px;
}

.cell-lock {
  font-size: 0.9rem;
  line-height: 1;
}

.cell-locked-hint {
  font-size: 0.5rem;
  font-weight: 700;
  color: #065f46;
  opacity: 0.7;
  letter-spacing: 0.02em;
  text-align: center;
}

/* Avatar row */
.cell-avatars {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  justify-content: center;
  margin-top: 1px;
}

.cell-av {
  width: 18px; height: 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.7);
  background: #e2e8f0;
  flex-shrink: 0;
}

.cell-av-fallback {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.7);
}

.cell-count {
  margin-top: auto;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 100px;
  line-height: 1.6;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
.partial .cell-count { background: #d97706; }

/* Empty state */
.cal-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}
.cal-empty-state strong { display: block; font-size: 1.1rem; margin-bottom: 0.3rem; color: var(--navy); }

/* ── Legend ──────────────────────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  justify-content: center;
  padding: 0.65rem 1rem 0.4rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}
.ld {
  width: 13px; height: 13px;
  border-radius: 3px;
  border: 1.5px solid transparent;
  flex-shrink: 0;
}
.ld.locked  { background: var(--green-bg);  border-color: var(--green-border); }
.ld.voted   { background: var(--blue-bg);   border-color: var(--blue-border); }
.ld.partial { background: var(--amber-bg);  border-color: var(--amber-border); }
.ld.blocked {
  background: repeating-linear-gradient(45deg, var(--blocked-a) 0, var(--blocked-a) 3px, var(--blocked-b) 3px, var(--blocked-b) 6px);
  border-color: #c4ced8;
}

/* ── Activities section ──────────────────────────────────────── */
.activities-section {
  margin: 0.5rem 0.65rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--cell-border);
  background: #fff;
  align-self: stretch;
}

.activities-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.75rem 1rem 0.55rem;
  border-bottom: 1px solid var(--cell-border);
}

.activities-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--navy);
}

.activities-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.act-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  border-bottom: 1px solid var(--cell-border);
}
.act-row:last-child { border-bottom: none; }

.act-date-cell {
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border-right: 1px solid var(--cell-border);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1px;
}

.act-date-day {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
}

.act-date-month {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}

.act-suggestions {
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.act-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  line-height: 1.35;
}

.act-item-text { flex: 1; color: var(--text); }
.act-item-by   { color: var(--text-muted); font-size: 0.7rem; white-space: nowrap; margin-right: auto; }

.act-delete {
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.act-delete:hover { color: #ef4444; }

.act-none {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.act-vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: 1px solid var(--cell-border);
  border-radius: 100px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.act-vote-btn:hover { border-color: var(--accent); color: var(--accent); }
.act-vote-btn.voted { background: var(--blue-bg); border-color: var(--blue-border); color: var(--accent); }
.act-vote-count { font-variant-numeric: tabular-nums; }

.act-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px dashed var(--cell-border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  margin-top: 0.25rem;
  transition: border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.act-add-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Activity modal ──────────────────────────────────────────── */
.act-modal {
  max-width: 380px;
  padding: 1.25rem 1.25rem 1.5rem;
}

.act-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.act-modal-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.act-modal-datestr {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy);
}

.act-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.act-close:hover { color: var(--text); }

.act-existing {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  max-height: 180px;
  overflow-y: auto;
}

.act-existing-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #f8fafc;
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
}

.act-existing-text { flex: 1; color: var(--text); }
.act-existing-by   { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; margin-right: auto; }

.act-existing-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 0.5rem 0;
}

.act-input-row {
  display: flex;
  gap: 0.5rem;
}

.act-input {
  flex: 1;
  border: 1.5px solid var(--cell-border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  font-size: 0.9rem;
  outline: none;
  color: var(--text);
  background: #f8fafc;
  transition: border-color 0.15s;
}
.act-input:focus { border-color: var(--accent); background: #fff; }

.act-submit-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.act-submit-btn:hover { background: var(--navy-mid); }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  color: #fff;
  padding: 0.6rem 1.4rem;
  border-radius: 100px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0,0,0,0.28);
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 100;
  white-space: nowrap;
  pointer-events: none;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
