html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  /* ごく薄い暖色寄りのオフホワイト（白に赤・黄をわずかに足す） */
  background-color: #fdfaf4;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ===== sticky ヘッダー（目次＋保存バー） =====
   モバイルでは下部 sticky/fixed が iOS Safari の下部アドレスバーとズレて隙間が出るため、
   目次・保存バーともに「上部」に固定する。
   PC（>=768px）ではこの問題が無く、長いフォームでも常に押せるよう保存バーだけ画面下部へ固定する
   （下の min-width:768px のメディアクエリ参照）。 */
.trial-stickyhead {
  position: sticky; top: 0; z-index: 1031;
  background: #fff; margin-bottom: .75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  border-bottom: 1px solid #dee2e6;
}
.trial-submitbar {
  background: #fff; border-top: 1px solid #eee;
  padding: .4rem .25rem;
  display: flex; gap: .75rem; align-items: center; justify-content: flex-end;
}
.trial-submitbar .req-ok { color: #198754; }
.trial-submitbar .req-warn { color: #b02a37; font-weight: 600; }
@media (max-width: 767.98px) {
  .trial-submitbar { justify-content: space-between; flex-wrap: wrap; padding: .4rem .5rem; }
}
/* PC表示：保存バーを画面下部に固定（モバイルは上部のまま） */
@media (min-width: 768px) {
  .trial-submitbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1032;
    justify-content: flex-end;
    padding: .55rem 1.25rem;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  }
  /* 固定バーに最終行が隠れないよう、フォーム下に余白を確保 */
  .trial-form { padding-bottom: 4.5rem; }
}

/* 表ヘッダーは1行で（狭幅で1文字ずつ縦折り返しになるのを防ぐ） */
.table thead th { white-space: nowrap; }

/* 行クリックで開く一覧（行全体をクリック可能に） */
tr.js-rowlink { cursor: pointer; }
/* ホバー（＝カーソルが乗っている行）を青系で明示し、クリック可能と分かるようにする。
   ストライプ/期日超過(table-danger)の上でも見えるよう table-hover の色を上書き。 */
.table-hover > tbody > tr.js-rowlink:hover > * {
  --bs-table-bg-state: #d8e9ff;
}

/* ===== 独自の確認ダイアログ（uiConfirm）=====
   ブラウザ標準 confirm() の代替。psearch ドロワーと同じ手作りオーバーレイ方式。
   z-index は psearch(1080) より上に重ねる。 */
.uiconfirm { position: fixed; inset: 0; z-index: 1090; display: flex;
  align-items: center; justify-content: center; padding: 1rem;
  visibility: hidden; }
.uiconfirm.open { visibility: visible; }
.uiconfirm-backdrop { position: absolute; inset: 0;
  background: rgba(17,24,39,.45); opacity: 0; transition: opacity .18s ease; }
.uiconfirm.open .uiconfirm-backdrop { opacity: 1; }
.uiconfirm-panel { position: relative; width: min(440px, 100%);
  background: #fff; border-radius: .75rem; overflow: hidden;
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
  transform: translateY(12px) scale(.98); opacity: 0;
  transition: transform .2s ease, opacity .2s ease; }
.uiconfirm.open .uiconfirm-panel { transform: translateY(0) scale(1); opacity: 1; }
.uiconfirm-body { display: flex; gap: .9rem; padding: 1.25rem 1.25rem 1rem; }
.uiconfirm-icon { flex: 0 0 auto; width: 2.75rem; height: 2.75rem;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.uiconfirm-icon svg { width: 1.5rem; height: 1.5rem; display: block; }
.uiconfirm-title { font-size: 1.05rem; font-weight: 700; margin: .15rem 0 .35rem; }
.uiconfirm-msg { color: #4b5563; font-size: .92rem; line-height: 1.55;
  margin: 0; white-space: pre-line; }
.uiconfirm-foot { display: flex; justify-content: flex-end; gap: .5rem;
  padding: .75rem 1.25rem 1.1rem; }
/* 重大度バリアント（アイコンの配色） */
.uiconfirm-warning .uiconfirm-icon { background: #fef3c7; color: #b45309; }
.uiconfirm-danger  .uiconfirm-icon { background: #fee2e2; color: #b91c1c; }
.uiconfirm-info    .uiconfirm-icon { background: #dbeafe; color: #1d4ed8; }
@media (max-width: 575.98px) {
  .uiconfirm-panel { width: 100%; }
  .uiconfirm-foot .btn { flex: 1 1 0; }
}

/* ===== モバイル最適化（スマホ縦） ===== */
@media (max-width: 575.98px) {
  /* iOS のフォーカス時ズーム防止＋タッチしやすさ（最低16px） */
  .form-control, .form-select,
  .form-control-sm, .form-select-sm { font-size: 16px; min-height: 40px; }
  /* ボタンのタップ領域を確保 */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; padding-left: .6rem; padding-right: .6rem; }
  /* 表は横スクロールで慣性スクロール */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  /* 見出し・余白を引き締め */
  h1.h3, h1.h4 { font-size: 1.25rem; }
  .card-body { padding: .75rem; }
  /* チェックは指で押しやすく */
  .form-check-input { width: 1.2em; height: 1.2em; }
}

/* ===== アプリ枠：左端を上下に貫く共通サイドレール ＋ 本体 ===== */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; }
.app-rail { flex: 0 0 56px; width: 56px; background: #f3f3f1; border-right: 1px solid #e5e7eb; }
.app-rail-inner { position: sticky; top: 0; display: flex; flex-direction: column; gap: .5rem;
  padding: .6rem .4rem; align-items: center; }
.app-body { flex: 1 1 auto; min-width: 0; }
.view-nav-item { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; color: #9aa0a6; background: #fff; border: 1px solid #e5e7eb; text-decoration: none;
  transition: background-color .12s, color .12s, border-color .12s; }
.view-nav-item:hover { background: #f1f3f5; color: #6b7280; }
.view-nav-item.active { background: #4f6ef7; border-color: #4f6ef7; color: #fff; }
.view-nav-item svg { width: 22px; height: 22px; display: block; }
@media (max-width: 767.98px) {
  /* モバイルは上部の横並びレールに */
  .app-shell { flex-direction: column; }
  .app-rail { flex: 0 0 auto; width: 100%; border-right: 0; border-bottom: 1px solid #e5e7eb; }
  .app-rail-inner { position: static; flex-direction: row; padding: .4rem .5rem; }
}

/* ===== 期間ビュー共通：ステータス→バー/チップ配色 ===== */
.vbar-trying,    .vchip-trying    { background: #e8edfb; border: 1px solid #b9c6f3; color: #3a4fb5; }
.vbar-approval,  .vchip-approval  { background: #fdf3d6; border: 1px solid #f0d99a; color: #9a7b1a; }
.vbar-post,      .vchip-post      { background: #efe9fb; border: 1px solid #d6c8f3; color: #6b46c1; }
.vbar-plan,      .vchip-plan      { background: #f3f4f6; border: 1px dashed #cbd5e1; color: #6b7280; }
.vbar-done,      .vchip-done      { background: #e2f3e9; border: 1px solid #b6dcc4; color: #2e7d50; }
.vbar-returned,  .vchip-returned  { background: #fdeaea; border: 1px solid #f3c2c2; color: #c0392b; }
.vbar-cancelled, .vchip-cancelled { background: #f1f3f5; border: 1px solid #dde1e6; color: #9aa0a6; text-decoration: line-through; }

/* ===== ガント（月・行＝トライ／列＝日。PCは1画面フィット、スマホは横スクロール） ===== */
.gantt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gantt { position: relative; border: 1px solid #e5e7eb; border-radius: .5rem; overflow: hidden; background: #fff; }
/* 列テンプレートはページ側（#ganttGrid）で当月の日数に合わせて上書きする */
.gantt-head-row, .gantt-row { display: grid; grid-template-columns: 190px repeat(7, minmax(0, 1fr)); }
.gantt-head-row { background: #f8f9fa; border-bottom: 1px solid #e5e7eb; }
.gantt-head-row > div { padding: .4rem .25rem; font-size: .78rem; color: #6c757d; font-weight: 600; }
.gantt-head-row .g-dayhead { text-align: center; overflow: hidden; }
.gantt-head-row .g-dayhead .g-wd { display: block; font-size: .62rem; font-weight: 500; line-height: 1; }
.gantt-head-row .g-dayhead.today { color: #dc3545; font-weight: 700; }
.gantt-head-row .g-dayhead.weekend { color: #adb5bd; }
.gantt-row { border-bottom: 1px solid #f0f1f3; }
.gantt-row:hover { background: #fcfdff; }

/* 今日を縦断する赤いライン。グリッドの外側（.gantt 直下）に絶対配置で1本だけ引き、
   上端から下端まで連続させる。left はラベル幅＋日列内の今日位置を calc で算出。 */
.g-today-line { position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 2px solid #dc3545; z-index: 3; pointer-events: none; }
.g-today-legend { display: inline-block; width: 0; height: .9rem; border-left: 2px solid #dc3545;
  vertical-align: middle; margin-right: .15rem; }
.gantt-row .g-label { grid-column: 1; padding: .35rem .5rem; display: flex; flex-direction: column;
  justify-content: center; font-size: .82rem; color: #1f2937; }
.gantt-row .g-label .g-kanri { font-family: ui-monospace, Consolas, monospace; }
.gantt-row .g-label .g-sub { color: #6c757d; font-size: .74rem; }
.gantt-row .g-day { border-left: 1px solid #f3f4f6; min-height: 2.7rem; grid-row: 1; }
.gantt-row .g-day.weekend { background: #fcfcfa; }
.gantt-row .vbar { grid-row: 1; align-self: center; margin: .3rem .25rem; padding: .22rem .55rem;
  border-radius: .35rem; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-decoration: none; z-index: 1; }
.gantt-warn { color: #c0392b; font-size: .85rem; padding: .5rem .6rem 0; }

/* ===== カレンダー（月・実施日ビュー） ===== */
.cal { border: 1px solid #e5e7eb; border-radius: .5rem; overflow: hidden; background: #fff; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head > div { padding: .3rem .5rem; font-size: .78rem; color: #6c757d; background: #f8f9fa;
  border-bottom: 1px solid #e5e7eb; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); min-height: 5.6rem; }
.cal-bg { border-left: 1px solid #f0f1f3; border-bottom: 1px solid #f0f1f3; }
.cal-week .cal-bg:first-child { border-left: 0; }
.cal-bg.other { background: #fafafa; }
.cal-bg.today { outline: 2px solid #0d6efd; outline-offset: -2px; }
.cal-daynum2 { grid-row: 1; font-size: .78rem; color: #6b7280; padding: .18rem .4rem; pointer-events: none; }
.cal-daynum2.other { color: #c0c4cc; }
.cal-daynum2.today { color: #0d6efd; font-weight: 700; }
.cal-bar { align-self: center; height: 1.15rem; line-height: 1.15rem; margin: 0 3px; padding: 0 .4rem;
  border-radius: .3rem; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-decoration: none; z-index: 1; }
@media (max-width: 575.98px) {
  .cal-week { min-height: 3.6rem; }
  .gantt-head-row, .gantt-row { grid-template-columns: 120px repeat(7, minmax(0, 1fr)); }
}