:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-strong: #eef3f1;
  --text: #1d2522;
  --muted: #65706b;
  --line: #d9dfdb;
  --accent: #236b5a;
  --accent-dark: #174b40;
  --warning: #b55d2a;
  --danger: #b83a3a;
  --ok: #2f7b42;
  --shadow: 0 16px 36px rgba(28, 44, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
}

.login-body {
  min-height: 100vh;
  background: var(--surface-strong);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 460px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 22px;
}

.login-form {
  gap: 12px;
}

.login-fields {
  grid-template-columns: 1fr;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.consent-row input {
  margin-top: 3px;
}

.login-title {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.login-actions {
  display: flex;
  justify-content: stretch;
}

.login-actions button {
  flex: 1;
}

.auth-switch {
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.link-button {
  background: none;
  border: none;
  padding: 0 0 0 4px;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

button,
input {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 56px) 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.account-panel {
  min-width: min(100%, 380px);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.auth-fields input {
  min-width: 0;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.auth-actions,
.auth-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.auth-actions .primary-button,
.auth-actions .secondary-button,
.auth-user .secondary-button {
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.auth-user span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.auth-user .auth-usage {
  color: var(--accent-dark);
}

.auth-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

.auth-message.error {
  color: var(--danger);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 12px;
  font-size: 15px;
  letter-spacing: 0;
}

.status-pill {
  min-width: 112px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ready {
  background: #e2f1e4;
  color: var(--ok);
}

.status-pill.missing,
.status-pill.error {
  background: #f7e7e1;
  color: var(--warning);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 900px);
  justify-content: center;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 56px) 42px;
}

.panel,
.result-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.panel-heading,
.result-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.model-grid div,
.result-details div {
  min-width: 0;
  padding: 14px;
  background: var(--surface-strong);
  border-radius: 8px;
}

dt,
.result-details span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

dd,
.result-details strong {
  display: block;
  margin: 5px 0 0;
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.primary-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.primary-button {
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  padding: 9px 13px;
  background: #fff;
  color: var(--accent-dark);
  border-color: var(--line);
}

.train-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.train-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.train-log {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 280px;
  margin-top: 22px;
  padding: 26px;
  border: 2px dashed #b7c5bd;
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfcfb 0%, #eef3f1 100%);
  cursor: pointer;
  text-align: center;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: #e9f4ef;
}

.drop-zone.locked {
  cursor: not-allowed;
  opacity: 0.72;
}

.drop-zone input {
  display: none;
}

.document-mark {
  position: relative;
  display: block;
  width: 78px;
  height: 96px;
  margin-bottom: 18px;
  border: 2px solid #7e948b;
  border-radius: 7px;
  background: #fff;
}

.document-mark::before {
  content: "";
  position: absolute;
  right: -2px;
  top: -2px;
  width: 24px;
  height: 24px;
  border-left: 2px solid #7e948b;
  border-bottom: 2px solid #7e948b;
  background: #dfe8e3;
}

.document-mark::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 38px;
  width: 42px;
  height: 26px;
  border-top: 3px solid var(--accent);
  border-bottom: 3px solid var(--warning);
}

.drop-title {
  display: block;
  max-width: 100%;
  font-size: 18px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.drop-note {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.llm-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}

.llm-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.analyze-button {
  width: 100%;
  margin-top: 14px;
}

.result-band {
  grid-column: 1 / -1;
  padding: 24px;
}

.risk-meter {
  min-width: min(320px, 100%);
}

.risk-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe4e1;
}

.risk-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--warning), var(--danger));
  transition: width 0.25s ease;
}

.risk-track span.fraud {
  background: var(--danger);
}

.risk-track span.normal {
  background: var(--ok);
}

.risk-track span.unknown {
  background: var(--muted);
}

.result-decided {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result-overall-summary {
  margin: 18px 0 0;
  padding: 14px 16px;
  background: var(--surface-strong);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.6;
}

.risk-meter strong {
  display: block;
  margin-top: 8px;
  text-align: right;
  font-size: 20px;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.branches-area,
.reasons-area {
  margin-top: 24px;
}

.branch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

/* 「AIによる判断」グループ（統計的判断＋生成系AIを内包） */
.branch-group {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.branch-group-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.branch-group-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.branch-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  border-top: 3px solid var(--line);
}

.branch-card.fraud {
  border-top-color: var(--danger);
}

.branch-card.normal {
  border-top-color: var(--ok);
}

.branch-card.unknown {
  border-top-color: var(--warning);
}

.branch-card.na {
  border-top-color: var(--muted);
  opacity: 0.75;
}

.branch-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.branch-head strong {
  font-size: 14px;
}

.branch-risk {
  font-size: 16px;
  font-weight: 800;
}

.branch-bar {
  height: 8px;
  margin: 10px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe4e1;
}

.branch-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--warning), var(--danger));
}

.branch-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
}

.branch-reasons {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.branch-reasons li {
  margin-bottom: 5px;
  overflow-wrap: anywhere;
}

.branch-na {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.reasons-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.65;
}

.reasons-list li {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

/* --- エビデンス: 操作パネル ------------------------------------------- */
.evidence-panel {
  margin-top: 10px;
  padding-left: 10px;
  border-left: 3px solid var(--line);
}

/* パネルの左ボーダー色を、その指標のハイライト色に合わせる */
.evidence-panel--rule {
  border-left-color: rgba(56, 132, 255, 0.9);
}

.evidence-panel--llm {
  border-left-color: rgba(40, 190, 130, 0.95);
}

.evidence-panel--overall {
  border-left-color: rgba(255, 196, 0, 0.95);
}

.evidence-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.evidence-action {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.evidence-action:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.evidence-action.primary {
  border-color: var(--accent);
}

.evidence-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.evidence-chip input {
  flex: 0 0 auto;
  cursor: pointer;
}

/* --- エビデンス: ジャンプボタン --------------------------------------- */
.evidence-jumps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.evidence-jump-button {
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-jump-button:hover {
  background: var(--accent);
  color: #fff;
}

/* --- エビデンス: 統合パネル（PDFエリア内） --------------------------- */
.combined-evidence-area {
  margin-bottom: 14px;
}

.combined-master {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.combined-group {
  margin-bottom: 12px;
}

.combined-group-title {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.combined-group-title--rule {
  background: rgba(40, 100, 210, 0.95);
}

.combined-group-title--llm {
  background: rgba(20, 150, 96, 0.95);
}

.combined-group-title--overall {
  background: rgba(200, 145, 0, 0.95);
}

/* --- エビデンス: PDFビューア ------------------------------------------ */
.pdf-area {
  margin-top: 24px;
}

.pdf-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.pdf-viewer {
  max-height: 70vh;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #525659;
}

.pdf-page {
  position: relative;
  margin: 0 auto 14px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.pdf-page canvas {
  display: block;
}

.pdf-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pdf-highlight {
  position: absolute;
  background: rgba(255, 214, 0, 0.38);
  outline: 1px solid rgba(214, 158, 0, 0.85);
  border-radius: 2px;
}

/* 指標ごとのハイライト色分け */
.pdf-highlight--rule {
  background: rgba(56, 132, 255, 0.32);
  outline-color: rgba(28, 90, 200, 0.9);
}

.pdf-highlight--llm {
  background: rgba(40, 190, 130, 0.34);
  outline-color: rgba(18, 130, 84, 0.9);
}

.pdf-highlight--overall {
  background: rgba(255, 196, 0, 0.4);
  outline-color: rgba(210, 150, 0, 0.9);
}

/* 点滅は明滅（opacity）で行い、各色の背景を上書きしない */
.pdf-highlight.flash {
  animation: evidence-flash 1.1s ease-out 2;
}

@keyframes evidence-flash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

@media (max-width: 900px) {
  .app-header,
  .panel-heading,
  .result-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .account-panel {
    min-width: 0;
  }

  .auth-fields {
    grid-template-columns: 1fr;
  }

  .auth-actions,
  .auth-user {
    justify-content: stretch;
  }

  .auth-actions button,
  .auth-user button {
    flex: 1;
  }

  .model-grid,
  .result-details,
  .branch-grid {
    grid-template-columns: 1fr;
  }

  .status-pill,
  .risk-meter {
    width: 100%;
  }
}

/* 問い合わせ導線フッター（SAAS-051） */
.app-footer {
  margin: 32px auto 24px;
  padding: 16px 24px;
  max-width: 1180px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.login-footer {
  border-top: none;
  margin-top: 16px;
}

/* 免責注記（SAAS-049） */
.result-disclaimer {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.footer-disclaimer {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.footer-contact a {
  color: var(--accent);
}

/* お問い合わせフォーム（モーダル） */
.footer-link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 27, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  padding: 24px;
}

.modal-card h2 {
  margin: 0 0 4px;
}

.contact-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.contact-field {
  display: block;
  margin-bottom: 14px;
}

.contact-field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.contact-field em {
  color: var(--danger);
  font-style: normal;
  font-size: 0.8rem;
}

.contact-field input,
.contact-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
  box-sizing: border-box;
}

.contact-field input[readonly] {
  background: var(--surface-strong);
  color: var(--muted);
}

.contact-field textarea {
  resize: vertical;
}

.contact-feedback {
  margin: 0 0 12px;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.contact-feedback.error {
  color: var(--danger);
}

.contact-feedback.ok {
  color: var(--ok);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* hidden 属性を確実に効かせる（.consent-row 等の display 指定より優先） */
[hidden] {
  display: none !important;
}

/* メール確認コード入力 */
.turnstile-container {
  margin: 4px 0;
  min-height: 0;
}

.verify-fields {
  display: grid;
  gap: 10px;
}

.verify-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.verify-fields input {
  height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 1.15rem;
  letter-spacing: 0.35em;
  text-align: center;
}

.verify-fields .link-button {
  justify-self: start;
}

/* 利用規約などの法務ページ */
.legal-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px clamp(18px, 4vw, 40px) 56px;
}

.legal-doc h1 {
  margin-bottom: 8px;
}

.legal-doc h2 {
  margin: 26px 0 8px;
  font-size: 17px;
}

.legal-doc ol,
.legal-doc ul {
  margin: 0;
  padding-left: 1.4em;
  line-height: 1.7;
}

.legal-doc li {
  margin: 4px 0;
}

.legal-doc p {
  line-height: 1.7;
}

.legal-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.legal-back {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.legal-back a {
  color: var(--accent);
}

.consent-row a {
  color: var(--accent);
}

/* 退会（削除）系の危険操作 */
.danger-button {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.link-danger {
  color: var(--danger);
}

/* パスワード忘れ・戻る 等の補助リンク */
.auth-help {
  margin: 6px 0 0;
  text-align: center;
  font-size: 0.85rem;
}

.auth-help-note {
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ハニーポット（ボット誘導用・人間には非表示） */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
