:root {
  --bg: #f6f7f9;
  --fg: #1a1a1a;
  --muted: #777;
  --border: #d8dce0;
  --accent: #3b82f6;
  --yes: #16a34a;
  --maybe: #ca8a04;
  --no: #9ca3af;
  --weekend: #fafafa;
  --present: #22c55e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.4;
}

main { max-width: 760px; margin: 0 auto; padding: 16px; }

header h1 {
  font-size: 1.1rem;
  margin: 0 0 12px;
  font-weight: 600;
}

.presence-bar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.presence-bar h2 {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.presence-buttons {
  display: flex;
  gap: 8px;
}
.presence-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.presence-toggle .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--no);
}
.presence-toggle.on { border-color: var(--present); background: #ecfdf5; }
.presence-toggle.on .dot { background: var(--present); box-shadow: 0 0 0 3px rgba(34,197,94,0.2); }
.presence-toggle .name { font-weight: 600; }
.presence-toggle .state { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.presence-toggle.on .state { color: var(--present); }

.week table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.week th, .week td {
  border: 1px solid var(--border);
  padding: 8px;
  vertical-align: top;
  text-align: left;
}
.week thead th {
  background: #f1f3f5;
  font-size: 0.85rem;
  text-align: center;
}
.week tr.weekend { background: var(--weekend); }
.week .date-cell {
  width: 60px;
  text-align: center;
  background: #fafafa;
}
.week .date-cell .md { font-weight: 600; }
.week .date-cell .wd { font-size: 0.75rem; color: var(--muted); }

.cell {
  cursor: pointer;
  min-height: 52px;
}
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell .status { font-weight: 600; font-size: 0.9rem; }
.cell .note { font-size: 0.8rem; color: var(--muted); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.cell.st-yes   { background: #ecfdf5; }
.cell.st-yes   .status { color: var(--yes); }
.cell.st-maybe { background: #fefce8; }
.cell.st-maybe .status { color: var(--maybe); }
.cell.st-no    .status { color: var(--no); }
.cell.st-empty .status { color: #cbd5e1; }

dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  min-width: 280px;
  max-width: 90vw;
}
dialog::backdrop { background: rgba(0,0,0,0.3); }
dialog h3 { margin: 0 0 12px; font-size: 1rem; }
.status-choice { border: none; padding: 0; margin: 0 0 12px; }
.status-choice legend { font-size: 0.8rem; color: var(--muted); padding: 0; margin-bottom: 4px; }
.status-choice label { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; }
.note-field { display: block; }
.note-field span { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.note-field textarea { width: 100%; font: inherit; padding: 6px; border: 1px solid var(--border); border-radius: 4px; resize: vertical; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.modal-actions .spacer { flex: 1; }
.modal-actions button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font: inherit;
}
.modal-actions button[data-action="save"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal-actions button[data-action="delete"] { color: #dc2626; border-color: #fca5a5; }
.modal-actions button[data-action="delete"]:hover { background: #fef2f2; }

@media (max-width: 480px) {
  main { padding: 8px; }
  .presence-toggle { padding: 8px; }
  .presence-toggle .state { display: none; }
  .week th, .week td { padding: 6px; }
}
