/* 総務対応管理 共通スタイル。
   シンプル・フラット基調(白背景+薄い罫線、影・装飾なし)。
   アクセントカラーは紫。区分色(労務=紫/経理=ゴールド/総務=グリーン)・優先度色・
   期日の警告色(赤/オレンジ)は識別のため維持。 */

:root {
  --purple: #542494;
  --gold: #CC9401;
  --green: #2DA253;
  --blue: #2D7DD2;
  --orange: #E34601;
  --danger: #C0392B;
  --yellow: #F0C24B;

  --cream: #F6EFDB;
  --surface: #ffffff;
  --border: #e6d9ae;
  --ink: #222222;
  --ink-soft: #6b6b6b;

  --accent: var(--purple);
  --accent-soft: rgba(84, 36, 148, 0.08);
}

body.accent-purple {
  --accent: var(--purple);
  --accent-soft: rgba(84, 36, 148, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Sans", sans-serif;
  color: var(--ink);
  background: var(--cream);
  display: flex;
  justify-content: center;
  padding: 16px 12px 32px;
  font-size: 14px;
}

.screen {
  width: 100%;
  max-width: 1400px;
  background: var(--cream);
  border: none;
  border-radius: 0;
  box-shadow: none;
  position: relative;
}

header.app-header {
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
  box-sizing: border-box;
}
header.app-header img { height: 28px; display: block; }
header.app-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 100%;
  flex-wrap: wrap;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.header-right .who {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.header-right .who:empty { display: none; }

.hbtn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  height: 32px;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.1s ease;
}
.hbtn:active { background: #f0f0f0; }
.hbtn svg { width: 14px; height: 14px; }
.hbtn.is-loading svg { animation: spin 0.8s linear infinite; }
.hbtn-icon-only {
  padding: 0;
  width: 32px;
  justify-content: center;
}
.hbtn-icon-only svg { width: 16px; height: 16px; }

main.app-main {
  padding: 16px 20px 20px;
}

/* ---- 要仕分け見出し ---- */
.rule-box {
  margin-bottom: 20px;
}
.rule-box strong.rule-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}

/* ---- 要仕分けグリッド(PC: 複数列) ---- */
.triage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 10px;
}

/* ---- ツールバー(フィルタ・並び替え・検索・登録ボタン) ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  min-height: 36px;
}
/* toolbar-group は900px以上では contents で親の1行フレックスに溶け込ませ、
   900px未満だけ実体を持つ行として分離する(下部メディアクエリ参照)。 */
.toolbar-group {
  display: contents;
}
.toolbar .tabs {
  flex: 0 0 auto;
  margin-bottom: 0;
}
.toolbar .sort-row {
  flex: 0 0 auto;
  margin-bottom: 0;
}
.toolbar .sort-row select.select-input {
  width: auto;
  min-width: 140px;
  height: 32px;
}
.search-input {
  flex: 1 1 200px;
  min-width: 160px;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  height: 32px;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder { color: var(--ink-soft); opacity: 0.9; }
.toolbar-add-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
}
.toolbar-add-btn svg { width: 14px; height: 14px; }

