/* 回覧はんこポン — 素の CSS（フレームワーク無し, §7） */

:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --line: #dfe2e6;
  --text: #2b2f33;
  --muted: #7a828a;
  --accent: #b7282e; /* 朱肉色 */
  --accent-soft: #fbeaea;
  --link: #1a5fb4;
  --chip-unread: #1a5fb4;
  --chip-stamp: #b7282e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Yu Gothic UI", "Meiryo UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

#zoom-root { height: 100%; }
#app { height: 100%; display: flex; flex-direction: column; }

/* 文字サイズ調整（A−／A＋）。#zoom-root の外に固定配置し、拡大しても動かない・
   大きさも変わらない。押すたびに画面全体（#zoom-root）の倍率が変わる。 */
#font-controls {
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 95; /* 通常UIより前、モーダル(100)より後ろ */
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
}
#font-controls .font-btn {
  padding: 3px 10px;
  font-weight: 700;
  line-height: 1.2;
  border-radius: 999px;
}

/* どのページからでもTOPへ戻れる固定ボタン（迷った人の安心用）。拡大の外＝body 直下。 */
#home-button {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 95; /* 通常UIより前、モーダル(100)より後ろ */
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  background: #fff;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}
#home-button:hover { background: var(--accent-soft); }
#home-button[hidden] { display: none; }

button {
  font: inherit;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
button:hover { background: #f6f7f8; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: #99181e; }
button.linklike {
  border: none;
  background: none;
  color: var(--link);
  padding: 2px 4px;
}
button:disabled { opacity: 0.5; cursor: default; }

input[type="text"], select {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  width: 100%;
}

/* ---- 共通レイアウト ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
}
.topbar .spacer { flex: 1; }

/* ログイン名義（共有PCで取り違えないよう、はっきり出す） */
.topbar .me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
}
.topbar .me .me-label { font-size: 11px; color: var(--muted); }
.topbar .me .me-name { font-weight: 700; color: var(--accent); }

/* 自分の発出タブの進捗文（例: 7月14日発の文書が 8/10 押印されています） */
.doc-mine-status { color: var(--accent); font-size: 12px; margin-top: 3px; font-weight: 600; }

.content {
  flex: 1;
  overflow: auto;
  padding: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

.error-banner {
  background: #fdeaea;
  border: 1px solid #eab6b6;
  color: #8c1d1d;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  white-space: pre-wrap;
}

/* ストレージ状態バナー（軸2）。最上部に常設。正常時は緑・簡潔、異常時は黄/赤 */
#storage-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  font-size: 13px;
  color: #fff;
}
#storage-banner[hidden] { display: none; }
#storage-banner[data-severity="ok"] { background: #2f7d4f; padding: 5px 16px; }
#storage-banner[data-severity="warn"] { background: #b26a00; }
#storage-banner[data-severity="error"] { background: #b00020; }
#storage-banner[data-severity="info"] { background: #4a5158; }
#storage-banner .sb-body { flex: 1; min-width: 0; }
#storage-banner .sb-headline { font-weight: 600; }
#storage-banner .sb-error { margin-top: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
#storage-banner .sb-detail { margin-top: 2px; }
#storage-banner .sb-path {
  margin-top: 2px;
  opacity: 0.85;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}
#storage-banner .sb-retry {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  border-radius: 6px;
  padding: 4px 12px;
  flex: none;
  align-self: flex-start;
}
#storage-banner .sb-retry:hover { background: rgba(255, 255, 255, 0.3); }
#storage-banner .sb-retry:disabled { opacity: 0.6; }

/* 設定: 既存ストアが無かったときの新規作成の確認 */
.setup-create-note {
  margin-top: 10px;
  padding: 12px 14px;
  background: #fff7e6;
  border: 1px solid #e8c98a;
  border-radius: 8px;
}
.setup-create-note .hint { margin: 4px 0 10px; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 0;
}

h1 { font-size: 18px; margin: 0 0 14px; }
h2 { font-size: 15px; margin: 0 0 10px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }

/* ---- 一覧 ---- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}
.tabs button {
  border-radius: 999px;
  padding: 6px 16px;
}
.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tabs .count {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  opacity: 0.85;
}

.doc-list { display: flex; flex-direction: column; gap: 10px; }

.doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
}
.doc-row:hover { border-color: var(--accent); }
.doc-row .doc-main { flex: 1; min-width: 0; }
.doc-row .doc-title { font-weight: 600; font-size: 15px; }
.doc-row .doc-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.doc-row .progress { color: var(--muted); white-space: nowrap; }
.doc-row .progress b { color: var(--text); }

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 6px;
  vertical-align: 2px;
}
.chip.unread { background: var(--chip-unread); }
.chip.needs-stamp { background: var(--chip-stamp); }
.chip.complete { background: #2b8a3e; }

/* ---- 起案フォーム ---- */

