/* ===== HBQ Calendar UI ===== */
.cal-app { height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }

/* --- トップバー --- */
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .icon-btn {
  appearance: none; border: none; background: transparent; cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--text);
}
.topbar .icon-btn:hover { background: var(--surface-alt); }
.period-title { font-weight: 700; font-size: 17px; min-width: 110px; }
.period-title .yr { color: var(--text-muted); font-weight: 400; font-size: 13px; margin-right: 4px; }
.topbar-spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-alt); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { appearance: none; border: none; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); font-weight: 600; }

/* --- クイック入力バー --- */
.quickbar { display: flex; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.quickbar input { flex: 1; }
.quick-hint { font-size: 11px; color: var(--text-muted); padding: 0 12px 6px; background: var(--surface); border-bottom: 1px solid var(--border); }

/* --- 本体 --- */
.cal-main { flex: 1; overflow: auto; position: relative; -webkit-overflow-scrolling: touch; }

/* 月グリッド */
.month-grid { display: flex; flex-direction: column; height: 100%; }
.month-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); background: var(--surface); }
.month-dow div { text-align: center; font-size: 11px; color: var(--text-muted); padding: 6px 0; }
.month-dow .sun { color: #c0756b; } .month-dow .sat { color: #6b86c0; }
.month-weeks { flex: 1; display: grid; grid-auto-rows: 1fr; }
.week-row { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.day-cell { border-right: 1px solid var(--border); padding: 2px 3px; overflow: hidden; min-height: 0; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.day-cell:last-child { border-right: none; }
.day-cell.other { background: #faf7f1; }
.day-num { font-size: 12px; color: var(--text-muted); align-self: flex-start; padding: 1px 5px; border-radius: 10px; }
.day-cell.today .day-num { background: var(--hbq-honey-gold); color: #fff; font-weight: 700; }
.day-cell .sun { color: #c0756b; } .day-cell .sat { color: #6b86c0; }
.ev-chip {
  font-size: 11px; line-height: 1.3; padding: 1px 5px; border-radius: 4px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid rgba(0,0,0,.15);
}
.ev-chip.allday { font-weight: 600; }
.ev-more { font-size: 10px; color: var(--text-muted); padding-left: 4px; }

/* アジェンダ（予定リスト） */
.agenda { padding: 8px 0 80px; max-width: 760px; margin: 0 auto; }
.agenda-day { display: flex; gap: 10px; padding: 8px 14px; }
.agenda-date { flex: 0 0 56px; text-align: center; }
.agenda-date .d { font-size: 22px; font-weight: 700; line-height: 1; }
.agenda-date .w { font-size: 11px; color: var(--text-muted); }
.agenda-date.today .d { color: var(--hbq-honey-gold); }
.agenda-date.sun .d { color: #c0756b; } .agenda-date.sat .d { color: #6b86c0; }
.agenda-list { flex: 1; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.agenda-ev { display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; background: var(--surface); border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm); cursor: pointer; }
.agenda-ev .t { flex: 0 0 48px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.agenda-ev .ti { flex: 1; font-size: 14px; font-weight: 500; }
.agenda-ev .loc { font-size: 11px; color: var(--text-muted); }
.agenda-empty { text-align: center; color: var(--text-muted); font-size: 13px; padding: 40px 0; }
.ev-dim { opacity: .5; }
.cat-tag { font-size: 10px; padding: 0 5px; border-radius: 8px; background: var(--surface-alt); color: var(--text-muted); }

/* 週タイムグリッド */
.week-wrap { display: flex; flex-direction: column; height: 100%; }
.week-head { display: grid; grid-template-columns: 46px repeat(7, 1fr); border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 2; }
.week-head div { text-align: center; font-size: 11px; padding: 6px 0; color: var(--text-muted); }
.week-head .wd-today { color: var(--hbq-honey-gold); font-weight: 700; }
.week-body { flex: 1; overflow: auto; }
.week-grid { display: grid; grid-template-columns: 46px repeat(7, 1fr); position: relative; }
.hour-col { grid-column: 1; }
.hour-row { height: 44px; border-bottom: 1px solid var(--border); font-size: 10px; color: var(--text-muted); text-align: right; padding-right: 4px; }
.week-col { position: relative; border-right: 1px solid var(--border); }
.week-col .cell { height: 44px; border-bottom: 1px solid var(--border); }
.week-ev { position: absolute; left: 2px; right: 2px; border-radius: 4px; color: #fff; font-size: 11px; padding: 2px 4px; overflow: hidden; border-left: 3px solid rgba(0,0,0,.15); cursor: pointer; }

/* --- FAB --- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 56px; height: 56px;
  border-radius: 50%; background: var(--primary); color: #fff; border: none; font-size: 28px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(39,32,26,.25); display: grid; place-items: center; z-index: 30;
}

/* --- サイドシート（カレンダー一覧） --- */
.scrim { position: fixed; inset: 0; background: rgba(39,32,26,.4); z-index: 40; }
.sheet-left {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(84vw, 320px); background: var(--surface); z-index: 50;
  box-shadow: var(--shadow-soft); display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 0;
}
.sheet-head { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sheet-head .me { font-weight: 700; } .sheet-head .sub { font-size: 12px; color: var(--text-muted); }
.sheet-body { flex: 1; overflow: auto; padding: 8px 0; }
.cal-group-title { font-size: 11px; color: var(--text-muted); padding: 10px 16px 4px; }
.cal-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; cursor: pointer; }
.cal-row:hover { background: var(--surface-alt); }
.cal-check { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--c, #999); display: grid; place-items: center; flex: 0 0 auto; }
.cal-check.on { background: var(--c, #999); }
.cal-check.on::after { content: "✓"; color: #fff; font-size: 12px; }
.cal-name { flex: 1; font-size: 14px; }
.cal-badge { font-size: 10px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 8px; padding: 0 5px; }
.cal-dim-toggle { font-size: 11px; color: var(--text-muted); cursor: pointer; }
.sheet-foot { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }

/* --- モーダル --- */
.modal-scrim { position: fixed; inset: 0; background: rgba(39,32,26,.45); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 440px; max-height: 90dvh; overflow: auto;
  box-shadow: var(--shadow-soft); padding: 18px;
}
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal .inline { display: flex; align-items: center; gap: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal-actions .spacer { flex: 1; }
.att-list { display: flex; flex-wrap: wrap; gap: 6px; }
.att-chip { font-size: 12px; border: 1px solid var(--border); border-radius: 14px; padding: 4px 10px; cursor: pointer; background: var(--surface); }
.att-chip.on { background: var(--primary-soft); border-color: var(--primary); }
.scope-opts { display: flex; flex-direction: column; gap: 8px; }
.scope-opt { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; }
.scope-opt.on { border-color: var(--primary); background: var(--primary-soft); }
.scope-opt .cnt { font-size: 12px; color: var(--text-muted); }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--hbq-ink); color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 13px; z-index: 80; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: .95; }

@media (min-width: 760px) {
  .agenda { padding-bottom: 24px; }
}
