:root {
  --bg: #f8fafc;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --border: #e2e8f0;
  --error: #b91c1c;
  /* コンテンツ最大幅（モバイル / PC） */
  --page-width-mobile: 100%;
  --page-width-desktop: 1024px;
  --page-width: var(--page-width-mobile);
  /* スキャン画面：ライブ・静止画 */
  --preview-height: min(48vh, 360px);
}

* {
  box-sizing: border-box;
}

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

/* ページ最下部（スクロール先）のナビ。固定フッターではない */
header.site-header--bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  width: 100%;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
  max-width: var(--page-width);
}

.site-header-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.site-header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

header.site-header--bottom nav a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9375rem;
}

.site-doc-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  width: 100%;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
  max-width: var(--page-width);
}

.site-doc-footer nav a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  font-size: 0.9375rem;
}

.home-page .page-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding-top: 24px;
  padding-bottom: 8px;
}

.home-page .home-hero {
  margin-bottom: 0;
  padding: 28px 20px 24px;
  text-align: center;
}

.home-page .home-hero h1 {
  margin: 0 0 12px;
  font-size: 1.5rem;
}

.home-page .home-lead {
  margin: 0 0 8px;
  line-height: 1.55;
}

.home-page .home-note {
  margin: 0;
}

.home-page .home-cta {
  margin-top: 1.5rem;
}

.home-page .home-guide-link {
  margin: 12px 0 0;
}

.home-page .btn-home-scan {
  display: block;
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  flex: none;
  padding: 14px 20px;
}

.sub-page .site-doc-footer {
  flex-shrink: 0;
  flex-direction: column;
  text-align: center;
  gap: 6px;
  margin-top: auto;
  border-top: none;
  padding-top: 8px;
}

.sub-page .site-doc-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
}

.sub-page .site-doc-footer nav a:not(:last-child)::after {
  content: "·";
  margin-left: 16px;
  color: var(--muted);
  font-weight: 400;
  pointer-events: none;
}

.rakuten-developer-credit {
  margin-top: 12px;
  padding-top: 4px;
}

.rakuten-developer-credit img {
  display: block;
  max-width: 100%;
  height: auto;
}

.result-sub {
  margin: 16px 0 8px;
  font-size: 1rem;
}

.price-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.link-list a {
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
}

@media (min-width: 640px) {
  :root {
    --page-width: var(--page-width-desktop);
  }
}

.scan-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.scan-page main {
  flex: 1 1 auto;
}

.scan-page .site-doc-footer {
  flex-shrink: 0;
  flex-direction: column;
  text-align: center;
  gap: 6px;
  border-top: none;
  padding-top: 8px;
}

.scan-page .site-doc-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
}

.scan-page .site-doc-footer nav a:not(:last-child)::after {
  content: "·";
  margin-left: 16px;
  color: var(--muted);
  font-weight: 400;
  pointer-events: none;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 4px 0 0;
}

main {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 16px;
}

.scan-app.card {
  padding: 0;
  overflow: hidden;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.viewport {
  position: relative;
  background: #000;
  width: 100%;
  min-height: var(--preview-height);
  overflow: hidden;
}

/* ライブ映像・静止画とも同じ固定枠 */
.viewport.is-live,
.viewport.is-frozen {
  height: var(--preview-height) !important;
  min-height: var(--preview-height) !important;
  max-height: var(--preview-height) !important;
}

.freeze-preview {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
  background: #111;
}

.viewport.is-frozen .camera-wrap {
  display: none !important;
}

.viewport.is-frozen {
  cursor: pointer;
  touch-action: manipulation;
}

.freeze-hint {
  z-index: 2;
}

.capture-footer {
  padding: 12px 16px 16px;
}

.analysis-panel {
  border-top: 3px solid var(--accent);
  background: var(--card);
  padding: 12px 16px 16px;
  max-height: 52vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.analysis-panel .status-line {
  margin: 0 0 10px;
}

.panel-block .loading {
  margin: 8px 0;
}

.panel-block .btn.primary {
  width: 100%;
  margin-top: 12px;
}

#panel-result h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.hidden {
  display: none !important;
}

.camera-tap-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 160px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  touch-action: manipulation;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

label.camera-tap-btn {
  margin: 0;
}

.camera-tap-btn:active {
  background: #eff6ff;
}

.camera-tap-btn:disabled {
  opacity: 0.6;
}

.status-line {
  text-align: center;
  font-weight: 600;
  margin: 0 0 12px;
  min-height: 1.5em;
  color: var(--accent);
}

.capture-icon {
  font-size: 2.5rem;
}

.viewport.is-live .camera-wrap {
  touch-action: none;
}

.camera-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
}

#camera-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(1);
  transform-origin: center center;
  will-change: transform;
}

#camera-idle {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--preview-height);
  padding: 16px;
}

#camera-idle .camera-tap-btn {
  min-height: 140px;
  max-width: 100%;
}

.camera-wrap.is-mirror #camera-video {
  transform: scaleX(-1);
}

.btn-fallback {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

.camera-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  margin: 0;
  padding: 12px;
  text-align: center;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  pointer-events: none;
}

.hint {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

#preview {
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  border-radius: 8px;
  background: #eee;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.outline {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.loading {
  text-align: center;
  font-weight: 600;
  margin: 16px 0 8px;
}

.loading-preview {
  width: 100%;
  max-height: 40vh;
  object-fit: contain;
  border-radius: 8px;
  background: #eee;
  margin-bottom: 12px;
}


.error {
  color: var(--error);
  margin: 0 0 12px;
}

.result-dl {
  margin: 0;
}

.result-dl dt {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 10px;
}

.result-dl dd {
  margin: 2px 0 0;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  padding: 6px 12px;
  background: #eff6ff;
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.875rem;
}

.market-warnings {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.market-warnings:not(.hidden) {
  display: block;
}

.market-warnings li {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  font-size: 0.875rem;
  line-height: 1.45;
}

.sub-page,
.history-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.sub-page .page-main {
  max-width: var(--page-width);
  margin-left: auto;
  margin-right: auto;
  padding: 16px;
  width: 100%;
  box-sizing: border-box;
  flex: 1 0 auto;
}

.app-settings-page-title {
  margin: 0 0 20px;
  font-size: 1.25rem;
}

.app-settings-section-label {
  margin: 0 0 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--muted);
}

.site-header-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.app-settings-dl {
  margin: 0 0 8px;
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 4px 12px;
  font-size: 0.9375rem;
}

.app-settings-dl dt {
  margin: 0;
  color: var(--muted);
}

.app-settings-dl dd {
  margin: 0;
  word-break: break-all;
}

.app-settings-note {
  margin: 0 0 12px;
}

.app-settings-sub {
  margin: 0 0 8px;
  font-size: 0.9375rem;
}

.app-settings-danger {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  border: none;
}

.btn-danger:disabled {
  opacity: 0.6;
}

.login-consent-note {
  margin: 12px 0 16px;
  line-height: 1.5;
}

.login-google-btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.login-consent-heading {
  margin: 0 0 10px;
  font-size: 1rem;
}

.login-consent-list {
  margin: 0 0 12px;
  padding-left: 1.2em;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.login-consent-list li {
  margin-bottom: 6px;
}

.login-consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  font-size: 0.9375rem;
  line-height: 1.45;
  cursor: pointer;
}

.login-consent-check input {
  margin-top: 3px;
  flex-shrink: 0;
}

.login-consent-form .login-google-btn {
  margin-top: 4px;
}
