:root {
  --bg: #ffffff; --fg: #1d1d1f; --muted: #6e6e73; --line: #e5e5ea; --soft: #f5f5f7;
  --accent: #0a66c2; --accent-soft: #e6f0fa; --mail: #2e7d4f; --mail-soft: #e7f4ec;
  --danger: #c62828; --now: #e53935;
  --hour: 48px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113; --fg: #f2f2f7; --muted: #9a9aa0; --line: #2c2c30; --soft: #1c1c1f;
    --accent: #5aa2ff; --accent-soft: #19304d; --mail: #5fcf8f; --mail-soft: #183527;
    --danger: #ff6b6b; --now: #ff5c5c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 6px 12px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.small { padding: 6px 12px; }
[hidden] { display: none !important; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center; }
.login-card input { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); text-align: center; }
.login-card button { padding: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line);
  padding: max(8px, env(safe-area-inset-top)) 16px 8px; display: grid; gap: 8px; }
.top .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top h1 { font-size: 18px; margin: 0; }
.nav { display: flex; gap: 4px; }
.nav button { min-width: 40px; }
.seg { display: flex; background: var(--soft); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 14px; border-radius: 8px; }
.seg button.on { background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }
.range { font-weight: 600; font-size: 15px; }

main { padding: 0 0 max(24px, env(safe-area-inset-bottom)); }

/* 時間軸（日・週） */
.grid { display: grid; position: relative; }
.days-head { display: grid; position: sticky; top: var(--head-h, 0); z-index: 3; background: var(--bg); border-bottom: 1px solid var(--line); }
.days-head div { text-align: center; padding: 4px 0; font-size: 12px; color: var(--muted); }
.days-head div b { display: block; font-size: 16px; color: var(--fg); }
.days-head .is-today b { color: #fff; background: var(--accent); border-radius: 999px; width: 28px; height: 28px; line-height: 28px; margin: 0 auto; }
.days-head .sun { color: var(--danger); } .days-head .sat { color: var(--accent); }
.hours { position: relative; }
.hours .h { height: var(--hour); font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.col { position: relative; border-left: 1px solid var(--line); }
.col .slot { height: calc(var(--hour) / 2); border-bottom: 1px dotted var(--line); }
.col .slot:nth-child(2n) { border-bottom-style: solid; }
.col .slot.past { background: var(--soft); }
.col .slot:not(.past):active { background: var(--accent-soft); }
.ev { position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 2px 6px; overflow: hidden;
  background: var(--accent-soft); border-left: 3px solid var(--accent); font-size: 12px; line-height: 1.3; cursor: pointer; }
.ev.mail { background: var(--mail-soft); border-left-color: var(--mail); }
.ev b { display: block; font-size: 12px; }
.ev span { color: var(--muted); }
.week .ev { padding: 1px 3px; font-size: 10px; }
.week .ev b { font-size: 10px; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--now); z-index: 2; pointer-events: none; }

/* 月 */
.month { display: grid; grid-template-columns: repeat(7, 1fr); }
.month .wd { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--line); }
.month .cell { min-height: 84px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; cursor: pointer; overflow: hidden; }
.month .cell:nth-child(7n) { border-right: 0; }
.month .cell.other { color: var(--muted); background: var(--soft); }
.month .num { font-size: 13px; font-weight: 600; }
.month .cell.today .num { color: #fff; background: var(--accent); border-radius: 999px; padding: 0 6px; }
.month .pill { font-size: 10px; line-height: 1.3; margin-top: 2px; padding: 1px 3px; border-radius: 4px; background: var(--accent-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month .pill.mail { background: var(--mail-soft); }
@media (max-width: 600px) { .month .pill .t { display: none; } }
.month .more { font-size: 10px; color: var(--muted); }

/* ダイアログ */
dialog { border: 0; border-radius: 16px; padding: 20px; width: min(420px, calc(100vw - 32px)); background: var(--bg); color: var(--fg); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog form, .detail { display: grid; gap: 10px; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
dialog input, dialog select { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); font-size: 16px; width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.actions button { padding: 10px 14px; }
.detail p { margin: 0; }

.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
