/* =========================================================
   メモリアルブック 共通スタイル
   色はすべてここ（:root）で管理しています。
   FileMakerでいう「テーマ」に相当します。
   ========================================================= */
:root {
  --c-header: #37474F;        /* ヘッダー（濃いブルーグレー） */
  --c-primary: #546E7A;       /* ボタン（中間のブルーグレー） */
  --c-primary-hover: #455A64; /* ボタンにカーソルを乗せたとき */
  --c-head-row: #CFD8DC;      /* 表の見出し行 */
  --c-border: #B0BEC5;        /* 枠線・区切り線 */
  --c-stripe: #ECEFF1;        /* 一覧の1行おきの背景 */
  --c-hover-row: #E3E8EB;     /* 一覧の行にカーソルを乗せたとき */
  --c-bg: #F5F7F8;            /* 画面の背景 */
  --c-text: #263238;          /* 文字 */
  --c-sub: #607D8B;           /* 補足の文字 */
  --c-danger: #B85450;        /* 削除ボタン */
  --c-danger-hover: #9E4440;
  --c-white: #FFFFFF;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
img { max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .15s;
}
.btn-primary { background: var(--c-primary); color: var(--c-white); }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-secondary { background: var(--c-white); color: var(--c-primary-hover); border-color: var(--c-border); }
.btn-secondary:hover { background: var(--c-stripe); }
.btn-danger { background: var(--c-danger); color: var(--c-white); }
.btn-danger:hover { background: var(--c-danger-hover); }
.btn-header { background: transparent; color: var(--c-white); border-color: rgba(255, 255, 255, .5); min-height: 34px; padding: 4px 12px; }
.btn-header:hover { background: rgba(255, 255, 255, .12); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-link {
  background: none;
  border: none;
  color: var(--c-primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
  font-size: 14px;
}
.btn:focus-visible, .btn-link:focus-visible, input:focus, textarea:focus {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* ---------- 入力欄 ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--c-sub); margin-bottom: 4px; }
.req {
  font-style: normal;
  font-size: 11px;
  color: var(--c-white);
  background: var(--c-sub);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: 1px;
}
input[type="text"], input[type="password"], input[type="search"], input[type="date"], textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: var(--c-white);
  font-size: 16px; /* 16px未満だとiPhoneで入力時に画面が勝手に拡大されるため */
}
input[type="date"] { min-height: 44px; -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; min-height: 260px; line-height: 1.7; }

/* ---------- ヘッダー ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 24px;
  background: var(--c-header);
  color: var(--c-white);
}
.app-title { color: var(--c-white); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: .05em; white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-user { font-size: 13px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ---------- ログイン画面 ---------- */
.page-login { background: linear-gradient(160deg, var(--c-header), var(--c-primary)); }
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--c-white);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 10px 30px rgba(38, 50, 56, .25);
}
.login-title { margin: 0; text-align: center; font-size: 24px; color: var(--c-header); }
.login-sub { margin: 4px 0 24px; text-align: center; color: var(--c-sub); font-size: 13px; }
.error-msg { color: var(--c-danger); font-size: 13px; margin: 0 0 12px; }
.login-help { margin: 20px 0 0; text-align: center; font-size: 13px; }
.login-help a { color: var(--c-primary); }

/* ---------- 説明書ページ ---------- */
.doc { max-width: 860px; }
.doc h1 { margin: 8px 0 24px; font-size: 24px; color: var(--c-header); }
.doc h2 {
  margin: 36px 0 12px;
  padding: 6px 12px;
  font-size: 19px;
  color: var(--c-white);
  background: var(--c-primary);
  border-radius: 6px;
}
.doc h3 {
  margin: 24px 0 8px;
  padding-left: 10px;
  font-size: 16px;
  color: var(--c-header);
  border-left: 4px solid var(--c-primary);
}
.doc p, .doc li { overflow-wrap: anywhere; }
.doc ul, .doc ol { padding-left: 1.5em; }
.doc li { margin: 4px 0; }
.doc a { color: var(--c-primary); }
.doc a.btn { color: var(--c-white); }
.table-wrap { overflow-x: auto; margin: 12px 0; }
.doc table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
}
.doc th, .doc td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--c-stripe); }
.doc tr:last-child th, .doc tr:last-child td { border-bottom: none; }
.doc thead th { background: var(--c-head-row); color: var(--c-header); font-size: 13px; }
.doc tbody th { width: 34%; background: var(--c-bg); color: var(--c-header); font-weight: 600; }
.doc-back { margin-top: 40px; text-align: center; }

/* ---------- 一覧画面（共通） ---------- */
.list-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.search-box { display: flex; gap: 8px; flex: 1; max-width: 560px; }
.search-box input { flex: 1; min-width: 0; }
.list-count { font-size: 13px; color: var(--c-sub); margin: 8px 0; }
.empty-msg {
  text-align: center;
  color: var(--c-sub);
  padding: 40px 16px;
  background: var(--c-white);
  border: 1px dashed var(--c-border);
  border-radius: 8px;
}