.compose-form { max-width: 720px; }

/* 書庫の段階選択（ドリルダウン）。段が増えたら折り返す */
.shelf-cascade { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.shelf-cascade select { min-width: 140px; }

/* 格納先クイック選択チップ（#7） */
.shelf-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.shelf-presets .presets-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.chip-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  background: #fff;
}
.chip-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-btn .preset-tag {
  font-size: 10px;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.chip-btn.active .preset-tag { background: rgba(255, 255, 255, 0.25); color: #fff; }

.dept-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.dept-toolbar .dept-count { color: var(--muted); font-size: 12px; }

.dept-group { margin-bottom: 8px; }
.dept-group .group-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.dept-group .group-toggle { font-size: 12px; }
/* 起案画面: スタッフ個別押印の部署に付く小さな印（#9） */
.mode-tag {
  font-size: 10px;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: 1px;
}
.dept-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.dept-checks label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
  cursor: pointer;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }

.att-list { list-style: none; margin: 10px 0 0; padding: 0; }
.att-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 6px;
  background: #fafbfc;
}
.att-list .att-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---- 文書ビュー ---- */

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.kairanhyo { margin-bottom: 16px; }
.stamp-grid { display: flex; flex-wrap: wrap; gap: 10px; }

/* スタッフ個別押印の部署グループ（#9）。外側 stamp-grid の中で1行を占有する */
.staff-dept {
  flex-basis: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfd;
}
.staff-dept-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.staff-dept-head .staff-dept-name { font-weight: 600; font-size: 13px; }
.staff-dept-head .staff-dept-count { font-size: 12px; color: var(--muted); }
.staff-members { gap: 8px; }
.stamp-cell {
  width: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  background: #fafbfc;
}
.stamp-cell .dept-name {
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.stamp-cell .route-del-check { flex: none; cursor: pointer; }
.stamp-cell .stamp-slot {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stamp-cell .empty-circle {
  width: 56px;
  height: 56px;
  border: 2px dashed var(--line);
  border-radius: 50%;
}
.stamp-cell .stamped-by { font-size: 11px; color: var(--muted); margin-top: 4px; }

.att-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafbfc;
}
.att-entry .att-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-entry .rev-tag { font-size: 11px; color: var(--muted); }
.old-revs { margin: -2px 0 8px 12px; font-size: 12px; }
.old-revs li { margin: 2px 0; }

.preview-pane {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #6b6f73;
  min-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.preview-pane embed { width: 100%; height: 620px; border: none; }
.preview-pane img { max-width: 100%; max-height: 620px; display: block; }
.preview-pane .placeholder { color: #e6e8ea; }

/* 添付行の「拡大」ボタン（目立つよう朱色の太字）。
   button.linklike の色指定に勝つよう、こちらも button 付きで詳細度を揃える。 */
button.att-enlarge { font-size: 13px; color: var(--accent); font-weight: 700; margin-left: 10px; }

/* 画面いっぱいの拡大表示（§5.2 プレビュー拡大） */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 150; /* モーダル(100)より前面 */
  background: rgba(20, 22, 24, 0.92);
  display: flex;
  flex-direction: column;
}
.preview-overlay-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  color: #fff;
}
.preview-overlay-title {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-overlay-body {
  flex: 1;
  min-height: 0;
  margin: 0 16px 16px;
  background: #6b6f73;
  border-radius: 8px;
  overflow: hidden;
  /* embed を絶対配置で inset:0 させ、確定サイズの枠を与える（小プレビューと同じ
     考え方）。flex 中央寄せ＋height:100% だと PDFium が灰色化することがある。 */
  position: relative;
}
.preview-overlay-body embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.preview-overlay-body img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
}

/* ---- タイムライン ---- */

.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item {
  border-left: 3px solid var(--line);
  padding: 2px 0 2px 12px;
}
.tl-item.tl-stamp { border-left-color: var(--accent); }
.tl-item.tl-cancel { border-left-color: #e67700; }
.tl-item.tl-comment { border-left-color: var(--link); }
.tl-item.tl-revision { border-left-color: #2b8a3e; }
.tl-head { font-size: 12px; color: var(--muted); }
.tl-head b { color: var(--text); }
.tl-body { margin-top: 3px; white-space: pre-wrap; }
.tl-comment .tl-body {
  background: #eef4fb;
  border-radius: 0 10px 10px 10px;
  padding: 8px 12px;
}
.tl-corrupt { color: var(--muted); font-style: italic; }

/* ---- 文書への操作（ステップ3） ---- */

.stamp-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
  background: #fff;
  padding: 0;
}
.stamp-button:hover { background: var(--accent-soft); }

.cancel-link { font-size: 11px; color: var(--muted); }
.cancel-link:hover { color: var(--accent); }

.route-toggle { font-size: 12px; font-weight: 400; margin-left: 10px; }
.route-del-bar { margin-top: 12px; gap: 10px; }
.route-del-all { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.route-editor { margin-top: 12px; max-width: 360px; }
.confirm-list { margin: 6px 0 0; padding-left: 20px; line-height: 1.7; }
.kairanhyo-meta { margin-bottom: 10px; color: var(--muted); }

.complete-note {
  background: #e7f3e9;
  border: 1px solid #b7dcbd;
  color: #205b28;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-weight: 600;
}

.timeline-card { display: flex; flex-direction: column; }
.timeline { flex: 1; overflow-y: auto; max-height: 60vh; }

.tl-comment.mine { border-left-color: #2b8a3e; }
.tl-comment.mine .tl-body {
  background: #e7f6e9;
  border-radius: 10px 0 10px 10px;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: flex-end;
}
.comment-input {
  flex: 1;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}

/* ---- 書庫（ステップ6） ---- */

.shelf-tree { display: flex; flex-direction: column; gap: 8px; }
.shelf-node {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.shelf-node > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
}
.shelf-node .shelf-count { color: var(--muted); font-weight: 400; font-size: 12px; }
.shelf-children {
  padding: 2px 12px 10px 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shelf-children .shelf-node { background: #fafbfc; }
.archived-row { padding: 10px 14px; }

.archived-note {
  background: #eef4fb;
  border: 1px solid #bcd3ee;
  color: #1d4e89;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.kairanhyo-pdf embed {
  width: 100%;
  height: 640px;
  border: none;
  border-radius: 8px;
}

/* ---- マスタ編集（ステップ7） ---- */

.masters-card { max-width: 760px; }
.master-fieldset { border: 0; margin: 0; padding: 0; min-inline-size: 0; }
.master-fieldset:disabled { opacity: 0.6; }
.master-table { width: 100%; border-collapse: collapse; }
.master-table th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
}
.master-table td { padding: 6px 8px; vertical-align: middle; }
.master-table tr:not(.add-row):hover { background: #fafbfc; }
.master-table input[type="text"], .master-table select { width: 100%; }
.master-table .id-col { width: 128px; }
.master-table .id-col code {
  font-size: 12px;
  color: var(--muted);
  background: #f2f3f5;
  padding: 2px 6px;
  border-radius: 4px;
}
.master-table .add-row td { padding-top: 10px; }
.del-link { color: var(--muted); }
.del-link:hover { color: var(--accent); }
.dirty-dot { color: #e67700; margin-left: 6px; font-size: 10px; vertical-align: 1px; }
.masters-hint { align-self: center; }
.masters-link { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }

/* ---- モーダル ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 32, 34, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 20px 22px;
  min-width: 360px;
  max-width: 520px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-body { margin: 12px 0 16px; }
.modal-body p { margin: 0; line-height: 1.7; }

/* ---- トースト（完了通知） ---- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 200; /* モーダル(100)より前面 */
  pointer-events: none;
}
.toast {
  min-width: 160px;
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #2b8a3e; }
.toast-info { background: #1a5fb4; }
.toast-error { background: var(--accent); }

/* ---- 設定 ---- */

.setup-card { max-width: 560px; margin: 40px auto; }
.setup-note { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ==== ブラウザデモ（サンプル版）専用の追加スタイル ============================
   本体（Electron 版）には無い、デモの注意書きバナー用。styles.css は自己ホスト
   なので CSP（style-src 'self'）に抵触せずインラインの <style> を避けられる。 */
#demo-notice {
  background: #b45309;
  color: #ffffff;
  text-align: center;
  font-size: 13px;
  font-weight: bold;
  padding: 6px 12px;
  line-height: 1.5;
}

/* プレビュー非対象（Word/Excel 等）をクリックしたときの案内（プレビュー枠内） */
.preview-doc-note { color: #eef1f4; text-align: center; padding: 24px; line-height: 1.7; }
.preview-doc-note-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.preview-doc-note-file { font-size: 14px; color: #ffd98a; margin-bottom: 8px; word-break: break-all; }
.preview-doc-note-sub { font-size: 12px; color: #c7ccd1; }
