/* 認定調査票 特記事項入力フォーム */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", "Yu Gothic", sans-serif;
  font-size: 16px;
  background: #ffffff;
  color: #222;
  margin: 0;
  padding: 0;
}

/* ============================
   ページヘッダー
============================ */
.page-header {
  background: #f8f8f8;
  border-bottom: 1px solid #ddd;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-header h1 {
  font-size: 18px;
  margin: 0 0 10px 0;
  color: #333;
}

/* ヘッダー操作行 */
.header-actions {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.header-actions .sheet-picker {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.btn-create-new {
  padding: 8px 20px;
  background: #388e3c;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  height: 36px;
}

.btn-create-new:hover {
  background: #2e7d32;
}

.btn-generate-pdf {
  padding: 8px 20px;
  background: #1565c0;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  height: 36px;
}

.btn-generate-pdf:hover:not(:disabled) {
  background: #0d47a1;
}

.btn-generate-pdf:disabled {
  background: #90a4ae;
  cursor: default;
}

.load-status {
  font-size: 13px;
  color: #555;
  align-self: center;
}

/* 編集中バナー */
.editing-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  margin-top: 8px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #5d4037;
}

#editing-banner-text {
  flex: 1;
}

.btn-copy-create {
  padding: 4px 12px;
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-copy-create:hover {
  background: #1565c0;
}

.btn-copy-create:disabled {
  background: #90caf9;
  cursor: not-allowed;
}

/* 新規作成モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-dialog {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  width: 380px;
  max-width: 90vw;
  animation: modalFadeIn 0.15s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  color: #333;
}

.btn-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.btn-modal-close:hover {
  color: #333;
}

.modal-note {
  padding: 8px 20px 0;
  font-size: 13px;
  color: #1565c0;
  background: #e3f2fd;
  margin: 10px 20px 0;
  border-radius: 4px;
  padding: 8px 12px;
}

.modal-body {
  padding: 16px 20px;
}

.modal-body label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
}

.modal-input:focus {
  outline: 2px solid #1976d2;
  border-color: #1976d2;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 16px;
}

.btn-modal-cancel {
  padding: 8px 18px;
  background: #eee;
  color: #555;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.btn-modal-cancel:hover {
  background: #ddd;
}

.btn-modal-submit {
  padding: 8px 20px;
  background: #388e3c;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-modal-submit:hover {
  background: #2e7d32;
}

.btn-modal-submit:disabled {
  background: #a5d6a7;
  cursor: not-allowed;
}

/* ============================
   シート選択ピッカー
============================ */
.sheet-picker {
  margin-bottom: 10px;
}

.sheet-picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.sheet-picker-header label {
  font-size: 14px;
  color: #555;
  white-space: nowrap;
}

.sheet-search-input {
  flex: 1;
  max-width: 240px;
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
}

.btn-refresh {
  padding: 4px 10px;
  background: #eee;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  color: #555;
  line-height: 1;
}

.btn-refresh:hover {
  background: #ddd;
}

.sheet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px 0;
}

.sheet-list-loading,
.sheet-list-empty,
.sheet-list-error {
  font-size: 13px;
  color: #999;
  padding: 6px 0;
}

.sheet-list-error {
  color: #c62828;
}

.sheet-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: #333;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.sheet-list-item:hover {
  background: #e3f2fd;
  border-color: #90caf9;
}

.sheet-list-item.active {
  background: #1976d2;
  border-color: #1976d2;
  color: #fff;
}

.sheet-item-name {
  font-weight: 600;
}

.sheet-item-date {
  font-size: 12px;
  color: #888;
}

.sheet-list-item.active .sheet-item-date {
  color: rgba(255, 255, 255, 0.8);
}

/* 削除ボタン（×） */
.sheet-item-delete {
  margin-left: 4px;
  font-size: 14px;
  font-weight: bold;
  color: #bbb;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
  opacity: 0;
}

.sheet-list-item:hover .sheet-item-delete {
  opacity: 1;
}

.sheet-item-delete:hover {
  color: #c62828;
  background: rgba(198, 40, 40, 0.1);
}

