/* ===== リセット & ベース ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic Pro', 'Yu Gothic UI', sans-serif;
  background: #f0f4ff;
  color: #1e293b;
  min-height: 100vh;
  padding: 20px 16px 60px;
  line-height: 1.6;
}

.container {
  max-width: 920px;
  margin: 0 auto;
}

/* ===== ヘッダー ===== */
.app-header {
  text-align: center;
  padding: 32px 0 28px;
}

.app-header h1 {
  font-size: 1.85rem;
  font-weight: 800;
  color: #3730a3;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.subtitle {
  color: #6366f1;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.disclaimer-top {
  display: inline-block;
  background: #e0e7ff;
  color: #4338ca;
  font-size: 0.8rem;
  padding: 5px 18px;
  border-radius: 20px;
}

/* ===== ステップナビ ===== */
.step-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 24px;
  background: #e2e8f0;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  user-select: none;
}

.step-item.active {
  background: #6366f1;
  color: white;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

.step-item.done {
  background: #c7d2fe;
  color: #4338ca;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-item.active .step-num {
  background: rgba(255,255,255,0.25);
}

.step-arrow {
  color: #cbd5e1;
  font-size: 1.3rem;
  line-height: 1;
}

/* ===== セクション ===== */
.section {
  background: white;
  border-radius: 18px;
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.hidden {
  display: none;
}

.section.hidden {
  display: none;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #3730a3;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 2px solid #e0e7ff;
}

.section-desc {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ===== フォーム ===== */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: #334155;
  margin-bottom: 7px;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  font-size: 0.9rem;
  color: #1e293b;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fafafa;
}

input:focus, textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
  background: white;
}

textarea {
  resize: vertical;
}

.hint {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 5px;
}

/* ===== ボタン ===== */
.btn-primary {
  background: #6366f1;
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.btn-primary:disabled {
  background: #a5b4fc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: white;
  color: #6366f1;
  border: 2px solid #6366f1;
  padding: 10px 22px;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #eef2ff;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-text {
  background: none;
  border: none;
  color: #6366f1;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 0;
  font-family: inherit;
}

.btn-text:hover {
  color: #4f46e5;
}

.btn-icon {
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: #e2e8f0;
}

.btn-copy {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  color: #475569;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-copy:hover {
  background: #e0e7ff;
  color: #4338ca;
  border-color: #a5b4fc;
}

.btn-add-row {
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: 7px;
  padding: 7px 18px;
  font-size: 0.85rem;
  color: #64748b;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-add-row:hover {
  background: #eef2ff;
  border-color: #818cf8;
  color: #4338ca;
}

.btn-delete-row {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 8px;
  border-radius: 5px;
  transition: background 0.15s;
}

.btn-delete-row:hover {
  background: #fee2e2;
}

/* ===== アップロードエリア ===== */
.upload-panel {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
}

.upload-panel h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px dashed #c7d2fe;
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  background: white;
  color: #6366f1;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.upload-zone:hover {
  background: #eef2ff;
  border-color: #818cf8;
}

.upload-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.upload-main-text {
  font-size: 0.9rem;
}

.upload-sub-text {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* 入力モード切り替えタブ（画像 / テキスト貼り付け） */
.input-mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.mode-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #64748b;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-tab:hover {
  border-color: #c7d2fe;
}

.mode-tab.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

#zoom-text-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.6;
  padding: 14px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  resize: vertical;
  transition: border-color 0.15s;
}

#zoom-text-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* アクティブゾーン（貼り付け先） */
.upload-panel.zone-active {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.upload-panel.zone-active .upload-zone {
  border-color: #818cf8;
  background: #eef2ff;
}

/* ドラッグオーバー */
.upload-panel.drag-over {
  border-color: #4f46e5;
  box-shadow: 0 0 0 4px rgba(99,102,241,0.25);
}

.upload-panel.drag-over .upload-zone {
  border-color: #4f46e5;
  background: #e0e7ff;
}

/* 貼り付けフラッシュ */
.upload-panel.zone-flash {
  animation: zoneFlash 0.6s ease;
}

@keyframes zoneFlash {
  0%   { box-shadow: 0 0 0 6px rgba(99,102,241,0.5); }
  100% { box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
}

.preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.preview-item {
  position: relative;
  width: 110px;
}

.preview-item img {
  width: 110px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  display: block;
}

.preview-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  border: 2px solid white;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.preview-remove:hover {
  background: #dc2626;
}

.preview-name {
  display: block;
  font-size: 0.68rem;
  color: #64748b;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 補足情報エリア ===== */
.optional-section {
  background: #f8fafc;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 140px;
}

.optional-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 14px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

/* ===== ローディング / エラー ===== */
.loading-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #eef2ff;
  border-radius: 9px;
  margin-top: 14px;
  font-size: 0.9rem;
  color: #4338ca;
}

.loading-area.hidden {
  display: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid #a5b4fc;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-area {
  padding: 12px 16px;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 9px;
  color: #b91c1c;
  font-size: 0.88rem;
  margin-top: 14px;
}

.error-area.hidden {
  display: none;
}

/* ===== テーブル（STEP 3 編集用） ===== */
.table-panel {
  margin-bottom: 28px;
}

.table-panel h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 10px;
}

.table-scroll {
  overflow-x: auto;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: #eef2ff;
  color: #3730a3;
  font-weight: 700;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid #c7d2fe;
  white-space: nowrap;
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #f8faff;
}

.cell-input {
  width: 100%;
  padding: 6px 9px;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  font-size: 0.85rem;
  font-family: inherit;
  min-width: 80px;
  background: white;
  transition: border-color 0.15s;
}

.cell-input:focus {
  outline: none;
  border-color: #818cf8;
}

.cell-number {
  max-width: 90px;
}

/* ===== 出力カード ===== */
.disclaimer-box {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.85rem;
  color: #78350f;
  margin-bottom: 22px;
}

.output-card {
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 18px;
}

.output-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.output-card-header h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: #1e293b;
}