/* ---- カード/セクション共通 ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: none;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title .leaf {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  flex: none;
}

/* ---- ボタン共通 ---- */
.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8125rem;
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.1s ease, background-color 0.1s ease;
  -webkit-appearance: none;
  appearance: none;
}
.btn:active { opacity: 0.8; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-block { width: 100%; display: flex; }
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}
.btn-ghost {
  background: #fff;
  color: var(--ink-soft);
  border: 1px solid var(--border);
}
.btn-danger-ghost {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-link {
  background: none;
  border: none;
  color: var(--ink-soft);
  text-decoration: underline;
  font-size: 0.75rem;
  padding: 4px 2px;
  cursor: pointer;
  font-weight: 500;
  height: auto;
}
.btn-link:hover { color: var(--purple); }
.btn-sm {
  font-size: 0.6875rem;
  padding: 0 10px;
  height: 28px;
}

.hidden { display: none !important; }

/* ---- タブ(下線式) ---- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
  height: 36px;
}
.tab-btn {
  flex: 0 0 auto;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.8125rem;
  padding: 0 10px;
  height: 36px;
  border-radius: 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn.is-active {
  border-bottom-color: var(--accent);
  color: var(--ink);
  font-weight: 700;
}

.sort-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  height: 32px;
}
.sort-row label {
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 500;
  flex: none;
}
select.select-input {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  flex: 1;
  height: 32px;
  -webkit-appearance: none;
  appearance: none;
}

/* ---- 仕分けカード ---- */
.triage-card {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--yellow);
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 10px;
}
.triage-card:last-child { margin-bottom: 0; }
.item-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.6875rem;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.item-meta-row .src-icon { flex: none; display: flex; align-items: center; }
.item-meta-row-top {
  justify-content: space-between;
  flex-wrap: nowrap;
}
.meta-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.item-title {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--ink);
  margin: 0 0 4px;
  line-height: 1.5;
}
.item-detail {
  font-size: 0.75rem;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 4px;
  overflow: hidden;
}
/* 展開時のみ原文の改行を保持する。省略表示側はJSで改行を空白に正規化済みなので
   white-space:normal のままにし、-webkit-line-clampが確実に効くようにする
   (pre-wrapのまま3行clampすると改行を含む長文で全文表示になってしまう不具合があった)。 */
.item-detail:not(.is-collapsed) {
  white-space: pre-wrap;
}
.item-detail.is-collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.item-detail-original {
  margin-top: 4px;
}
.summary-block {
  background: #FFF6D9;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 0.75rem;
  color: var(--ink);
  line-height: 1.6;
  margin: 0 0 4px;
  white-space: pre-wrap;
}
.summarize-btn {
  flex: none;
  height: 26px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.summarize-btn:active:not(:disabled) { background: var(--cream); }
.summarize-btn:disabled { opacity: 0.6; cursor: default; }
.cell-title-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.cell-title-top .item-title {
  flex: 1;
  min-width: 0;
}
.more-btn {
  background: none;
  border: none;
  color: var(--purple);
  font-weight: 500;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 0;
}

.triage-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.seg-group {
  display: flex;
  gap: 6px;
}
.seg-btn {
  flex: 1;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.75rem;
  padding: 0 6px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}
.seg-btn.is-active-labor {
  border-color: var(--purple);
  background: rgba(84,36,148,0.08);
  color: var(--ink);
  font-weight: 700;
}
.seg-btn.is-active-accounting {
  border-color: var(--gold);
  background: rgba(204,148,1,0.10);
  color: var(--ink);
  font-weight: 700;
}
.seg-btn.is-active-general {
  border-color: var(--green);
  background: rgba(45,162,83,0.08);
  color: var(--ink);
  font-weight: 700;
}
/* 要約AIの区分候補: 点線枠+薄い色で「候補」を示す(自動では選択しない) */
.seg-btn.is-hint-labor {
  border-style: dashed;
  border-color: var(--purple);
  background: rgba(84,36,148,0.05);
}
.seg-btn.is-hint-accounting {
  border-style: dashed;
  border-color: var(--gold);
  background: rgba(204,148,1,0.06);
}
.seg-btn.is-hint-general {
  border-style: dashed;
  border-color: var(--green);
  background: rgba(45,162,83,0.05);
}
.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.field-row label {
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 500;
  flex: none;
  width: 44px;
}
input.text-input, input.date-input, textarea.detail-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  -webkit-appearance: none;
  appearance: none;
  min-height: 36px;
}
input.text-input::placeholder, textarea.detail-input::placeholder { color: var(--ink-soft); opacity: 0.9; }
/* PIN欄はtype="password"だとiOS/Chrome/Edgeの「強力なパスワードを保存」機能が介入し、
   入力した数字と違う文字列で保存・自動入力されて正しく登録・ログインできなくなる不具合が
   実際に発生した(2026-09-07)。type="text"にしつつ、この疑似CSSで見た目だけドット表示にする。 */
#pinInput {
  -webkit-text-security: disc;
  text-security: disc;
}
textarea.detail-input {
  resize: none;
  overflow: hidden;
  min-height: 56px;
  line-height: 1.6;
}
.field-row input.text-input, .field-row input.date-input { flex: 1; min-width: 120px; }

.empty-note {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  padding: 18px 8px;
}

