:root {
  color-scheme: light;
  --slot-h: 26px;        /* 時間割の1コマ(15分)の高さ */
  --bg: #f3f4f6;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1d4ed8;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", "Yu Gothic UI", sans-serif; background: var(--bg); color: var(--text); font-size: 15px; -webkit-text-size-adjust: 100%; }
body.noScroll { overflow: hidden; }
button { font-family: inherit; }

.container { max-width: 960px; margin: 0 auto; padding: 10px 10px calc(16px + env(safe-area-inset-bottom)); }

/* ---------- 上の帯 ---------- */
.topbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.titleBlock { min-width: 0; }
.company { font-size: 11px; color: var(--muted); }
.topbar h1 { font-size: 19px; margin: 0; line-height: 1.2; }
.topActions { margin-left: auto; display: flex; gap: 6px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.badgeTest { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.badgeAdmin { background: #1f2937; color: #fff; }
.testBanner { background: #fef2f2; color: #b91c1c; border: 2px solid #f87171; border-radius: 10px; padding: 8px 10px; font-weight: 700; font-size: 13px; margin-bottom: 10px; }

/* ---------- 部品 ---------- */
.btn { min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid #d1d5db; background: #fff; color: var(--text); cursor: pointer; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.btn.danger { background: #fff; color: var(--danger); border-color: #fca5a5; font-weight: 700; }
#confirmYes.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.wide { width: 100%; margin-top: 12px; }
.btnSmall { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.btnIcon { min-width: 44px; padding: 4px 8px; }
.card { background: #fff; border-radius: 14px; padding: 12px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card h2 { font-size: 17px; margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.errorText { color: var(--danger); margin-top: 10px; font-weight: 700; white-space: pre-wrap; }
.errorBanner { background: #fef2f2; color: var(--danger); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-weight: 700; }
.warnBanner { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 13px; }
.loading { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.hidden { display: none !important; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; min-width: 0; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid #d1d5db; font-size: 16px; background: #fff; color: var(--text); font-family: inherit; }
.field textarea { min-height: 60px; resize: vertical; }
.req { display: inline-block; background: var(--danger); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: middle; }
.checkLabel { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid #d1d5db; background: #fff; font-size: 14px; cursor: pointer; }
.tab.active { background: #1f2937; color: #fff; border-color: #1f2937; }

/* ---------- 月表示 ---------- */
.calHeader { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.calTitle { font-weight: 700; font-size: 18px; flex: 1; text-align: center; }
.calSubHeader { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.legendItem { display: inline-flex; align-items: center; gap: 4px; }
.legendDot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

.calGrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.calWeekday { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.calWeekday.sun, .calDayNum.sun { color: #dc2626; }
.calWeekday.sat, .calDayNum.sat { color: #2563eb; }
.calCell { min-width: 0; min-height: 76px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; text-align: left; display: flex; flex-direction: column; gap: 2px; cursor: pointer; font: inherit; color: inherit; overflow: hidden; }
.calCell:active { background: #eff6ff; }
.calCell.today { border: 2px solid var(--primary); }
.calCellEmpty { background: transparent; border: none; cursor: default; }
.calDayNum { font-size: 12px; font-weight: 700; color: #374151; padding-left: 2px; }
.chip { min-width: 0; color: #fff; font-size: 10px; line-height: 1.35; border-radius: 4px; padding: 1px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chipCancelled { text-decoration: line-through; opacity: .85; }
.chipUser { display: none; }
.calMore { font-size: 10px; color: var(--muted); padding-left: 2px; }

/* ---------- その日の時間割 ---------- */
.dayOverlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.35); display: flex; justify-content: center; align-items: stretch; }
.dayPanel { background: #fff; width: 100%; max-width: 720px; display: flex; flex-direction: column; min-height: 0; }
.dayHeader { display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.dayTitle { flex: 1; text-align: center; font-weight: 700; font-size: 17px; min-width: 0; }
.dayHint { font-size: 12px; color: var(--muted); padding: 6px 10px; }
.dayScroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 8px calc(12px + env(safe-area-inset-bottom)); min-height: 0; }
.dayGrid { display: grid; column-gap: 4px; position: relative; }
.dayCorner { position: sticky; top: 0; background: #fff; z-index: 3; grid-row: 1; grid-column: 1; }
.dayCarHeader { position: sticky; top: 0; z-index: 3; grid-row: 1; color: #fff; font-weight: 700; font-size: 14px; text-align: center; padding: 8px 4px; border-radius: 8px 8px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.timeLabel { font-size: 11px; color: var(--muted); text-align: right; padding-right: 4px; transform: translateY(-7px); }
.timeLabelFirst { transform: none; }
.slot { border-top: 1px dotted #e5e7eb; background: #fff; min-width: 0; }
.slot.hourStart { border-top: 1px solid #cbd5e1; }
.slotFree { border-left: 0; border-right: 0; border-bottom: 0; padding: 0 6px; text-align: left; font-size: 10px; color: #cbd5e1; cursor: pointer; font-family: inherit; }
.slotFree:hover, .slotFree:focus-visible { background: #eff6ff; color: var(--primary); outline: none; }
.slotFree:active { background: #dbeafe; }
.block { z-index: 2; margin: 1px 0; border: none; border-radius: 8px; color: #fff; text-align: left; padding: 3px 6px; overflow: hidden; cursor: pointer; font-family: inherit; min-width: 0; box-shadow: 0 1px 2px rgba(0,0,0,.2); display: flex; flex-direction: column; justify-content: flex-start; }
.blockTime { font-size: 11px; font-weight: 700; line-height: 1.3; }
.blockUser { font-size: 13px; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blockDest { font-size: 11px; line-height: 1.3; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- モーダル ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal-content { background: #fff; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
.modal-content h3 { margin: 0 0 12px; font-size: 18px; }
#confirmModal { z-index: 400; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.modal-actions .spacer { flex: 1; }
.confirmText { white-space: pre-wrap; background: #f9fafb; border-radius: 10px; padding: 10px; margin: 0; }
.formGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.formGrid .full { grid-column: 1 / -1; }

.toast { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 500; max-width: 92vw; text-align: center; }

/* ---------- 一覧(本部) ---------- */
.bookingList { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.listItem { display: flex; align-items: stretch; gap: 8px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; font: inherit; color: inherit; cursor: pointer; min-width: 0; }
.listCancelled { cursor: default; background: #f9fafb; color: var(--muted); }
.listCancelled .listLine1, .listCancelled .listLine2 { text-decoration: line-through; }
.listBar { width: 6px; border-radius: 3px; flex: none; }
.listMain { flex: 1; min-width: 0; }
.listLine1 { font-weight: 700; font-size: 14px; }
.listLine2 { font-size: 13px; color: #4b5563; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tagCancelled { align-self: center; font-size: 11px; background: #e5e7eb; color: #374151; padding: 2px 8px; border-radius: 999px; }

/* ---------- 全画面(CSSの疑似全画面。100vw/100vhは使わない) ---------- */
#app.app-fullscreen { position: fixed; inset: 0; z-index: 100; max-width: none; margin: 0; background: var(--bg); overflow: auto; }
:fullscreen #app { max-width: none; }

/* ---------- 広い画面 ---------- */
@media (min-width: 640px) {
  .container { padding: 16px; }
  .calCell { min-height: 96px; padding: 4px; }
  .chip { font-size: 11px; }
  .chipUser { display: inline; }
  .modal-overlay { align-items: center; padding: 16px; }
  .modal-content { border-radius: 16px; }
  .dayOverlay { padding: 16px; align-items: center; }
  .dayPanel { border-radius: 16px; max-height: 100%; overflow: hidden; }
  :root { --slot-h: 22px; }
}
