:root {
  --ink: #1a2333;
  --muted: #5a6577;
  --faint: #8a94a6;
  --line: #e3e8f1;
  --bg: #f5f7fb;
  --card: #ffffff;
  --accent: #7c4dff;
  --grad: linear-gradient(90deg, #2f6bff, #7c4dff, #c86dd7, #f6588a, #ff9a3d);
  --shadow: 0 4px 18px rgba(30, 50, 90, 0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--grad) top / 100% 4px no-repeat, var(--bg);
  line-height: 1.7;
  min-height: 100vh;
}
a { color: var(--accent); }
button { font-family: inherit; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px 16px 48px; }

/* ヘッダー */
.header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 14px; }
.logo {
  width: 72px; height: 54px; border-radius: 12px; flex: 0 0 72px;
  background: #fff; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: 0 4px 18px rgba(60, 59, 110, 0.25);
}
.logo img { width: 64px; height: 34px; display: block; }
.title {
  font-size: 1.9rem; font-weight: 800; letter-spacing: 0.5px; line-height: 1.15;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.title .tag {
  display: inline-block; font-size: 0.66rem; font-weight: 700; color: var(--faint); -webkit-text-fill-color: var(--faint);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; margin-left: 10px; background: #fff; vertical-align: middle;
}
.subtitle { color: var(--faint); font-size: 0.85rem; margin-top: 2px; }
.status-badge {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  background: #e6f4ea; border-radius: 999px; padding: 6px 14px; white-space: nowrap; font-size: 0.82rem; font-weight: 600; color: #137333;
}
.status-badge .dot { width: 9px; height: 9px; border-radius: 50%; background: #34a853; box-shadow: 0 0 8px #34a853; }
.account { font-size: 0.8rem; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.account button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); cursor: pointer; font-size: 0.78rem; }

/* カード */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 18px 20px; }
.hero { position: relative; overflow: hidden; background: var(--grad) top / 100% 4px no-repeat, #fff; margin-bottom: 14px; }
.hero h3 { margin: 0 0 4px; font-size: 1.2rem; }
.hero p { margin: 0 0 12px; color: var(--muted); font-size: 0.86rem; }
.hero::after {
  content: ""; position: absolute; top: 0; left: 0; height: 100%; width: 38%;
  background: linear-gradient(100deg, transparent, rgba(124,77,255,0.06), transparent);
  animation: scan 3.2s linear infinite; pointer-events: none;
}
@keyframes scan { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }
.stats { display: flex; flex-wrap: wrap; gap: 10px; position: relative; z-index: 1; }
.stat { flex: 1 1 130px; border-radius: 14px; padding: 12px 14px; color: #fff; box-shadow: 0 4px 18px rgba(30,50,90,0.1); }
.stat:nth-child(1) { background: linear-gradient(135deg, #2f6bff, #55a4ff); }
.stat:nth-child(2) { background: linear-gradient(135deg, #7c4dff, #c86dd7); }
.stat:nth-child(3) { background: linear-gradient(135deg, #f6588a, #ff9a3d); }
.stat:nth-child(4) { background: linear-gradient(135deg, #ff9a3d, #ffc53d); }
.stat .v { font-size: 1.2rem; font-weight: 700; }
.stat .l { font-size: 0.72rem; opacity: 0.92; }

/* レイアウト */
.grid { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }
.side h4, .main h4 { margin: 0 0 8px; font-size: 0.95rem; }
label.lbl { display: block; font-size: 0.8rem; color: var(--muted); margin: 10px 0 4px; }
select, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"] {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 0.95rem; font-family: inherit; background: #fff; color: var(--ink);
}
select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,77,255,0.15); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 11px 18px; font-size: 0.98rem; font-weight: 700; cursor: pointer; color: #fff;
  background: linear-gradient(90deg, #2f6bff, #7c4dff 70%, #c86dd7); box-shadow: 0 4px 14px rgba(124,77,255,0.3);
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn.ghost { background: #fff; color: var(--accent); border: 1px solid var(--line); box-shadow: none; font-weight: 600; padding: 7px 12px; font-size: 0.85rem; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; border-radius: 9px; }
.hint { font-size: 0.78rem; color: var(--faint); margin-top: 6px; }

/* 進捗 */
.progress { display: none; align-items: center; gap: 12px; padding: 14px 16px; margin-top: 12px; border-radius: 12px; background: rgba(124,77,255,0.06); border: 1px solid rgba(124,77,255,0.2); font-size: 0.9rem; }
.progress.on { display: flex; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(124,77,255,0.25); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex: 0 0 20px; }
@keyframes spin { to { transform: rotate(360deg); } }
.err { display: none; margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: #fdecea; border: 1px solid #f5c2c0; color: #a32d2d; font-size: 0.9rem; white-space: pre-wrap; }
.err.on { display: block; }

/* 結果 */
.result-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.result-title { border-left: 4px solid var(--accent); background: linear-gradient(90deg, rgba(124,77,255,0.09), transparent 80%); border-radius: 8px; padding: 7px 12px; font-weight: 700; flex: 1 1 auto; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.md { font-size: 0.95rem; }
.md h2 { font-size: 1.08rem; margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.md h2:first-child { margin-top: 0; }
.md table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.88rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; white-space: nowrap; }
.md th { background: #f5f7fb; }
.md td:first-child { white-space: normal; min-width: 140px; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: 2px 0; }
.note { font-size: 0.78rem; color: var(--faint); margin-top: 10px; }

/* 履歴 */
.history { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.history li { padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 0.85rem; border: 1px solid transparent; }
.history li:hover { background: #f5f7fb; }
.history li.active { border-color: var(--accent); background: rgba(124,77,255,0.06); }
.history .d { font-size: 0.72rem; color: var(--faint); }
.empty { font-size: 0.82rem; color: var(--faint); }

/* ログイン */
.login { max-width: 460px; margin: 40px auto; text-align: center; }
.login h2 { margin: 0 0 6px; font-size: 1.25rem; }
.login p { color: var(--muted); font-size: 0.9rem; margin: 0 0 14px; }
.login #codeInput { text-align: center; font-size: 1.05rem; letter-spacing: 1px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.login .authform { text-align: left; }
.login .authform .lbl { margin-top: 12px; }
.login .authnote { text-align: left; background: #f0fdf4; color: #166534; border-radius: 10px; padding: 10px 14px; font-size: 0.84rem; }
.authtabs { display: flex; border-bottom: 2px solid var(--line); margin-bottom: 14px; }
.authtabs button { flex: 1; padding: 10px 0; border: none; background: none; font-size: 0.95rem; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit; }
.authtabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.authlegacy { margin-top: 16px; text-align: left; font-size: 0.84rem; color: var(--muted); }
.authlegacy summary { cursor: pointer; }
.authlegacy input { margin-top: 8px; }
.authlegacy .btn.wide { margin-top: 8px; }
.hidden { display: none !important; }
.chip { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; background: #eef0f5; color: var(--muted); }
.chip.ok { background: #e6f4ea; color: #137333; }
.chip.ng { background: #fdecea; color: #a32d2d; }
.footer { text-align: center; font-size: 0.75rem; color: var(--faint); margin-top: 30px; }

/* ===== eBay 版 追加 ===== */
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; font-size: 0.85rem; color: var(--muted); }
.topbar .quota { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 600; }
.ext { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--line); background: #fff; }
.ext.on { background: #e6f4ea; color: #137333; border-color: #b7e1c1; }
.ext.off { background: #fff4e5; color: #9a5b00; border-color: #ffd699; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.tabs button { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 7px 14px; font-size: 0.86rem; font-weight: 600; cursor: pointer; }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.mode { display: flex; gap: 8px; flex-wrap: wrap; }
.mode label { flex: 1 1 200px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; background: #fff; font-size: 0.88rem; }
.mode label.sel { border-color: var(--accent); background: rgba(124,77,255,0.06); }
.mode input { margin-right: 6px; }
.mode small { display: block; color: var(--faint); font-size: 0.76rem; margin-top: 2px; }
.genres { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 6px; }
.genres button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 10px; text-align: left; cursor: pointer; font-size: 0.86rem; line-height: 1.4; }
.genres button.sel { border-color: var(--accent); background: rgba(124,77,255,0.08); font-weight: 700; }
.genres button small { display: block; color: var(--faint); font-size: 0.72rem; font-weight: 400; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
@media (max-width: 640px) { .steps { grid-template-columns: 1fr; } }
.step { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; font-size: 0.84rem; }
.step.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,77,255,0.12); }
.step.done { border-color: #b7e1c1; background: #f3faf5; }
.step .n { font-weight: 700; }
.step .d { color: var(--faint); font-size: 0.76rem; }
.bar { height: 8px; border-radius: 999px; background: #eef0f5; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .4s; }
.cards { display: grid; gap: 10px; margin-top: 10px; }
.cand { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 14px 16px; box-shadow: var(--shadow); }
.cand.good { border-color: #b7e1c1; }
.cand .ttl { font-weight: 700; font-size: 0.98rem; line-height: 1.45; }
.cand .ttl a { color: var(--ink); text-decoration: none; }
.cand .ttl a:hover { text-decoration: underline; }
.nums { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 8px 0 4px; font-size: 0.86rem; color: var(--muted); }
.nums b { color: var(--ink); font-size: 1.05rem; }
.nums .profit b { color: #137333; }
.nums .profit.neg b { color: #a32d2d; }
.flags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.flag { background: #fdecea; color: #a32d2d; border-radius: 6px; padding: 2px 8px; font-size: 0.74rem; font-weight: 600; }
.flag.warn { background: #fff4e5; color: #9a5b00; }
.reason { font-size: 0.86rem; color: var(--muted); margin: 6px 0; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
details.calc { margin-top: 8px; font-size: 0.8rem; color: var(--muted); }
details.calc summary { cursor: pointer; }
details.calc table { border-collapse: collapse; margin-top: 6px; }
details.calc td { padding: 2px 10px 2px 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 0.78rem; background: #f5f7fb; }
.scroll { overflow-x: auto; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.kpis { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.kpi { flex: 1 1 140px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: #fff; }
.kpi .v { font-size: 1.3rem; font-weight: 700; }
.kpi .l { font-size: 0.74rem; color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.5px; }
.sortbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 0.82rem; color: var(--muted); margin-top: 10px; }
.sortbar button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 0.78rem; cursor: pointer; }
.sortbar button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 0.9rem; font-family: inherit; min-height: 80px; }
.guide { background: #fff; border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; font-size: 0.86rem; color: var(--muted); margin-top: 12px; }
.guide ol { margin: 6px 0 0; padding-left: 1.3em; }

/* 候補カードの画像（左: eBay 実売 ／ 仕入先） */
.cand { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.cand .body { min-width: 0; }
.media { display: flex; flex-direction: column; gap: 8px; width: 132px; flex: 0 0 132px; }
.thumb { position: relative; display: block; width: 132px; height: 132px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; text-decoration: none; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; font-size: 0.68rem; line-height: 1.3; padding: 2px 6px; color: #fff; background: rgba(26,35,51,0.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb.none { background: #f5f7fb; }
.thumb.none::before { content: "画像なし"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.74rem; color: var(--faint); }
@media (max-width: 640px) {
  .cand { grid-template-columns: 1fr; }
  .media { flex-direction: row; width: auto; flex: none; }
  .thumb { width: 108px; height: 108px; }
}

/* Claude の API キー未登録の案内（BYOK・2026-10-24） */
.ai-key-notice { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: #fff4e5; color: #7a4a00; border: 1px solid #f3c27a; font-size: 13px; line-height: 1.7; }
.ai-key-notice a { color: #b45309; font-weight: 700; }
