/* 三原面談 予約ページ — ネイティブアプリ調 (ナビゲーションバー / セル / 8px グリッド / 単一アクセント) */
:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-2: #767676;
  --text-3: #a3a3a3;
  --line: #e6e6e6;
  --accent: #2b3a8f;
  --accent-soft: #eef1fa;
  --accent-line: #c9d1ee;
  --full-bg: #f0f0f0;
  --full-text: #9a9a9a;
  --danger: #e5322d;
  --danger-soft: #fdeceb;
  --success: #1e9e5a;
  --success-soft: #e9f7ef;
  --sat: #2f80ed;
  --sun: #e5322d;
  --line-green: #06c755;
  --nav-h: 48px;
  --hour-px: 192px;   /* 15分 = 48px */
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Roboto, "Segoe UI", Meiryo, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
a { color: var(--accent); }

/* ナビゲーションバー */
.nav { position: sticky; top: 0; z-index: 10; height: var(--nav-h); display: flex; align-items: center; justify-content: center; background: var(--surface); border-bottom: 1px solid var(--line); }
.nav h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: .01em; }
.nav-back { position: absolute; left: 4px; top: 0; height: var(--nav-h); width: 44px; border: none; background: none; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* 本体 */
.app { max-width: 1000px; margin: 0 auto; background: var(--surface); min-height: calc(100vh - var(--nav-h)); padding-bottom: 32px; }
.band { height: 8px; background: var(--bg); }
.pad { padding: 16px; }
.state { padding: 40px 16px; text-align: center; color: var(--text-2); font-size: 14px; }
.hint, .help { font-size: 12px; color: var(--text-2); margin: 8px 16px 0; }
.help.center { text-align: center; margin: 12px 0 0; }
.alert { margin: 16px; padding: 12px 14px; background: var(--danger-soft); color: var(--danger); border-radius: var(--radius); font-size: 14px; white-space: pre-line; }

/* 読み込み中 (スケルトン) */
.loading { padding: 20px 16px 28px; }
.sk { display: block; position: relative; overflow: hidden; background: #ececec; border-radius: 6px; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); animation: sk-shimmer 1.4s ease-in-out infinite; }
.sk-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sk-title { width: 120px; height: 18px; }
.sk-toggle { width: 96px; height: 32px; border-radius: 8px; }
.sk-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px 6px; }
.sk-day { height: 14px; }
.sk-cell { height: 44px; }
.sk-cell.tall { height: 64px; }
.loading-text { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 24px; font-size: 13px; color: var(--text-2); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes sk-shimmer { 100% { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* セル (ラベル + 内容) */
.cell { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.cell:last-child { border-bottom: none; }
.cell-label { flex: 0 0 96px; font-size: 13px; color: var(--text-2); }
.cell-body { flex: 1; min-width: 0; font-size: 15px; word-break: break-all; }
.cell.summary .cell-body { font-weight: 600; }
.select-wrap { position: relative; }
/* 表示はテキスト (長い名前は折り返す)、タップは上に重ねた透明な select が受ける */
.select-face { font-size: 15px; color: var(--text); padding: 6px 28px 6px 0; line-height: 1.4; min-height: 22px; }
.select-wrap select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font: inherit; font-size: 16px; cursor: pointer; }
.select-wrap::after { content: ""; position: absolute; right: 6px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
/* メニュー欄: スマホでは見出しの下に全幅で表示 */
.cell.menu { flex-wrap: wrap; align-items: flex-start; }
.cell.menu .cell-label { padding-top: 8px; }
.cell.menu .cell-body { flex: 1 1 220px; }
@media (max-width: 640px) {
  .cell.menu { flex-direction: column; align-items: stretch; gap: 4px; padding-top: 10px; padding-bottom: 10px; min-height: 0; }
  .cell.menu .cell-label { flex: none; padding-top: 0; font-size: 12px; }
  .cell.menu .cell-body { flex: none; }   /* 縦並びでは flex-basis が高さになるため無効化 (大きな空白の原因) */
  .select-face { padding: 9px 34px 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
  .select-wrap::after { right: 14px; }
}
}
.select-wrap::after { content: ""; position: absolute; right: 6px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: translateY(-70%) rotate(45deg); pointer-events: none; }

/* セクション見出し・切替 */
.sec-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 16px 8px; }
.sec-head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.view-toggle { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 2px; }
.view-toggle button { font: inherit; font-size: 13px; padding: 6px 16px; border: none; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; }
.view-toggle button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.range-nav { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 8px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.nav-btn { width: 40px; height: 40px; border: none; background: none; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 20px; }
.nav-btn:hover { background: var(--bg); }
.nav-btn:disabled { color: var(--line); cursor: default; background: none; }
.legend { display: flex; gap: 16px; padding: 0 16px 8px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.mark { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.mark.open { background: var(--accent-soft); border: 1px solid var(--accent-line); }
.mark.full { background: var(--full-bg); border: 1px solid #dcdcdc; }

/* タイムテーブル */
.tt-scroll { overflow: auto; max-height: 640px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.tt { display: grid; min-width: 100%; --time-w: 56px; --col-min: 96px; }
.tt-head, .tt-body { grid-template-columns: var(--time-w) repeat(var(--cols, 7), minmax(var(--col-min), 1fr)); }
.tt-head { display: grid; position: sticky; top: 0; z-index: 3; background: var(--surface); }
.tt-corner, .tt-day { height: 44px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text-2); }
.tt-day.sat { color: var(--sat); }
.tt-day.sun { color: var(--sun); }
.tt-day.today { color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.tt-body { display: grid; position: relative; }
.tt-times { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--line); }
.tt-time { position: absolute; right: 8px; transform: translateY(-50%); font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tt-time.first { transform: none; top: 4px !important; }
.tt-col { position: relative; border-right: 1px solid var(--line); }
.tt-col:last-child { border-right: none; }
.tt-hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.tt-half-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #efefef; }
.slot { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 4px 8px; font: inherit; font-size: 12px; line-height: 1.3; text-align: left; overflow: hidden; }
.slot .t { display: block; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.slot .m { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.open { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent); cursor: pointer; }
.slot.open:hover { background: #e3e8f7; }
.slot.open:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.slot.selected, .slot.selected:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.slot.full { background: var(--full-bg); border: 1px solid #e3e3e3; color: var(--full-text); cursor: default; }
.slot.full .m::before { content: "満 "; }
.slot.blocked { background: #fafafa; border: 1px dashed #dcdcdc; color: var(--text-3); cursor: default; }
.slot.blocked .m::before { content: "× "; }
.mark.blocked { background: #fafafa; border: 1px dashed #cfcfcf; }

/* フォーム */
.field { padding: 14px 16px 0; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.req { color: var(--danger); font-size: 11px; margin-left: 2px; }
.opt { color: var(--text-3); font-size: 11px; margin-left: 2px; }
input[type=text], input[type=email], input[type=tel], textarea {
  width: 100%; height: 48px; padding: 0 12px; border: 1px solid #d9d9d9; border-radius: var(--radius); font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
}
textarea { height: auto; min-height: 120px; padding: 12px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(43,58,143,.12); }
.field .help { margin: 6px 0 0; }
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; width: 0; }
.cta { position: sticky; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); margin-top: 20px; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(6px); }
/* 入力中 (キーボード表示中) は固定を解除して入力欄を隠さない */
body.typing .cta { position: static; border-top: none; background: none; backdrop-filter: none; }
html { scroll-padding-bottom: 120px; }
.field input, .field textarea { scroll-margin-bottom: 120px; }

/* ボタン */
.btn { display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; border: none; border-radius: 26px; font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #24317a; }
.btn.primary:disabled { background: #b9c0dc; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.btn.line { background: var(--line-green); color: #fff; }
.btn.line:hover { background: #05b34c; }

/* 完了 */
.done-head { padding: 32px 16px 24px; text-align: center; }
.done-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--success-soft); color: var(--success); margin-bottom: 12px; }
.done-head h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.done-head p { margin: 0; font-size: 14px; color: var(--text-2); }
.lead { margin: 0 0 12px; font-size: 14px; color: var(--text-2); }
.qr { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 4px 0 14px; }
.qr-code { padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.qr-code img, .qr-code canvas { display: block; }
.menu-desc { margin: 6px 0 0; font-size: 12px; color: var(--text-2); }
.quick { margin: 20px 16px 0; padding: 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-align: center; }
.quick-lead { margin: 0 0 10px; font-size: 13px; color: var(--text-2); }
.quick .btn { max-width: 360px; margin: 0 auto; }
.quick-when { display: block; margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--text); }
footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 24px 16px 0; }

/* PC */
@media (min-width: 641px) {
  :root { --nav-h: 56px; }
  .nav h1 { font-size: 17px; }
  .app { margin: 24px auto; min-height: 0; border-radius: 12px; border: 1px solid var(--line); overflow: hidden; }
  .cta { position: static; border-top: none; background: none; backdrop-filter: none; padding: 24px 16px 8px; }
  .cta .btn { max-width: 360px; margin: 0 auto; }
  #lineBox .btn { max-width: 360px; margin: 0 auto; }
  .tt-corner, .tt-day { font-size: 14px; }
}
@media (max-width: 640px) {
  :root { --hour-px: 160px; }   /* 15分 = 40px */
  .cta .help { display: none; }          /* 固定バーは薄く */
  body.typing .cta .help { display: block; }
  .tt { --time-w: 44px; --col-min: 0px; }
  /* 直近枠ボタン: スマホは画面下に固定バー */
  .quick { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; margin: 0; border: none; border-top: 1px solid var(--line); border-radius: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); backdrop-filter: blur(6px);
    display: flex; align-items: center; gap: 12px; text-align: left; box-shadow: 0 -4px 16px rgba(0,0,0,.05); }
  .quick-lead { flex: 1; min-width: 0; margin: 0; font-size: 11px; color: var(--text-2); }
  .quick-when { display: block; margin: 2px 0 0; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .quick .btn { flex: 0 0 auto; width: auto; height: 44px; padding: 0 16px; margin: 0; font-size: 14px; border-radius: 22px; }
  body.has-quick .app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  #stepDate .hint { margin-bottom: 8px; }
  .tt-scroll { max-height: 62vh; }
  .tt-corner, .tt-day { height: 40px; font-size: 11px; }
  .tt-time { font-size: 11px; right: 4px; }
  .slot { left: 2px; right: 2px; padding: 3px 2px; border-radius: 4px; text-align: center; }
  .slot .t { font-size: 11px; }
  .slot .m { display: none; }
  .slot.full .t::before { content: "満 "; font-size: 10px; }
  .slot.blocked .t::before { content: "× "; font-size: 10px; }
  .range-nav { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .sk::after, .spinner { animation: none !important; } }