.output-card-header h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
}

/* ===== 出力テーブルのセル色 ===== */
.status-found {
  color: #059669;
  font-weight: 700;
}

.status-none {
  color: #dc2626;
  font-weight: 700;
}

.remarks-check {
  color: #d97706;
  font-size: 0.82rem;
  font-weight: 600;
}

.remarks-ok {
  color: #059669;
  font-size: 0.82rem;
}

.row-check td {
  background: #fffbeb !important;
}

.no-data {
  text-align: center;
  color: #64748b;
  font-size: 0.88rem;
  padding: 16px;
}

.no-issues {
  color: #059669;
  font-size: 0.9rem;
  padding: 8px 0;
}

/* ===== 要確認コメント ===== */
.comment-area {
  min-height: 40px;
}

.check-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.check-list li {
  padding: 11px 16px;
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  border-radius: 0 9px 9px 0;
  font-size: 0.87rem;
  line-height: 1.6;
  color: #44403c;
  transition: opacity 0.2s, background 0.2s;
}

/* 除外済み項目 */
.check-item-excluded {
  opacity: 0.4;
  background: #f1f5f9 !important;
  border-left-color: #94a3b8 !important;
}

.check-item-excluded .check-item-label span {
  text-decoration: line-through;
  color: #94a3b8;
}

/* チェックボックス付きラベル */
.check-item-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.exclude-cb {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: #10b981;
  cursor: pointer;
}

/* 除外ヒント文 */
.exclude-hint {
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

/* 除外カウンター */
.exclude-counter {
  margin-top: 12px;
  font-size: 0.82rem;
  color: #475569;
  text-align: right;
}

.exclude-counter.has-excluded {
  color: #d97706;
  font-weight: 600;
}

.exclude-counter.all-excluded {
  color: #dc2626;
  font-weight: 600;
}

/* ===== サマリー ===== */
.summary-area {
  font-size: 0.9rem;
}

.summary-table {
  border-collapse: collapse;
  margin-bottom: 12px;
}

.summary-table th {
  text-align: left;
  padding: 8px 20px 8px 0;
  font-weight: 600;
  color: #475569;
  background: none;
  border-bottom: none;
}

.summary-table td {
  padding: 8px 12px;
  border-bottom: none;
  font-weight: 500;
}

.confirmed-count {
  color: #059669;
  font-size: 1.1em;
  font-weight: 700;
}

.check-count {
  color: #d97706;
  font-weight: 700;
}

.summary-note {
  font-size: 0.76rem;
  color: #94a3b8;
  line-height: 1.5;
}

/* ===== 確認文メッセージ ===== */
.message-block {
  margin-top: 4px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 18px;
}

.message-block.hidden {
  display: none;
}

.message-text {
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.75;
  color: #334155;
}

/* 編集可能 textarea */
.message-textarea {
  width: 100%;
  font-size: 0.88rem;
  line-height: 1.75;
  color: #334155;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.15s;
}

.message-textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.msg-edit-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

/* ===== トーン選択 ===== */
.tone-selector {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
}

.tone-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 10px;
}

.tone-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tone-option {
  display: flex;
  align-items: flex-start;
  gap: 0;
  cursor: pointer;
  flex: 1;
  min-width: 140px;
}

.tone-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tone-option-inner {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  cursor: pointer;
  width: 100%;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.tone-option-inner strong {
  font-size: 0.9rem;
  color: #334155;
}

.tone-option-inner span {
  font-size: 0.75rem;
  color: #94a3b8;
}

.tone-option input[type="radio"]:checked + .tone-option-inner {
  border-color: #6366f1;
  background: #eef2ff;
}

.tone-option input[type="radio"]:checked + .tone-option-inner strong {
  color: #4338ca;
}

/* ===== フッターナビ ===== */
.footer-nav {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  margin-top: 8px;
}

/* ===== トースト ===== */
.copy-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #1e293b;
  color: white;
  padding: 10px 26px;
  border-radius: 24px;
  font-size: 0.875rem;
  z-index: 9999;
  pointer-events: none;
  animation: toastFade 2s ease forwards;
}

@keyframes toastFade {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== レスポンシブ ===== */
@media (max-width: 640px) {
  body { padding: 12px 10px 50px; }
  .section { padding: 18px 16px; }
  .app-header h1 { font-size: 1.45rem; }
  .step-label { display: none; }
  .action-row { flex-direction: column; align-items: stretch; }
  .btn-primary { width: 100%; text-align: center; }
  .footer-nav { justify-content: stretch; flex-direction: column-reverse; }
  .footer-nav button { width: 100%; }
}

/* ===== ログイン画面 ===== */
#login-area {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 16px;
}

.login-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 10px 16px;
  margin-top: 16px;
}

.login-icon {
  font-size: 1.1rem;
}

.login-email {
  font-weight: 600;
  color: #166534;
  font-size: 0.95rem;
}

/* ===== 送信前確認チェックボックス ===== */
.pii-confirm-area {
  margin: 16px 0 8px;
  padding: 12px 14px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
}

.pii-confirm-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: #78350f;
  line-height: 1.5;
  cursor: pointer;
}

.pii-confirm-label input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

#analyze-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== 個人情報警告 ===== */
.warning-hint {
  font-size: 0.82rem;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
  line-height: 1.5;
}