/* ---------- 一覧画面（PC用：表形式） ---------- */
.memorial-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
}
.memorial-table th, .memorial-table td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--c-stripe); }
.memorial-table th { background: var(--c-head-row); color: var(--c-header); font-size: 13px; }
.memorial-table tbody tr:last-child td { border-bottom: none; }
.memorial-table tbody tr:nth-child(even) { background: var(--c-stripe); }
.memorial-table tbody tr:hover { background: var(--c-hover-row); }
.col-date { width: 120px; white-space: nowrap; }
.col-file { width: 28%; }
.col-actions { width: 170px; }
.memorial-table th.col-actions, .cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: 6px; }
.cell-title, .cell-file { overflow-wrap: anywhere; }
.text-none { color: var(--c-sub); }

/* ---------- 一覧画面（スマートフォン用：カード形式） ---------- */
.memorial-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-primary);
  border-radius: 8px;
  padding: 14px 16px;
}
.card-date { font-size: 13px; color: var(--c-sub); }
.card-title { font-size: 17px; font-weight: 700; margin: 2px 0 6px; overflow-wrap: anywhere; }
.card-file { font-size: 13px; color: var(--c-sub); overflow-wrap: anywhere; margin: 0 0 12px; }
.card-actions { display: flex; gap: 8px; }
.card-actions .btn { flex: 1; min-height: 44px; }

/* ---------- 詳細画面 ---------- */
.detail-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-title { margin: 0; font-size: 20px; color: var(--c-header); flex: 1; min-width: 0; }
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
.file-panel, .form-panel { background: var(--c-white); border: 1px solid var(--c-border); border-radius: 10px; padding: 20px; min-width: 0; }
.section-title { margin: 0 0 12px; font-size: 15px; color: var(--c-header); }
.file-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  background: var(--c-stripe);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.thumb-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.file-empty { color: var(--c-sub); font-size: 13px; text-align: center; }
.file-icon { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 12px; }
.file-icon-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 88px;
  border-radius: 6px;
  color: var(--c-white);
  font-weight: 700;
  font-size: 16px;
  background: var(--c-primary);
}
/* 種類ごとのアイコン色（ブルーグレーに合わせて彩度を落としています） */
.file-icon-pdf .file-icon-label { background: #A0595A; }
.file-icon-excel .file-icon-label { background: #4E7D5B; }
.file-icon-word .file-icon-label { background: #4A6A9B; }
.file-icon-sub { font-size: 12px; color: var(--c-sub); }
.file-name {
  margin: 0;
  padding: 8px 10px;
  background: var(--c-bg);
  border: 1px solid var(--c-stripe);
  border-radius: 6px;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.file-note { font-size: 12px; color: var(--c-danger); margin: 6px 0 0; }
.file-actions { margin-top: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hint { font-size: 12px; color: var(--c-sub); margin: 4px 0 0; text-align: center; }
.meta { font-size: 12px; color: var(--c-sub); margin: 0; text-align: right; }
.form-panel .field:last-of-type { margin-bottom: 8px; }

/* ---------- 通知（トースト） ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 8px;
  background: var(--c-header);
  color: var(--c-white);
  box-shadow: 0 6px 20px rgba(38, 50, 56, .3);
  white-space: pre-line;
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--c-danger); }

/* ---------- 確認ダイアログ ---------- */
.confirm-dialog {
  border: none;
  border-radius: 12px;
  padding: 24px;
  width: min(420px, calc(100% - 32px));
  color: var(--c-text);
  box-shadow: 0 10px 30px rgba(38, 50, 56, .3);
}
.confirm-dialog::backdrop { background: rgba(38, 50, 56, .5); }
.confirm-msg { margin: 0 0 20px; white-space: pre-line; overflow-wrap: anywhere; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* =========================================================
   PC用 / スマートフォン用 の切り替え
   画面幅767px以下をスマートフォンとして扱います。
   ========================================================= */
.sp-only { display: none; }

@media (max-width: 767px) {
  .pc-only { display: none !important; }
  .sp-only { display: block; }

  .app-header { height: 52px; padding: 0 16px; }
  .app-title { font-size: 16px; }
  .header-user { display: none; }
  .container { padding: 16px; }

  /* 一覧 */
  .list-toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .search-box .btn { padding: 8px 12px; }
  .list-toolbar > .btn { min-height: 48px; }

  /* 詳細 */
  .detail-grid { grid-template-columns: 1fr; gap: 16px; }
  .file-panel, .form-panel { padding: 16px; }
  .sp-detail-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
  .page-detail .container { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  textarea { min-height: 200px; }
  .sp-bottom-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--c-white);
    border-top: 1px solid var(--c-border);
  }
  .sp-bottom-bar .btn { flex: 1; min-height: 48px; }
  .page-detail .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }

  .confirm-actions .btn { flex: 1; }
}