.sheet-list-item.active .sheet-item-delete {
  color: rgba(255, 255, 255, 0.6);
}

.sheet-list-item.active .sheet-item-delete:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

/* ============================
   ヘッダー入力欄
============================ */
.header-input-section {
  padding: 8px 16px 10px;
  background: #f0f4ff;
  border-bottom: 1px solid #c5cae9;
}

.header-input-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: flex-end;
}

/* ごった煮メモ（雑記）＋振り分けボタンだけをスクロール中も上部固定する。
   main-content（縦に長いスクロール領域）の直下に置き、position:sticky で
   .page-header(z-index:100) の直下＝top:var(--sticky-header-height) に貼り付く。
   各調査項目より前面(z-index:50)。占有面積は最小（textarea rows=2 +
   max-height + 内部スクロール）。左右の負マージンで main-content の padding を
   打ち消し、固定バーの背景・下境界線を列幅いっぱいに敷く。 */
.zatsumemo-sticky {
  position: sticky;
  top: var(--sticky-header-height, 60px);
  z-index: 50;
  background: #f0f4ff;
  border-bottom: 1px solid #c5cae9;
  margin: -16px -20px 12px;   /* main-content の padding(16px 20px) を打ち消す */
  padding: 8px 20px;
}

.zatsumemo-sticky .zatsumemo-textarea {
  height: auto;
  max-height: 4.5em;          /* 占有面積を最小化。超過分は内部スクロール */
  overflow-y: auto;
  resize: vertical;
  line-height: 1.4;
}

.zatsumemo-sticky-item {
  gap: 2px;
}

@media (max-width: 768px) {
  /* タブレット以下は main-content の padding が 12px。負マージンを合わせる */
  .zatsumemo-sticky {
    margin: -12px -12px 10px;
    padding: 8px 12px;
  }
}

.header-input-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 130px;
}

.header-input-item label {
  font-size: 11px;
  color: #555;
  font-weight: 600;
}

.hdr-input {
  padding: 5px 9px;
  border: 1px solid #aab;
  border-radius: 5px;
  font-size: 14px;
  background: #fff;
  height: 32px;
}

.hdr-input:focus {
  outline: 2px solid #3f51b5;
  border-color: #3f51b5;
}

.header-input-org label {
  font-size: 11px;
  color: #555;
  font-weight: 600;
}

.hdr-org-name {
  font-size: 13px;
  color: #999;
  line-height: 32px;
}

@media (max-width: 600px) {
  .header-input-grid {
    gap: 8px 12px;
  }
  .header-input-item {
    min-width: calc(50% - 6px);
  }
  .header-input-org {
    min-width: 100%;
  }
}

/* ============================
   2カラムレイアウト
============================ */
.app-layout {
  display: flex;
  align-items: flex-start;
}

.side-nav {
  width: 220px;
  min-width: 220px;
  position: sticky;
  top: var(--sticky-header-height, 60px); /* JS で動的更新 */
  height: calc(100vh - var(--sticky-header-height, 60px));
  overflow-y: auto;
  border-right: 1px solid #e0e0e0;
  background: #fafafa;
  padding: 8px 0;
  flex-shrink: 0;
  z-index: 10;
}

/* ============================
   メインコンテンツ
============================ */
.main-content {
  flex: 1;
  padding: 16px 20px;
  min-width: 0;
  max-width: 900px;
}

/* ============================
   群ヘッダー
============================ */
.group-header {
  background: #FFF3E0;
  border-left: 4px solid #FF8F00;
  padding: 8px 14px;
  font-weight: bold;
  font-size: 15px;
  margin: 24px 0 4px 0;
  border-radius: 0 4px 4px 0;
  color: #5D4037;
}

/* ============================
   調査項目カード
============================ */
.survey-item {
  border-bottom: 1px solid #e8e8e8;
  padding: 14px 4px;
  scroll-margin-top: var(--sticky-header-height, 80px);
}

.survey-item:last-child {
  border-bottom: none;
}

.item-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.item-id {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
}

.item-name {
  font-weight: bold;
  font-size: 16px;
}

.save-indicator {
  font-size: 12px;
  margin-left: auto;
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}

