/* トンマナ：株式会社トーアミ コーポレートサイト準拠
   白ベース / ネイビー #2A2F88 / アクセントレッド #DC2525 / Noto Sans JP / 英字見出し＋日本語サブ */
:root {
  --navy: #2a2f88;
  --navy-soft: #7578b2;
  --navy-tint: #eceef8;
  --red: #dc2525;
  --bg: #ffffff;
  --bg-sub: #f6f7fb;
  --text: #333333;
  --muted: #6e6e6e;
  --line: #d4d4d4;
  --line-soft: #eeeeee;
  --busy: #e6e6e6;
  --busy-ink: #a5a5a5;
  --ok: #2a2f88;
  --radius: 6px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
/* ダブルタップでの拡大を止める（ピンチでの拡大はできる） */
html { touch-action: manipulation; }
body {
  background: var(--bg-sub); color: var(--text);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "游ゴシック", YuGothic, Meiryo, sans-serif;
  font-size: 16px; line-height: 1.7; -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select { font: inherit; color: inherit; }
/* iPhone は 16px 未満の入力欄を触ると画面を拡大するので、入力欄は常に 16px */
input, select, textarea { font-size: 16px !important; }

/* ---------- ヘッダー ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid var(--line-soft); box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.topbar-inner {
  max-width: 1120px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-sub { font-size: .62rem; font-weight: 700; letter-spacing: .08em; color: var(--navy-soft); line-height: 1.2; }
.brand-title { font-size: 1.05rem; font-weight: 900; color: #222; line-height: 1.3; white-space: nowrap; }
.pill-badge {
  flex: 0 0 auto; background: var(--navy); color: #fff; border-radius: 999px;
  padding: 6px 16px; font-size: .82rem; font-weight: 700; white-space: nowrap;
}
.demo-bar { display: block; text-align: center; background: #fff4e0; color: #8a5a00; font-size: .78rem; padding: 4px 16px; }
.demo-bar[hidden] { display: none; }
@media (max-width: 420px) {
  .brand-title { font-size: .95rem; }
  .pill-badge { padding: 4px 10px; font-size: .72rem; }
}

main { max-width: 1120px; margin: 0 auto; padding: 8px 16px 48px; }

/* ---------- 見出し（英字＋日本語） ---------- */
.section-title { text-align: center; margin: 22px 0 18px; }
.section-title h1 {
  margin: 0; color: var(--navy); font-weight: 900; letter-spacing: -.01em; line-height: 1.1;
  font-size: clamp(1.7rem, 5vw, 2.5rem); font-family: "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
}
.section-title p { margin: 4px 0 0; color: var(--muted); font-weight: 700; letter-spacing: .2em; font-size: .9rem; }
.section-title::after { content: ""; display: block; width: 48px; height: 3px; background: var(--red); margin: 12px auto 0; }

/* ---------- ログイン ---------- */
.login { min-height: 72vh; display: grid; place-items: center; }
.login-card {
  width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 8px 24px 28px; text-align: center; display: grid; gap: 14px; box-shadow: 0 6px 24px rgba(42,47,136,.06);
}
.login-card .section-title { margin-bottom: 4px; }
.login-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.login-card input { text-align: center; }

input, select {
  width: 100%; padding: 11px 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; min-height: 48px;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%), linear-gradient(135deg, var(--navy) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input:focus, select:focus { outline: 2px solid var(--navy); outline-offset: 0; border-color: var(--navy); }

.btn { border: 0; border-radius: 999px; padding: 12px 22px; min-height: 48px; font-weight: 700; cursor: pointer; transition: opacity .15s, background .15s; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { opacity: .88; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: var(--red); color: #fff; }
.btn:disabled { opacity: .5; cursor: progress; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: .82rem; cursor: pointer; padding: 6px 0; }
.link-btn:hover { color: var(--navy); }

/* ---------- 日付タブ（トーアミのグローバルナビ風：区切り線＋赤い下線） ---------- */
.toolbar { display: flex; gap: 12px; align-items: stretch; margin: 0 0 12px; background: #fff; border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px; }
.days { display: flex; overflow-x: auto; flex: 1; scrollbar-width: thin; }
.day {
  position: relative; flex: 0 0 auto; min-width: 62px; border: 0; border-left: 1px solid var(--line-soft); background: transparent;
  padding: 6px 8px 10px; text-align: center; cursor: pointer; line-height: 1.2;
}
.day:first-child { border-left: 0; }
.day .w { display: block; font-size: .64rem; font-weight: 700; letter-spacing: .04em; color: var(--navy-soft); }
.day .d { display: block; font-size: 1.15rem; font-weight: 700; color: #222; }
.day.sat .w { color: #3a62c9; } .day.sun .w { color: var(--red); }
.day::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 2px; height: 3px; background: transparent; }
.day[aria-selected="true"] .d { color: var(--navy); }
.day[aria-selected="true"]::after { background: var(--red); }
.day:hover .d { color: var(--navy); }
.date-pick { flex: 0 0 auto; display: grid; align-content: center; font-size: .66rem; font-weight: 700; color: var(--navy-soft); width: 140px; border-left: 1px solid var(--line-soft); padding-left: 12px; }
.date-pick input { min-height: 40px; padding: 4px 8px; }
@media (max-width: 560px) {
  .toolbar { flex-direction: column; gap: 6px; }
  .date-pick { width: 100%; border-left: 0; padding-left: 0; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
}

.status-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); }
.sw.free { background: #fff; border-color: var(--navy-soft); }
.sw.busy { background: var(--busy); border-color: var(--busy); }
.sw.toami { background: var(--navy); border-color: var(--navy); }
.hint { margin: 4px 0 14px; font-size: .85rem; color: var(--muted); }

/* ---------- タイムテーブル（縦：時間 / 横：会議室） ----------
   縦スクロールはページ全体、横スクロールは .tt-scroll だけ（縦横が同時に動かない）。
   会議室名の行 .tt-headwrap はヘッダーの下に固定し、横スクロールは app.js で同期する */
.tt {
  --time-w: 56px; --col-min: 84px; /* 84px: タブレット（768px）でも 8 部屋が収まる */ --col-w: minmax(var(--col-min), 1fr);
  background: #fff; border: 1px solid var(--line-soft); border-radius: 10px;
}
.tt-sticky { position: sticky; top: var(--topbar-h, 0px); z-index: 5; background: #fff; border-radius: 10px 10px 0 0; }
.tt-headwrap { overflow: hidden; border-radius: 10px 10px 0 0; }
/* スマホ用の部屋切替バー */
.tt-pager { display: flex; align-items: center; gap: 8px; padding: 6px 6px 4px; border-bottom: 1px solid var(--line-soft); }
.tt-pager button {
  flex: 0 0 auto; width: 44px; height: 36px; border-radius: 999px; border: 1px solid var(--navy); background: var(--navy); color: #fff;
  font-size: 1.3rem; font-weight: 700; line-height: 1; cursor: pointer; padding: 0 0 3px;
}
.tt-pager button:disabled { background: #fff; color: var(--line); border-color: var(--line); cursor: default; }
.pg-label { flex: 1; text-align: center; font-size: .82rem; font-weight: 700; color: var(--navy); line-height: 1.3; }
.pg-label b { font-size: 1rem; }
.pg-label small { display: block; font-size: .64rem; font-weight: 500; color: var(--muted); }
.tt-scroll { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.timetable, .tt-head { min-width: calc(var(--time-w) + var(--cols) * var(--col-min)); }
.tt-head {
  display: grid; grid-template-columns: var(--time-w) repeat(var(--cols), var(--col-w));
  background: #fff; border-bottom: 2px solid var(--navy);
}
.tt-corner { position: sticky; left: 0; background: #fff; z-index: 1; }
.tt-room { padding: 8px 6px 7px; text-align: center; border-left: 1px solid var(--line-soft); line-height: 1.3; display: grid; justify-items: center; gap: 2px; }
.tt-room strong { font-size: .92rem; font-weight: 900; color: #222; }
.tt-room small { font-size: .7rem; color: var(--muted); }
.st { font-size: .66rem; font-weight: 700; border-radius: 999px; padding: 0 8px; }
.st.busy { background: #fde8e8; color: var(--red); }
.st.off { background: #f0f0f0; color: var(--muted); }

.tt-body { display: grid; grid-template-columns: var(--time-w) 1fr; }
.tt-times { position: sticky; left: 0; z-index: 3; background: #fff; border-right: 1px solid var(--line-soft); }
.tt-time { height: var(--row); position: relative; }
.tt-time span { position: absolute; top: -.6em; right: 8px; font-size: .78rem; font-weight: 700; color: #444; font-variant-numeric: tabular-nums; background: #fff; line-height: 1.2; }
.tt-time.half span { font-size: .66rem; font-weight: 400; color: #a5a5a5; }
.tt-time:first-child span { top: 2px; }

.tt-cols { position: relative; display: grid; grid-template-columns: repeat(var(--cols), var(--col-w)); }
.tt-col { position: relative; border-left: 1px solid var(--line-soft); height: calc(var(--row) * var(--rows, 24)); }
.tt-cell {
  position: absolute; left: 0; right: 0; height: var(--row); border: 0; border-top: 1px solid var(--line-soft);
  background: transparent; cursor: pointer; padding: 0; color: transparent; font-size: .74rem; font-weight: 700;
}
.tt-cell.half { border-top: 1px dashed #f1f1f1; }
.tt-cell:not(:disabled):hover, .tt-cell:not(:disabled):focus-visible { background: var(--navy-tint); color: var(--navy); outline: none; }
.tt-cell:disabled { cursor: default; }
.tt-cell.past { background: repeating-linear-gradient(135deg, #fafafa 0 6px, #f3f3f3 6px 12px); }
@media (hover: none) { .tt-cell:not(:disabled) span { display: none; } }

.tt-block {
  position: absolute; left: 4px; right: 4px; z-index: 2; border-radius: 5px; padding: 3px 6px; overflow: hidden;
  display: flex; flex-direction: column; gap: 0; text-align: left; line-height: 1.3; font-size: .74rem; border: 0;
}
.tt-block b { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .7rem; }
.tt-block span { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-block small { font-size: .68rem; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-block.busy { background: var(--busy); color: #8a8a8a; }
.tt-block.busy span { font-weight: 500; }
.tt-block.toami { background: var(--navy); color: #fff; cursor: pointer; box-shadow: 0 2px 6px rgba(42,47,136,.25); }
.tt-block.toami:hover { opacity: .92; }

.tt-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--red); z-index: 3; pointer-events: none; }
.tt-now::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.tt-now span { position: absolute; right: 4px; top: -18px; font-size: .64rem; font-weight: 700; color: #fff; background: var(--red); border-radius: 3px; padding: 0 4px; }

@media (max-width: 560px) {
  /* スマホは 1 画面に 4 部屋。横に動かすと部屋の区切りで止まる */
  /* --tt-w は app.js が #rooms の実際の幅を入れる（100vw だとスクロールバーの幅まで含んでしまう）。2px は枠線 */
  .tt { --time-w: 44px; --col-min: calc((var(--tt-w, calc(100vw - 32px)) - 2px - var(--time-w)) / 4); border-radius: 8px; }
  .tt-scroll { scroll-snap-type: x mandatory; scroll-padding-left: var(--time-w); }
  .tt-col { scroll-snap-align: start; }
  .tt-room { padding: 6px 2px; }
  .tt-room strong { font-size: .74rem; line-height: 1.25; word-break: break-all; }
  .tt-block { left: 2px; right: 2px; padding: 3px 4px; }
  .tt-block b { white-space: normal; line-height: 1.2; } /* 時刻は「09:00〜 / 10:00」と 2 行に折り返す */
  .section-title { margin: 14px 0 12px; }
  .section-title h1 { font-size: 1.5rem; }
  .section-title::after { margin-top: 8px; }
  .hint { display: none; }
}

.empty { color: var(--muted); text-align: center; padding: 30px 0; grid-column: 1 / -1; }
.error { color: var(--red); font-size: .88rem; margin: 0; min-height: 1em; }
.error.center { text-align: center; margin-top: 16px; }

/* ---------- ダイアログ ---------- */
dialog.sheet {
  border: 0; padding: 0; border-radius: 12px; width: min(480px, calc(100% - 24px));
  background: #fff; color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); border-top: 5px solid var(--navy);
}
dialog.sheet::backdrop { background: rgba(20, 24, 70, .45); }
dialog.sheet form { padding: 20px 20px 22px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font-size: 1.2rem; font-weight: 900; color: #222; }
.sheet-sub { margin: -10px 0 0; color: var(--navy); font-weight: 700; font-size: .92rem; }
dialog label { display: grid; gap: 4px; font-size: .82rem; font-weight: 700; color: #444; }
.req { justify-self: start; display: inline-block; font-size: .68rem; color: #fff; background: var(--red); border-radius: 3px; padding: 0 5px; margin-left: 6px; font-weight: 700; }
.row { display: flex; align-items: end; gap: 8px; }
.row label { flex: 1; }
.tilde { padding-bottom: 12px; color: var(--muted); }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.actions .btn { flex: 1 1 140px; }
.detail { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.detail dt { color: var(--muted); font-size: .82rem; }
.detail dd { margin: 0; font-weight: 700; }
@media (max-width: 560px) {
  dialog.sheet { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 14px 14px 0 0; }
  dialog.sheet form { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: #222; color: #fff; padding: 12px 20px; border-radius: 999px; font-size: .9rem; font-weight: 700;
  transition: all .25s ease; pointer-events: none; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--navy); }
