:root {
  --roman: #2563eb;          /* blue  — Roman / Dad */
  --amber: #db2777;          /* pink  — Amber / Mom */
  --split: #ea580c;          /* orange — split / complicated day */
  --roman-faint: #dbeafe;    /* faint blue tile */
  --amber-faint: #fce7f3;    /* faint pink tile */
  --split-faint: #ffedd5;    /* faint orange tile */
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; padding: 36px 40px; border-radius: 18px; width: 340px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, .12); text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card .sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field select, .field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; background: #fff;
}
button { cursor: pointer; font: inherit; }
.primary {
  background: var(--roman); color: #fff; border: none; padding: 11px 18px;
  border-radius: 10px; font-size: 15px; font-weight: 600;
}
.primary:hover { filter: brightness(1.05); }
.primary.small { padding: 7px 14px; font-size: 14px; }
.ghost {
  background: #fff; border: 1px solid var(--line); padding: 8px 14px;
  border-radius: 10px; color: var(--ink);
}
.ghost.small { padding: 5px 10px; font-size: 13px; }
.ghost:hover { background: #f8fafc; }
#login-form button[type="submit"] { width: 100%; margin-top: 4px; }
.error { color: #dc2626; font-size: 14px; margin: 12px 0 0; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; gap: 10px;
}
.brand { font-weight: 700; font-size: 18px; }
.legend { display: flex; gap: 10px; }
.chip {
  font-size: 13px; padding: 4px 12px; border-radius: 999px; font-weight: 600;
}
.chip.roman { background: var(--roman-faint); color: var(--roman); }
.chip.amber { background: var(--amber-faint); color: var(--amber); }
.chip.split { background: var(--split-faint); color: var(--split); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

/* ---------- Controls ---------- */
.controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 8px; max-width: 1100px; margin: 0 auto; flex-wrap: wrap; gap: 10px;
}
.month-nav { display: flex; align-items: center; gap: 10px; }
.month-nav h2 { margin: 0; font-size: 20px; min-width: 190px; text-align: center; }
.month-nav .ghost { font-size: 20px; line-height: 1; padding: 4px 12px; }
.month-nav .ghost.small { font-size: 13px; }

.banner {
  max-width: 1100px; margin: 10px auto 0; padding: 12px 16px; border-radius: 12px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 14px;
}
.banner .swap-actions { margin-top: 8px; display: flex; gap: 8px; }
.banner button { font-size: 13px; padding: 6px 12px; border-radius: 8px; }
.banner .approve { background: #16a34a; color: #fff; border: none; }
.banner .decline { background: #fff; border: 1px solid #d1d5db; }

.swapbar {
  max-width: 1100px; margin: 8px auto 0; padding: 12px 16px; border-radius: 12px;
  background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.swap-buttons { display: flex; gap: 8px; }

/* ---------- Calendar grid ---------- */
.weekdays, .grid {
  max-width: 1100px; margin: 0 auto; display: grid;
  grid-template-columns: repeat(7, 1fr); gap: 8px; padding: 0 20px;
}
.weekdays { margin-top: 14px; color: var(--muted); font-size: 13px; font-weight: 600; text-align: center; }
.grid { margin-top: 6px; padding-bottom: 40px; }

.cell {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  min-height: 92px; padding: 8px; position: relative; cursor: pointer;
  display: flex; flex-direction: column; transition: transform .05s, box-shadow .1s;
}
.cell.empty { background: transparent; border: none; cursor: default; }
.cell.roman { background: var(--roman-faint); border-color: #bfdbfe; }
.cell.amber { background: var(--amber-faint); border-color: #fbcfe8; }
.cell.split {
  border-color: #fed7aa;
  /* diagonal blue/pink split so it reads as "both" at a glance, tinted orange */
  background:
    linear-gradient(135deg, var(--roman-faint) 0 47%, var(--split) 47% 53%, var(--amber-faint) 53% 100%);
}
.cell:not(.empty):hover { box-shadow: 0 4px 14px rgba(15,23,42,.12); }
.cell.today { outline: 2px solid var(--ink); outline-offset: -2px; }

.cell .num { font-weight: 600; font-size: 14px; }
.cell.roman .num { color: var(--roman); }
.cell.amber .num { color: var(--amber); }
.cell.split .num { color: var(--split); }
.cell .owner-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; opacity: .8; }
.cell.roman .owner-tag { color: var(--roman); }
.cell.amber .owner-tag { color: var(--amber); }
.cell.split .owner-tag { color: var(--split); }
.cell .note-preview {
  margin-top: auto; font-size: 11px; color: var(--muted); line-height: 1.3;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cell .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.cell .badge { position: absolute; top: 6px; right: 6px; font-size: 10px; background: #fde68a; color: #92400e; padding: 1px 6px; border-radius: 999px; }

/* swap-mode selection states */
.cell.selectable-give { outline: 2px dashed var(--roman); outline-offset: -2px; }
.cell.selectable-take { outline: 2px dashed var(--amber); outline-offset: -2px; }
.cell.picked-give { box-shadow: 0 0 0 3px var(--roman) inset; }
.cell.picked-take { box-shadow: 0 0 0 3px var(--amber) inset; }

/* ---------- Day editor overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
/* A class-level `display` overrides the `hidden` attribute's default
   `display:none`, so these elements must opt back into hiding explicitly. */
.overlay[hidden], .swapbar[hidden] { display: none; }
.panel {
  background: #fff; border-radius: 18px; width: 380px; max-width: 100%;
  padding: 24px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.panel-close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 24px; color: var(--muted); }
.panel h3 { margin: 0 0 16px; }
.panel-section { margin-bottom: 18px; }
.panel-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.owner-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.owner-opt { border: 1px solid var(--line); background: #fff; padding: 8px 12px; border-radius: 10px; font-weight: 600; }
.owner-opt.roman.active { background: var(--roman); color: #fff; border-color: var(--roman); }
.owner-opt.amber.active { background: var(--amber); color: #fff; border-color: var(--amber); }
.owner-opt.split.active { background: var(--split); color: #fff; border-color: var(--split); }
.owner-opt.reset.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.4; }
#note-input, .date-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; resize: vertical; }
#save-day { width: 100%; }
