:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --line: #2c313c;
  --text: #eef1f6;
  --muted: #98a1b2;
  --gold: #d8b25f;
  --gold-dim: #8d7336;
  --red: #e06c6c;
  --green: #6cc48f;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.hidden { display: none !important; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); min-height: 1.2em; font-size: 14px; }

button { font: inherit; cursor: pointer; }

input[type="text"], input[type="password"], input[type="search"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px; /* iOSの自動ズーム防止 */
}
input::placeholder { color: #6b7385; }

.primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--gold);
  color: #17130a;
  font-weight: 700;
  font-size: 16px;
}
.primary:disabled { background: #3a3f4b; color: #7c8496; }
.primary.big { padding: 18px; font-size: 18px; }

/* ---------- ログイン ---------- */
.screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-box { width: 100%; max-width: 340px; display: grid; gap: 12px; }

/* ---------- ヘッダ ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 17, 21, 0.94);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-top)) 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-weight: 700;
}
.tabs { display: flex; gap: 6px; }
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}
.tab.active { background: var(--gold); border-color: var(--gold); color: #17130a; font-weight: 700; }

.view { max-width: 640px; margin: 0 auto; }

/* ---------- カメラ ---------- */
#capture-panel { padding: 16px; display: grid; gap: 14px; }

.camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
#video { width: 100%; height: 100%; object-fit: cover; display: block; }

.frame-guide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.frame-guide span {
  width: 58%;
  aspect-ratio: 1;
  border: 2px dashed rgba(216, 178, 95, 0.65);
  border-radius: 50%;
}
.camera-msg {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.shot-row { display: flex; align-items: center; justify-content: center; gap: 18px; }
.shutter {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 4px solid var(--gold);
  background: var(--gold);
  box-shadow: inset 0 0 0 4px var(--bg);
}
.shutter:disabled { border-color: #444a58; background: #444a58; }
.file-btn {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; min-height: 0; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 14px;
  line-height: 1;
}
.hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- ローディング ---------- */
#loading { text-align: center; padding: 56px 24px; }
.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 18px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  /* 視差を減らす設定でも回転は残す（進行中であることが伝わらなくなるため） */
  .spinner { animation-duration: 1.4s; }
}
.loading-text { font-size: 17px; margin: 0 0 4px; }

/* ---------- 結果 ---------- */
#result { padding: 16px; display: grid; gap: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head { display: flex; gap: 12px; padding: 14px; align-items: flex-start; }
.card-head img {
  width: 72px; height: 72px; object-fit: contain;
  background: #fff; border-radius: 8px; flex: none;
}
.card-title { font-size: 17px; font-weight: 700; line-height: 1.4; margin: 0 0 4px; }
.card-cat { font-size: 12px; color: var(--muted); }

.price-hero {
  padding: 6px 16px 18px;
  text-align: center;
  border-top: 1px solid var(--line);
}
.price-label { font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
.price-value {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -0.02em;
  line-height: 1.15;
  word-break: break-all;
}
.price-value.small { font-size: 27px; }
.price-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.6; }

.conf { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.conf-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.conf-bar i { display: block; height: 100%; background: var(--gold); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.ok { background: rgba(108, 196, 143, 0.16); color: var(--green); }
.badge.warn { background: rgba(224, 108, 108, 0.16); color: var(--red); }
.badge.mid { background: rgba(216, 178, 95, 0.16); color: var(--gold); }

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  border: 1px solid var(--line);
  background: var(--panel);
}
.notice.warn { border-color: rgba(224, 108, 108, 0.5); background: rgba(224, 108, 108, 0.08); }
.notice.info { border-color: rgba(216, 178, 95, 0.4); background: rgba(216, 178, 95, 0.07); }

table.prices { width: 100%; border-collapse: collapse; font-size: 14px; }
table.prices th, table.prices td { padding: 9px 12px; border-top: 1px solid var(--line); text-align: left; }
table.prices th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.prices td.amount { text-align: right; white-space: nowrap; font-weight: 700; }
table.prices tr.matched { background: rgba(216, 178, 95, 0.1); }
table.prices tr.matched td { color: var(--gold); }
table.prices td.unavail { color: var(--muted); font-weight: 400; }

details.obs summary {
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}
.obs-grid { padding: 0 14px 14px; display: grid; grid-template-columns: 6em 1fr; gap: 6px 12px; font-size: 14px; }
.obs-grid dt { color: var(--muted); font-size: 13px; }
.obs-grid dd { margin: 0; }

.alt-item { padding: 12px 14px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.alt-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.alt-name { font-weight: 600; font-size: 15px; }
.alt-price { color: var(--gold); font-weight: 700; white-space: nowrap; }
.alt-reason { font-size: 13px; color: var(--muted); line-height: 1.6; }

.section-label { font-size: 12px; color: var(--muted); padding: 12px 14px 0; letter-spacing: 0.08em; }

.foot { display: flex; gap: 10px; }
.foot button { flex: 1; padding: 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }

.src { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.7; }
.src a { color: var(--muted); }

/* ---------- 価格表 ---------- */
#list-body { padding: 0 16px 32px; }
.cat-block { margin-bottom: 20px; }
.cat-name {
  font-size: 14px;
  color: var(--gold);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 0 0 8px;
  position: sticky;
  top: 56px;
  background: var(--bg);
}
.li-item { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #1e222a; font-size: 14px; }
.li-name { line-height: 1.45; }
.li-price { color: var(--gold); white-space: nowrap; font-weight: 700; }
.li-price.none { color: var(--muted); font-weight: 400; }
