:root {
  --ink: #202124;
  --sub: #5f6368;
  --line: #e0e3e7;
  --line-strong: #dadce0;
  --bg: #ffffff;
  --bg-soft: #f8f9fa;
  --accent: #1967d2;
  --accent-ink: #174ea6;
  --accent-soft: #d2e3fc;
  --red: #c5221f;
  --sat: #1a56c4;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p, ul, dl, dd, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
ul { list-style: none; }
svg { width: 1em; height: 1em; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { max-width: 480px; margin: 0 auto; }
.screen.cal { height: 100dvh; display: flex; flex-direction: column; position: relative; overflow: hidden; padding-top: env(safe-area-inset-top); }
.loading { padding: 48px 16px; text-align: center; color: var(--sub); }

/* ---- 上のバー ---- */
.bar { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 8px 0 16px; flex-shrink: 0; }
.bar h1 { font-size: 20px; font-weight: 600; }
.bar-actions { display: flex; align-items: center; gap: 2px; }
.pill { height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--bg); font-size: 14px; font-weight: 500; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent; color: var(--sub); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.avatar { width: 36px; height: 36px; margin: 4px; border: 0; border-radius: 18px; color: #fff; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; }

/* ---- 月の格子 ---- */
.weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); height: 24px; align-items: center; text-align: center; font-size: 11px; font-weight: 500; color: var(--sub); flex-shrink: 0; }
.weekdays .sun { color: var(--red); }
.weekdays .sat { color: var(--sat); }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); flex-shrink: 0; }
.cell { position: relative; height: 84px; padding: 4px 2px 0; border: 0; border-top: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; align-items: center; gap: 2px; overflow: hidden; }
.cell.selected { background: #eef3fd; }
.num { width: 24px; height: 24px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; flex-shrink: 0; }
.num.sun { color: var(--red); }
.num.sat { color: var(--sat); }
.num.out { color: #70757a; }
.num.sel { background: var(--accent-soft); color: var(--accent-ink); }
.num.today { background: var(--accent); color: #fff; }
.hol { width: 100%; font-size: 8px; letter-spacing: -0.2px; line-height: 12px; color: var(--red); text-align: center; white-space: nowrap; overflow: hidden; }
.chip { width: 100%; height: 16px; padding: 0 3px; border-radius: 3px; display: flex; align-items: center; gap: 2px; font-size: 10px; line-height: 16px; color: #fff; white-space: nowrap; overflow: hidden; text-align: left; flex-shrink: 0; }
.chip svg { font-size: 10px; stroke-width: 2.6; }
.chip > span { overflow: hidden; }
.chip.hard { font-weight: 700; box-shadow: inset 0 0 0 2px var(--red); }
.more { width: 100%; font-size: 9px; line-height: 11px; color: var(--sub); text-align: left; padding-left: 3px; }
.mark { position: absolute; top: 3px; right: 2px; font-size: 14px; display: flex; }
.mark.hard { color: var(--red); }
.mark.soft { color: #8a5a00; }

/* ---- 選んだ日の予定 ---- */
.agenda { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--line); background: var(--bg-soft); padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.agenda-head { display: flex; align-items: baseline; gap: 8px; }
.agenda-head h2 { font-size: 15px; font-weight: 700; }
.hol-name { font-size: 12px; color: var(--red); }
.empty { font-size: 14px; color: var(--sub); padding: 8px 0; }
.item { display: flex; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); text-align: left; }
.stripe { width: 4px; border-radius: 2px; flex-shrink: 0; }
.item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-title { font-size: 15px; font-weight: 500; }
.item-title.hard { font-weight: 700; color: #8c1d18; }
.item-meta { font-size: 12px; color: var(--sub); }
.item-car { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.item-car svg { font-size: 14px; }
.conf { display: flex; align-items: flex-start; gap: 4px; font-size: 12px; }
.conf svg { font-size: 14px; margin-top: 2px; }
.conf.hard { color: #8c1d18; font-weight: 700; }
.conf.soft { color: #5c3b00; }

.fab { position: absolute; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border: 0; border-radius: 16px; background: var(--accent); color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(32, 33, 36, .3); }

/* ---- シート ---- */
.backdrop { position: fixed; inset: 0; background: rgba(32, 33, 36, .45); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-width: 480px; margin: 0 auto; max-height: calc(100dvh - 24px - env(safe-area-inset-top)); background: var(--bg); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.sheet.form { height: calc(100dvh - 24px - env(safe-area-inset-top)); }
.sheet-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px; padding: 0 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.sheet-bar h2 { font-size: 16px; font-weight: 700; }
.spacer { width: 64px; }
.text-btn { min-width: 64px; height: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--sub); font-size: 15px; }
.text-btn.strong { color: var(--accent-ink); font-weight: 700; }
.save { height: 40px; padding: 0 18px; border: 0; border-radius: 20px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; }
.save:disabled { opacity: .5; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }

/* ---- フォーム部品 ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12px; font-weight: 500; color: var(--sub); }
.label.big { font-size: 16px; color: var(--ink); font-weight: 400; }
.label.with-icon { display: flex; align-items: center; gap: 6px; }
.label.with-icon svg { font-size: 16px; }
input[type=text], input[type=password], input[type=date], input[type=time], textarea {
  width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); font-size: 16px; -webkit-appearance: none; appearance: none;
}
input[type=date], input[type=time] { display: block; text-align: left; }
input:disabled { background: #f1f3f4; color: #70757a; }
textarea { padding: 10px 12px; line-height: 1.5; resize: vertical; }
.field-row { display: flex; align-items: center; justify-content: space-between; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.switch { width: 52px; height: 44px; padding: 7px 0; border: 0; background: transparent; }
.switch span { display: block; width: 52px; height: 30px; border-radius: 15px; background: #80868b; position: relative; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(32, 33, 36, .4); transition: transform .15s; }
.switch.on span { background: var(--accent); }
.switch.on span::after { transform: translateX(22px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.p-chip { min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--bg); display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.p-chip.on { color: #fff; }
.p-chip svg { font-size: 14px; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--bg); }
.seg-btn { height: 44px; border: 0; background: transparent; font-size: 15px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
.seg-btn.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.panel { display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); }
.slot { display: flex; flex-direction: column; gap: 4px; }
.slot-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.slot-time { display: flex; align-items: center; gap: 10px; }
.slot-time input { width: 128px; }
.slot-label { width: 34px; font-size: 15px; font-weight: 700; }
.slot-note { font-size: 12px; color: var(--sub); padding-left: 44px; }
.check { min-height: 44px; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 0; }
.hint { font-size: 12px; color: var(--sub); }
.plain { font-size: 14px; }
.small { font-size: 12px; }
.error { padding: 10px 12px; border: 1px solid var(--red); border-radius: 8px; background: #fce8e6; color: #8c1d18; font-size: 14px; }
.screen.cal > .error { margin: 0 16px 8px; }
.warn { display: flex; gap: 10px; padding: 12px; border-radius: 10px; font-size: 13px; }
.warn svg { font-size: 20px; margin-top: 1px; }
.warn strong { display: block; font-size: 14px; }
.warn ul { margin: 2px 0; }
.warn.hard { background: #fce8e6; color: #8c1d18; border: 1px solid var(--red); }
.warn.soft { background: #fef7e0; color: #5c3b00; border: 1px dashed #8a5a00; }

.btn { min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--bg); font-size: 15px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn.danger-outline { border-color: var(--red); color: #8c1d18; }
.btn.small { min-height: 44px; font-size: 13px; padding: 0 12px; }
.btn:disabled { opacity: .5; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.confirm { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--red); border-radius: 10px; font-size: 14px; }

/* ---- 詳細 ---- */
.d-title { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; }
.dot { width: 14px; height: 14px; border-radius: 7px; flex-shrink: 0; }
.d-list { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px 12px; font-size: 15px; }
.d-list dt { font-size: 12px; color: var(--sub); padding-top: 3px; }
.d-list .memo { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- ログインなど ---- */
.auth, .page { padding: calc(24px + env(safe-area-inset-top)) 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.page { padding-top: 8px; }
.auth h1 { font-size: 22px; font-weight: 700; }
.auth form { display: flex; flex-direction: column; gap: 16px; }
.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw { width: 48px; height: 48px; border-radius: 24px; display: flex; align-items: center; justify-content: center; color: transparent; font-size: 22px; border: 3px solid transparent; }
.swatch input:checked + .sw { color: #fff; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }
.swatch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 6px; }
.swatch.taken .sw { opacity: .3; }
.swatch.taken .sw-name { color: #70757a; }

/* ---- 管理 ---- */
.card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.card h2 { font-size: 16px; font-weight: 700; }
.link-card { border-color: var(--accent); }
.u-list { display: flex; flex-direction: column; gap: 14px; }
.u-row { display: flex; flex-direction: column; gap: 8px; }
.u-main { display: flex; align-items: center; gap: 8px; }
.u-name { font-size: 16px; font-weight: 600; }
.tag { font-size: 11px; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--sub); }
.tag.stop { border-color: var(--red); color: #8c1d18; }