/* ---- タスクカード(900px未満のフォールバック表示) ---- */
.task-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 4px;
  padding: 12px 12px 12px 14px;
  margin-bottom: 10px;
  box-shadow: none;
}
.task-card.due-overdue { border-left-color: var(--danger); }
.task-card.due-soon { border-left-color: var(--orange); }
.task-card:last-child { margin-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 8px;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.badge-labor { background: rgba(84,36,148,0.12); color: var(--purple); }
.badge-accounting { background: rgba(204,148,1,0.16); color: #7a5b00; }
.badge-general { background: rgba(45,162,83,0.14); color: #1d6b3d; }
.badge-uncategorized { background: #eeeeee; color: var(--ink-soft); }

.chip-task {
  display: inline-flex;
  align-items: center;
  height: 20px;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 8px;
  background: rgba(45,162,83,0.14);
  color: #1d6b3d;
}

.due-text {
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  padding: 2px 0;
  color: var(--ink-soft);
}
.due-text.is-overdue { color: var(--danger); font-weight: 700; }
.due-text.is-soon { color: var(--orange); font-weight: 700; }
.due-edit-date {
  margin-top: 4px;
}

.status-badge-progress {
  display: inline-flex;
  align-items: center;
  height: 20px;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 8px;
  background: rgba(45,125,210,0.12);
  color: var(--blue);
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.assignee-text {
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}
.assignee-edit-input {
  min-width: 120px;
}

/* ---- 案件一覧: 表形式(PC) ---- */
.task-table-wrap {
  overflow-x: auto;
}
.task-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
}
.task-table thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.task-table th.col-title { width: auto; }
.task-table th.col-due { width: 150px; }
.task-table th.col-category { width: 90px; }
.task-table th.col-source { width: 50px; }
.task-table th.col-assignee { width: 150px; }
.task-table th.col-sender { width: 200px; }
.task-table th.col-actions { width: 220px; }

/* 一覧の各行は白いカードとして、クリーム地の上に4pxの隙間で並べる */
.task-table tbody tr.task-row td {
  height: 46px;
  padding: 0 10px;
  font-size: 0.8125rem;
  color: var(--ink);
  vertical-align: middle;
  background: #fff;
  border-top: none;
  border-bottom: none;
}
.task-table tbody tr.task-row td:first-child {
  border-left: 3px solid transparent;
  padding-left: 8px;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}
.task-table tbody tr.task-row td:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}
.task-table tbody tr.task-row.due-overdue td:first-child { border-left-color: var(--danger); }
.task-table tbody tr.task-row.due-soon td:first-child { border-left-color: var(--orange); }
.task-table .cell-title .item-title { margin: 0; font-weight: 600; font-size: 0.8125rem; }
.task-table .cell-title .item-detail { font-size: 0.75rem; color: var(--ink-soft); max-width: 480px; margin: 2px 0 0; }
.task-table .cell-title .summary-block { max-width: 480px; }
.task-table .cell-sender { font-size: 0.75rem; color: var(--ink-soft); }
.task-table .cell-actions { white-space: nowrap; }
.task-table .cell-actions .task-actions { margin-top: 0; }
.task-table .empty-row td {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  padding: 20px 8px;
  background: transparent;
  border-bottom: none;
}

/* 900px未満はカード表示にフォールバック(JSは共通、CSSで表示を切替) */
.task-cards-wrap { display: none; }
@media (max-width: 899.98px) {
  .task-table-wrap { display: none; }
  .task-cards-wrap { display: block; }
}

/* ---- トースト ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(34, 34, 34, 0.92);
  color: #fff;
  font-weight: 500;
  font-size: 0.8125rem;
  padding: 10px 20px;
  border-radius: 6px;
  box-shadow: none;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- 電話・メール登録モーダル ---- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.sheet-overlay.hidden { display: none !important; }
.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: none;
  padding: 20px;
  max-height: 88vh;
  overflow-y: auto;
}
.sheet-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sheet h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.modal-close-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close-btn:active { background: #f0f0f0; }
.sheet .field-block { margin-bottom: 12px; }
.sheet .field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.sheet-actions .btn { flex: 1; }

.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
  text-align: center;
  padding: 20px;
  color: var(--ink-soft);
  font-size: 0.8125rem;
}

.gate-wrap {
  padding: 40px 18px;
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}
.gate-wrap h1 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 10px 0 20px;
}
.gate-error {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 10px;
  display: none;
}
.gate-error.is-visible { display: block; }

footer.app-footer {
  text-align: center;
  padding: 14px 18px 2px;
  font-size: 0.6875rem;
  color: var(--ink-soft);
}

/* ---- 設定画面 ---- */
.settings-main {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.settings-desc {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 14px;
}

/* 登録済みルーム一覧(表形式) */
.rooms-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
}
.rooms-table thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
.rooms-table tbody tr.room-row td {
  height: 44px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.rooms-table tbody tr.empty-row td {
  height: auto;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  padding: 16px 8px;
}
.room-name {
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--ink);
  display: block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}
.toggle-switch {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  border: none;
  cursor: pointer;
  flex: none;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: none;
  transition: transform 0.15s ease;
}
.toggle-switch.is-on { background: var(--accent); }
.toggle-switch.is-on::after { transform: translateX(16px); }

.add-room-btn-row {
  background: none;
  border: none;
  text-align: left;
  width: 100%;
  font-family: inherit;
  cursor: pointer;
  padding: 10px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  min-height: 40px;
}
.add-room-btn-row:last-child { border-bottom: none; }
.add-room-btn-row:disabled { cursor: default; opacity: 0.55; }
.add-room-btn-row:active:not(:disabled) { background: var(--cream); }
.registered-tag {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: #eeeeee;
  border-radius: 4px;
  padding: 2px 8px;
  flex: none;
}
.room-type-tag {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: #eeeeee;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
}

@media (max-width: 400px) {
  .field-row label { width: 100%; }
}

/* ---- 900px未満: PC向け横長要素をスマホ向けに畳む ---- */
@media (max-width: 899.98px) {
  .app-header-row { justify-content: center; text-align: center; }
  .header-right { justify-content: center; width: 100%; }
  .triage-grid { grid-template-columns: 1fr; }

  /* ツールバーをタブ行/操作行の2行に分ける。各行はrow方向+align-items:centerのままにして
     検索inputなどが縦方向にstretchされて巨大化する不具合を避ける。 */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
  }
  .toolbar .tabs { width: 100%; }
  .toolbar .sort-row { flex: 1 1 auto; }
  .toolbar .sort-row select.select-input { width: 100%; }
  .toolbar-add-btn { flex: 1 1 auto; justify-content: center; }

  main.app-main { padding: 12px 16px 16px; }
}

.msg-head { font-size: 0.6875rem; font-weight: 700; color: var(--ink-soft); margin: 6px 0 2px; }
.latest-line { font-size: 0.6875rem; color: var(--ink-soft); margin: 0 0 4px; }

.room-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 0.75rem; color: var(--ink-soft); }
.room-strip-label { font-weight: 500; flex: none; }
.room-strip-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.room-chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 8px 0 10px; font-family: inherit; font-size: 0.75rem; color: var(--ink); background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.room-chip.is-off { opacity: 0.55; cursor: pointer; padding: 0 10px; }
.chip-x { background: none; border: none; cursor: pointer; font-family: inherit; font-size: 0.8125rem; color: var(--ink-soft); padding: 0 2px; }
.chip-x.is-confirm { color: var(--danger); font-size: 0.6875rem; font-weight: 700; }
.room-strip-panel { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 12px; max-height: 320px; overflow-y: auto; }
.room-strip-panel .text-input { margin-bottom: 8px; }

.case-no { color: #aaa; font-weight: 500; margin-right: 2px; }
.summary-pending { font-size: 0.6875rem; color: var(--ink-soft); opacity: 0.7; margin: 0 0 4px; }
.summary-block .sum-row { margin: 0 0 3px; }
.summary-block ul { margin: 2px 0 0; padding-left: 1.2em; }
.sum-due { font-weight: 700; }
.sum-due.is-overdue { color: var(--danger); }
.sum-due.is-soon { color: var(--orange); }
.attach-bar { margin-top: 6px; }
.attach-row { font-size: 0.6875rem; color: var(--ink-soft); margin-top: 4px; }

.resolved-reason { font-size: 0.6875rem; color: var(--ink-soft); opacity: 0.7; margin-left: 4px; }