.save-indicator.saving {
  color: #888;
}

.save-indicator.saved {
  color: #388e3c;
}

.save-indicator.error {
  color: #c62828;
}

/* ============================
   判定ドロップダウン（D列）
============================ */
.value-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.value-row label,
.value-label {
  font-size: 14px;
  color: #555;
  white-space: nowrap;
}

.value-select {
  padding: 7px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
  background: #fff;
  min-width: 200px;
}

.value-select:focus {
  outline: 2px solid #1976d2;
  border-color: #1976d2;
}

/* ============================
   フラグメントブロック
============================ */
.fragment-block {
  margin-bottom: 10px;
}

.fragment-label {
  font-size: 13px;
  color: #666;
  margin-bottom: 5px;
}

/* select タイプ */
.fragment-select {
  padding: 7px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
  background: #fff;
  width: 100%;
  max-width: 500px;
}

.fragment-select:focus {
  outline: 2px solid #1976d2;
  border-color: #1976d2;
}

/* multi タイプ（チェックボックス群） */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: #1976d2;
  flex-shrink: 0;
}

.checkbox-item span {
  font-size: 15px;
  line-height: 1.4;
}

/* toggle_group タイプ */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle-label-text {
  font-size: 15px;
  flex: 1;
  min-width: 140px;
}

/* iOS風トグルスイッチ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 28px;
  transition: 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-slider {
  background: #1976d2;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.freq-select {
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  display: none;
}

.freq-select.visible {
  display: inline-block;
}

/* text タイプ */
.fragment-textarea {
  width: 100%;
  max-width: 700px;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  min-height: 56px;
  line-height: 1.5;
}

.fragment-textarea:focus {
  outline: 2px solid #1976d2;
  border-color: #1976d2;
}

/* ============================
   サイドナビゲーション
============================ */
.nav-group-title {
  font-size: 11px;
  font-weight: bold;
  color: #FF8F00;
  padding: 10px 12px 4px;
  letter-spacing: 0.05em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  text-decoration: none;
  color: #444;
  font-size: 12px;
  line-height: 1.3;
  border-radius: 4px;
  margin: 1px 4px;
}

