:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #6b7076;
  --line: #e3e1da;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe9;
  --danger: #b3412e;
  --danger-soft: #f8e6e2;
  --warn-soft: #fbf1d9;
  --sun: #c0443a;
  --sat: #2f5f9e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 960px; margin: 0 auto; padding: 16px; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: 0.04em; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.brand small { color: var(--muted); font-weight: 500; margin-left: 6px; font-size: 0.75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 0.95rem; line-height: 1.2; min-height: 40px;
  transition: background 0.15s, border-color 0.15s;
}
a.btn { text-decoration: none; color: inherit; }
.btn:hover { background: #f1f0ea; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: #275e50; }
.btn-danger { color: var(--danger); border-color: #e6c4bd; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 10px; min-height: 32px; font-size: 0.85rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ログイン */
.login { max-width: 360px; margin: 12vh auto 0; padding: 28px 24px; }
.login h1 { margin: 0 0 4px; font-size: 1.3rem; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; }

/* フォーム */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: 0.85rem; font-weight: 600; }
.field .hint { font-size: 0.78rem; color: var(--muted); }
input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="number"], textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 16px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.error { color: var(--danger); font-size: 0.88rem; margin: 4px 0 10px; min-height: 1em; }

/* カレンダー */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 12px; }
.month-nav h2 { margin: 0; font-size: 1.25rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.cal .dow { font-size: 0.75rem; text-align: center; padding: 6px 0; color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fbfaf7; }
.cal .dow.sun { color: var(--sun); } .cal .dow.sat { color: var(--sat); }
.cal .day { min-height: 92px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal .day.other { background: #faf9f6; color: #b5b3ad; }
.cal .day.today .num { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; }
.cal .num { font-size: 0.8rem; align-self: flex-start; }
.cal .day.sun .num { color: var(--sun); } .cal .day.sat .num { color: var(--sat); }
.cal .day.today .num { color: #fff; }
.chip {
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer;
  background: var(--accent-soft); color: #1d4a3e; border-radius: 5px; padding: 2px 5px;
  font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.full, .chip.closed { background: #eceae4; color: var(--muted); }
.chip.mine { box-shadow: inset 3px 0 0 var(--accent); }

/* 一覧 */
.agenda { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.agenda h3 { margin: 8px 0 0; font-size: 1rem; }
.ev { padding: 12px 14px; display: flex; gap: 14px; align-items: center; cursor: pointer; text-align: left; width: 100%; border: 1px solid var(--line); }
.ev:hover { border-color: #cfccc3; }
.ev .when { min-width: 92px; font-size: 0.85rem; color: var(--muted); }
.ev .when b { display: block; color: var(--ink); font-size: 0.95rem; }
.ev .what { flex: 1; min-width: 0; }
.ev .what .t { font-weight: 600; }
.ev .what .s { font-size: 0.82rem; color: var(--muted); }
.badge { display: inline-block; font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: #1d4a3e; white-space: nowrap; }
.badge.gray { background: #eceae4; color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: #7a5a12; }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

/* ダイアログ */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
dialog::backdrop { background: rgba(20, 20, 20, 0.35); }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 8px; }
.dlg-head h2 { margin: 0; font-size: 1.15rem; }
.dlg-body { padding: 4px 20px 20px; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.92rem; margin: 6px 0 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.desc { white-space: pre-wrap; background: #faf9f6; border-radius: 8px; padding: 10px 12px; font-size: 0.92rem; margin-bottom: 14px; }
.section-title { font-size: 0.9rem; font-weight: 700; margin: 16px 0 8px; }
.attendees { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.attendees li { background: #f1f0ea; border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; }
.mine-box { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* 管理画面テーブル */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.toolbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 8px 0 14px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* トースト */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: #23272b; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 0.92rem; transition: all 0.25s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); }

@media (max-width: 640px) {
  .wrap { padding: 12px; }
  .cal .day { min-height: 56px; padding: 3px; }
  .chip { font-size: 0; height: 7px; padding: 0; border-radius: 4px; }
  .ev .when { min-width: 76px; }
  .row { flex-direction: column; gap: 0; }
}
