:root {
  --bg: #f3f7f5;
  --card: #ffffff;
  --text: #18332a;
  --muted: #61736c;
  --line: #d7e3de;
  --primary: #167c5a;
  --primary-dark: #0f6145;
  --safe: #28875f;
  --warn: #ca8213;
  --danger: #c74747;
  --unknown: #6a7380;
  --shadow: 0 12px 30px rgba(20, 62, 47, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  line-height: 1.65;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  color: white;
  background: rgba(15, 97, 69, .96);
  backdrop-filter: blur(12px);
}
.app-header h1 { margin: 0; font-size: 1.15rem; line-height: 1.2; }
.eyebrow { margin: 0 0 2px; opacity: .8; font-size: .72rem; }
.version { font-size: .75rem; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; padding: 3px 8px; }
.container { width: min(100%, 760px); margin: 0 auto; padding: 16px 14px 36px; }
.hero {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, #e6f5ef, #ffffff);
  border: 1px solid #cde5db;
}
.hero h2 { margin: 0 0 4px; font-size: 1.25rem; }
.hero p { margin: 0; color: var(--muted); font-size: .92rem; }
.shield {
  flex: 0 0 54px;
  width: 54px;
  height: 62px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--primary);
  clip-path: polygon(50% 0, 92% 17%, 84% 72%, 50% 100%, 16% 72%, 8% 17%);
}
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.tab {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--muted);
  font-weight: 700;
}
.tab.active { color: white; background: var(--primary); border-color: var(--primary); }
.panel { display: none; }
.panel.active { display: block; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
}
label { display: block; margin: 14px 0 6px; font-weight: 700; }
label:first-child { margin-top: 0; }
input, textarea {
  width: 100%;
  border: 1px solid #bfcfc8;
  border-radius: 14px;
  padding: 13px 14px;
  background: #fcfefd;
  color: var(--text);
  outline: none;
}
textarea { resize: vertical; min-height: 120px; }
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(22,124,90,.12); }
.action-row { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin-top: 16px; }
.primary, .secondary {
  min-height: 50px;
  border-radius: 15px;
  font-weight: 800;
}
.primary { border: 0; color: white; background: var(--primary); }
.primary:active { background: var(--primary-dark); }
.secondary { border: 1px solid var(--line); color: var(--primary); background: white; }
.privacy-note { margin: 12px 0 0; color: var(--muted); font-size: .78rem; }
.result {
  margin-top: 16px;
  padding: 20px;
  border-radius: 22px;
  background: white;
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
}
.hidden { display: none !important; }
.result-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.result-label { margin: 0; font-size: .78rem; color: var(--muted); }
.result h2 { margin: 2px 0 0; }
.score-wrap { min-width: 84px; text-align: center; }
.score-wrap span { font-size: 2rem; font-weight: 900; }
.score-wrap small { color: var(--muted); }
.meter { height: 12px; background: #e5ece9; border-radius: 999px; overflow: hidden; margin: 12px 0; }
.meter span { display: block; width: 0; height: 100%; transition: width .35s ease; background: var(--unknown); }
.summary { font-weight: 700; }
.result ul { padding-left: 1.35rem; }
.advice-box { margin-top: 14px; padding: 14px; border-radius: 16px; background: #edf7f2; }
.advice-box h3 { margin-top: 0; }
.disclaimer { color: var(--muted); font-size: .8rem; margin-bottom: 0; }

.danger-alert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: -6px -6px 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #b91c1c;
  color: #fff;
  font-weight: 900;
  text-align: center;
  letter-spacing: .02em;
}
.danger-alert-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: #fff;
  color: #b91c1c;
  font-size: 1.05rem;
  font-weight: 1000;
}
.result.danger {
  border-color: #dc2626;
  background: #fffafa;
}
.result.danger.danger-animate {
  animation: dangerCardPulse 1.15s ease-in-out 3, dangerCardShake .42s ease-in-out 1;
}
.result.danger.danger-critical .danger-alert {
  animation: dangerBannerFlash .85s ease-in-out 4;
}
.result.danger.danger-critical .score-wrap span {
  color: #b91c1c;
  animation: dangerScorePop .65s ease-out 2;
}
.result.danger.danger-critical .meter {
  box-shadow: 0 0 0 4px rgba(220,38,38,.10);
}
@keyframes dangerCardPulse {
  0%,100% { box-shadow: 0 12px 28px rgba(19,60,48,.08); transform: scale(1); }
  50% { box-shadow: 0 0 0 7px rgba(220,38,38,.14), 0 16px 34px rgba(185,28,28,.18); transform: scale(1.012); }
}
@keyframes dangerCardShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
@keyframes dangerBannerFlash {
  0%,100% { background: #b91c1c; }
  50% { background: #ef4444; }
}
@keyframes dangerScorePop {
  0% { transform: scale(.82); opacity: .55; }
  65% { transform: scale(1.14); opacity: 1; }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .result.danger.danger-animate,
  .result.danger.danger-critical .danger-alert,
  .result.danger.danger-critical .score-wrap span { animation: none !important; }
}

.result.warning { border-color: #efd4a8; }
.result.safe { border-color: #acd9c8; }
.result.unknown { border-color: #c8ced5; }
.guide { margin-top: 16px; }
.guide h2 { margin-top: 0; font-size: 1.05rem; }
.guide ol { margin-bottom: 0; padding-left: 1.4rem; }
.history-head { display: flex; justify-content: space-between; align-items: center; }
.history-head h2 { margin: 0; font-size: 1.05rem; }
.danger-link { border: 0; background: transparent; color: var(--danger); }
.history-item { padding: 13px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.history-title { font-weight: 800; }
.history-meta { color: var(--muted); font-size: .78rem; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 9px; font-size: .72rem; font-weight: 800; }
.badge.danger { color: #8e2929; background: #fde4e4; }
.badge.warning { color: #8a5707; background: #fff0d6; }
.badge.safe { color: #176246; background: #dff3eb; }
.badge.unknown { color: #4d5662; background: #e8ebef; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }
footer { padding: 20px 14px calc(28px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: .8rem; }
footer p { margin: 3px 0; }
footer a { color: var(--primary); }
@media (min-width: 700px) {
  .container { padding-top: 24px; }
  .hero { padding: 24px; }
  .card, .result { padding: 24px; }
}

.section-title { margin: 0 0 4px; font-size: 1.05rem; }
.lead-small { margin: 0 0 12px; color: var(--muted); font-size: .86rem; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-button { display: grid; place-items: center; min-height: 58px; margin: 0; border: 2px dashed #91b8a8; border-radius: 16px; color: var(--primary); background: #f4fbf8; font-weight: 800; cursor: pointer; }
.image-area { margin-top: 12px; }
.image-area img { display: block; width: 100%; max-height: 360px; object-fit: contain; border: 1px solid var(--line); border-radius: 14px; background: #eef3f1; }
.full { width: 100%; margin-top: 12px; }
.ocr-progress { margin-top: 12px; }
.ocr-progress p { margin: 4px 0 0; text-align: center; color: var(--muted); font-size: .82rem; }
.divider { display: flex; align-items: center; gap: 10px; margin: 22px 0; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.action-row.single { grid-template-columns: 1fr; }
@media (max-width: 390px) { .tab { font-size: .82rem; padding-inline: 4px; } }

/* Ver1.2 menu and forced update */
.header-actions { display:flex; align-items:center; gap:8px; }
.menu-button, .menu-close { border:0; background:transparent; color:inherit; }
.menu-button { width:42px; height:42px; border:1px solid rgba(255,255,255,.38); border-radius:12px; font-size:1.35rem; line-height:1; }
.menu-backdrop { position:fixed; inset:0; z-index:39; background:rgba(10,28,22,.48); backdrop-filter:blur(2px); }
.app-menu { position:fixed; top:0; right:0; z-index:40; width:min(88vw,360px); height:100dvh; padding:calc(18px + env(safe-area-inset-top)) 18px calc(22px + env(safe-area-inset-bottom)); background:#fff; color:var(--text); box-shadow:-12px 0 30px rgba(10,35,27,.18); transform:translateX(105%); transition:transform .22s ease; overflow-y:auto; }
.app-menu.open { transform:translateX(0); }
.menu-head { display:flex; justify-content:space-between; align-items:center; gap:12px; padding-bottom:14px; border-bottom:1px solid var(--line); }
.menu-head h2 { margin:0; font-size:1.25rem; }
.eyebrow.dark { color:var(--muted); }
.menu-close { width:42px; height:42px; border-radius:12px; background:#edf4f1; color:var(--text); font-size:1.8rem; }
.menu-version { display:flex; justify-content:space-between; align-items:center; margin:18px 0 12px; padding:12px 14px; border-radius:14px; background:#f1f7f4; }
.menu-version span { color:var(--muted); font-size:.86rem; }
.force-update { width:100%; display:flex; align-items:center; gap:13px; min-height:72px; padding:13px 14px; border:0; border-radius:16px; color:white; background:var(--primary); text-align:left; }
.force-update:disabled { opacity:.65; cursor:wait; }
.force-update-icon { flex:0 0 38px; width:38px; height:38px; display:grid; place-items:center; border-radius:999px; background:rgba(255,255,255,.18); font-size:1.5rem; }
.force-update span:last-child { display:flex; flex-direction:column; }
.force-update strong { font-size:1rem; }
.force-update small { margin-top:2px; opacity:.88; font-size:.75rem; font-weight:500; }
.update-status { min-height:24px; margin:10px 2px 4px; color:var(--muted); font-size:.82rem; }
.menu-links { display:grid; margin-top:10px; border-top:1px solid var(--line); }
.menu-links a { padding:14px 4px; border-bottom:1px solid var(--line); color:var(--primary); text-decoration:none; font-weight:700; }
.menu-note { margin-top:16px; color:var(--muted); font-size:.78rem; }
body.menu-open { overflow:hidden; }

/* Ver1.8 複数スクリーンショット */
.image-preview-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.image-preview-item {
  position: relative;
  overflow: hidden;
  border: 1px solid #c9d8d2;
  border-radius: 14px;
  background: #f6faf8;
}
.image-preview-item img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
}
.image-order {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #167c5a;
  color: #fff;
  font-weight: 800;
}
.selected-count {
  margin: 4px 0 14px;
  font-weight: 700;
  color: #315f50;
}
@media (min-width: 700px) {
  .image-preview-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