.nav-link:hover { background: #e8e8e8; }
.nav-link.done { color: #aaa; }
.nav-link.done span { text-decoration: line-through; }

.nav-done-cb {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #388e3c;
}

/* ============================
   判定ボタン群
============================ */
.choice-row {
  margin-bottom: 14px;
}

.choice-label {
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
  font-weight: 500;
}

.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.choice-btn {
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid #ccc;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  color: #333;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  line-height: 1.3;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.choice-btn.selected {
  background: #1976d2;
  border-color: #1976d2;
  color: #fff;
  font-weight: bold;
}

.choice-btn:active {
  transform: scale(0.97);
}

/* 選択肢数別 */
.choices-2 .choice-btn { min-width: 100px; }
.choices-3 .choice-btn { flex: 1; min-width: 80px; }
.choices-4 .choice-btn { flex: 1; min-width: 80px; }
.choices-5 .choice-btn { min-width: 70px; }
.choices-6 .choice-btn { min-width: 70px; }

/* ============================
   multiple選択（チェックボックス風）
============================ */
.multi-mode .choice-btn {
  padding-left: 32px;
  position: relative;
  text-align: left;
}

.multi-mode .choice-btn::before {
  content: "☐";
  position: absolute;
  left: 10px;
  font-size: 16px;
}

.multi-mode .choice-btn.selected::before {
  content: "☑";
  color: #fff;
}

/* ============================
   頻度行（4群用）
============================ */
.freq-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  margin-bottom: 14px;
  padding: 8px 12px;
  background: #FFF8E1;
  border-left: 3px solid #FF8F00;
  border-radius: 0 6px 6px 0;
}

.freq-row-label {
  font-size: 13px;
  color: #795548;
  white-space: nowrap;
  font-weight: 500;
}

.freq-row .choice-btn {
  font-size: 13px;
  min-height: 38px;
  padding: 6px 12px;
}

/* ============================
   フラグメントボタン（select型のボタン化）
============================ */
.frag-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.frag-choice-btn {
  min-height: 40px;
  padding: 6px 12px;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: #333;
  transition: background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.frag-choice-btn.selected {
  background: #43a047;
  border-color: #43a047;
  color: #fff;
  font-weight: bold;
}

.frag-choice-btn:active {
  transform: scale(0.97);
}

/* ============================
   連結プレビュー
============================ */
.preview-row {
  margin-top: 10px;
}

.preview-label {
  font-size: 13px;
  color: #888;
  margin-bottom: 4px;
}

.preview-text {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  font-style: italic;
  color: #444;
  min-height: 36px;
  word-break: break-all;
  white-space: pre-wrap;
}

.preview-text.empty {
  color: #bbb;
  font-style: italic;
}

/* ============================
   ローディング表示
============================ */
#loading-msg {
  text-align: center;
  padding: 40px;
  color: #888;
  font-size: 16px;
}

/* ============================
   レスポンシブ調整
============================ */

/* タブレット */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .side-nav {
    width: 100%;
    min-width: unset;
    height: auto;
    max-height: 180px;
    position: sticky;
    top: 60px;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
  .main-content {
    padding: 12px;
  }
}

/* スマートフォン */
@media (max-width: 600px) {
  body {
    font-size: 15px;
  }

  .page-header {
    padding: 10px 12px;
  }

  .sheet-search-input {
    max-width: 100%;
  }

  .sheet-list {
    max-height: 100px;
  }

  .main-content {
    padding: 12px;
  }

  .value-select,
  .fragment-select {
    width: 100%;
    max-width: 100%;
  }

  .fragment-textarea {
    max-width: 100%;
  }

  .item-header {
    flex-direction: column;
    gap: 4px;
  }

  .save-indicator {
    margin-left: 0;
    text-align: left;
  }

  .toggle-item {
    gap: 8px;
  }
}

/* --- PDF Upload --- */
.header-field-upload {
  flex-basis: 100%;
}
.upload-area {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-upload {
  padding: 4px 12px;
  border: 1px solid #2196F3;
  background: #fff;
  color: #2196F3;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.btn-upload:hover {
  background: #E3F2FD;
}
.upload-filename {
  font-size: 13px;
  color: #333;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-clear-upload {
  background: none;
  border: none;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.btn-clear-upload:hover {
  color: #f44336;
}
.ocr-status {
  font-size: 12px;
  color: #666;
}
.ocr-status.loading {
  color: #FF9800;
}
.ocr-status.done {
  color: #4CAF50;
}
.ocr-status.error {
  color: #f44336;
}

/* --- Facility Section --- */
.facility-section {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 8px 16px 10px;
  border-top: 1px solid #c5cae9;
  margin-top: 4px;
  align-items: flex-end;
}

.btn-save-facility {
  padding: 4px 12px;
  border: 1px solid #4CAF50;
  background: #fff;
  color: #4CAF50;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 18px;
  height: 32px;
}

.btn-save-facility:hover {
  background: #E8F5E9;
}

/* === 矛盾チェック機能 === */

/* 赤枠 */
.consistency-flag {
  border: 2px solid #d32f2f !important;
  border-radius: 3px;
  background-color: #fff5f5;
}

/* モーダル */
.consistency-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.consistency-modal[hidden] { display: none; }

.consistency-modal__content {
  background: #fff;
  max-width: 720px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.consistency-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

.consistency-modal__footer {
  text-align: right;
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e0e0e0;
}

.consistency-suppressed {
  background: #fffbe6;
  border-left: 3px solid #faad14;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.consistency-issue-list { list-style: none; padding: 0; margin: 0; }

.consistency-issue {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.consistency-issue__msg { margin: 0.5rem 0; }

/* バッジ (種別カラー) */
.consistency-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-weight: bold;
  font-size: 0.85rem;
  color: #fff;
}
.consistency-badge--A { background: #d32f2f; }
.consistency-badge--B { background: #f57c00; }
.consistency-badge--D { background: #7b1fa2; }
.consistency-badge--E { background: #1976d2; }

/* トースト */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 4px;
  z-index: 2000;
}
.toast[hidden] { display: none; }

/* ============================================================
   決定稿（緑背景）+ ごった煮メモ振り分け（Task 6-9）
   ============================================================ */

/* 決定稿の項目カードは緑背景（デフォルトは白ベース） */
.survey-item.kettei {
  background: #e8f5e9;
  border-color: #66bb6a;
}

/* 確定畳み（Task 7）: collapsed カードは1行サマリのみ表示 */
.survey-item.collapsed .value-row,
.survey-item.collapsed [id^="fragments-"],
.survey-item.collapsed .freq-row {
  display: none;
}

/* 特記メモプレビューは折り畳み時も表示する（③） */
.survey-item.collapsed .preview-row {
  display: block;
}

/* collapsed 状態のカードはパディングを詰める */
.survey-item.collapsed {
  padding: 8px 4px;
  cursor: default;
}

/* collapsed 状態の item-header はクリック可能（展開ヒント） */
.survey-item.collapsed .item-header {
  cursor: pointer;
  margin-bottom: 0;
}
.survey-item.collapsed .item-header:hover {
  opacity: 0.8;
}

/* collapsed 時のサマリ（判定値表示） */
.collapsed-summary {
  display: none;
  font-size: 13px;
  color: #2e7d32;
  font-weight: 600;
  margin-left: 8px;
  white-space: nowrap;
}
.survey-item.collapsed .collapsed-summary {
  display: inline;
}

/* 全カード展開ボタン */
.btn-expand-all {
  margin-top: 8px;
  margin-left: 8px;
  padding: 8px 16px;
  background: #607d8b;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn-expand-all:hover { background: #546e7a; }

/* 項目ヘッダーの決定稿チェック */
.kettei-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: 13px;
  color: #2e7d32;
  cursor: pointer;
  user-select: none;
}
.kettei-label input { cursor: pointer; }

/* ごった煮メモ振り分けボタン */
.btn-distribute {
  margin-top: 8px;
  padding: 8px 16px;
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn-distribute:hover { background: #1565c0; }
.btn-distribute:disabled { background: #90caf9; cursor: default; }

/* 振り分け確認モーダル */
.modal-box-wide {
  width: 760px !important;
  max-width: 92vw;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
}
.modal-hint {
  padding: 0 16px;
  margin: 4px 0 8px;
  font-size: 13px;
  color: #666;
}
.distribute-rows {
  overflow-y: auto;
  padding: 0 16px;
  flex: 1 1 auto;
}
.distribute-row {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  background: #f5f8ff;
}
.distribute-row.kettei {
  background: #e8f5e9;
  border-color: #66bb6a;
}
.distribute-row-head {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}
.distribute-row textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
}
.distribute-row .kettei-label { margin-left: 0; margin-top: 4px; }

/* ============================
   振り分けモーダル Task6
============================ */
.distribute-seiri-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: #f0f4ff;
  border-bottom: 1px solid #c5cae9;
}

.distribute-seiri-label {
  font-size: 13px;
  font-weight: 600;
  color: #3949ab;
}

.distribute-seiri-textarea {
  width: 100%;
  border: 1px solid #9fa8da;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  resize: vertical;
}

.btn-redistribute {
  align-self: flex-start;
  padding: 6px 14px;
  background: #3949ab;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.btn-redistribute:hover:not(:disabled) {
  background: #283593;
}

.btn-redistribute:disabled {
  background: #90a4ae;
  cursor: default;
}

.distribute-badge-new {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  background: #ff9800;
  color: #fff;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.distribute-choice-val {
  font-size: 12px;
  color: #555;
  margin-left: 10px;
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
}

.distribute-collapsed {
  margin-top: 8px;
}

.distribute-collapsed > summary {
  cursor: pointer;
  padding: 8px 12px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  color: #666;
  user-select: none;
}

.distribute-collapsed > summary:hover {
  background: #eeeeee;
}

.modal-hint-sub {
  color: #888;
  font-size: 12px;
}

.distribute-item-label {
  font-weight: 600;
}

/* ============================
   スピナー（Task 6）
============================ */
.spinner {
  display: inline-block; width: 1em; height: 1em; margin-right: 0.4em;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; vertical-align: -0.15em;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
