:root {
  --bg: #f5f6f8; --card: #fff; --text: #1f2328; --muted: #6b7280; --line: #e3e6ea;
  --primary: #e60033; --primary-d: #c4002b; --accent: #2563eb; --ok: #15803d; --warn: #b45309; --err: #b91c1c;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif; }
a { color: var(--accent); }
code { background: #f0f1f3; padding: 1px 5px; border-radius: 4px; }
.topbar { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 54px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 18px; color: var(--primary); white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a { padding: 8px 16px; font-size: 16px; border-radius: 6px; color: var(--text); text-decoration: none; white-space: nowrap; }
.topbar nav a.active, .topbar nav a:hover { background: #f1f2f4; }
.topbar nav a.logout { margin-left: auto; color: var(--muted); }
.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 80px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card.narrow { max-width: 460px; margin: 40px auto; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.card > h2:first-of-type, form.card > h2:first-of-type { margin-top: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.notice { background: #ecfdf3; border: 1px solid #abefc6; color: #05603a; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert { background: #fef3f2; border: 1px solid #fecdca; color: #912018; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.err-text { color: var(--err); } .ok-text { color: var(--ok); }
.test-row { display: flex; gap: 10px; align-items: center; margin: -4px 0 12px; flex-wrap: wrap; } .note-text { color: var(--warn); }

.form label { display: block; margin-bottom: 14px; font-weight: 700; font-size: 15px; }
.form label small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; font-size: 13px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #b9c0c8; border-radius: 8px; font-size: 16px; font: inherit; background: #fff; color: inherit; margin-top: 4px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.check { display: inline-flex !important; align-items: center; gap: 6px; font-weight: 400 !important; margin: 4px 0; }
.check input { width: auto; margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 10px 16px; min-height: 44px; font-size: 15px; border: 1px solid #cfd4da; background: #fff; border-radius: 6px; cursor: pointer; font: inherit; color: inherit; white-space: nowrap; }
.btn:hover { background: #f5f6f8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--err); border-color: #f4b4b4; }
.btn.ghost { border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; min-height: 32px; }
.btn:disabled { opacity: .5; cursor: default; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.ship-table input, .ship-table select { margin: 0; min-width: 90px; }
.w-sm { width: 90px !important; } .w-md { width: 130px !important; }
.checks { width: 100%; margin: 12px 0; } .checks td { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.checks .ok { color: var(--ok); font-weight: 700; text-align: right; } .checks .ng { color: var(--err); font-weight: 700; text-align: right; }
.settings-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.settings-nav a { background: #fff; border: 1px solid var(--line); padding: 4px 12px; border-radius: 99px; text-decoration: none; color: var(--text); font-size: 13px; }

/* アップロード */
.dropzone { border: 2px dashed #c3c9d1; border-radius: var(--radius); padding: 28px; display: flex; gap: 16px; align-items: center; justify-content: center; text-align: center; cursor: pointer; background: #fafbfc; transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: #fff5f7; }
.dz-icon { font-size: 34px; }
.upload-opts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; align-items: center; font-size: 13px; }
.upload-opts label { display: inline-flex; gap: 4px; align-items: center; }

/* 一覧 */
.list-head { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 1px solid #cfd4da; background: #fff; padding: 8px 14px; border-radius: 99px; cursor: pointer; font: inherit; font-size: 15px; color: inherit; }
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.tab .cnt { margin-left: 6px; font-size: 11px; opacity: .7; }
.list-tools input { width: 220px; margin: 0; }
.bulkbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 10px; background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; position: sticky; top: 60px; z-index: 5; }

.bulkbar:not(.active) > .btn { opacity: .6; }
.items { display: flex; flex-direction: column; gap: 8px; }
.item { display: grid; grid-template-columns: 36px 120px 1fr auto; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.item.sel { border-color: var(--primary); background: #fff8f9; }
.item-check { display: flex; align-items: center; justify-content: center; height: 100%; cursor: pointer; }
.item-check input { width: 26px; height: 26px; cursor: pointer; }
.thumb { width: 120px; height: 120px; border-radius: 6px; overflow: hidden; background: #f0f1f3; display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-count { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 0 5px; border-radius: 4px; }
.item-body { min-width: 0; }
.item-top { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.inline-title { width: 100%; margin: 0 0 4px; font-weight: 600; border-color: transparent; padding: 4px 6px; margin-left: -6px; }
.inline-title:hover { border-color: #cfd4da; }
.title-skel { color: var(--muted); padding: 4px 0; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.meta { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 14px; color: #4b5563; }
.badge { font-size: 13px; padding: 2px 10px; border-radius: 99px; font-weight: 600; background: #eef0f3; }
.st-analyzing { background: #eef2ff; color: #3730a3; }
.st-ready { background: #ecfdf3; color: #067647; }
.st-queued { background: #fffaeb; color: #b54708; }
.st-processing { background: #fff4ed; color: #c4320a; }
.st-listed { background: #eff8ff; color: #175cd3; }
.st-sold { background: #f4f3ff; color: #5925dc; }
.st-ended { background: #f2f4f7; color: #475467; }
.st-error { background: #fef3f2; color: #b42318; }
.st-relist { background: #fdf2fa; color: #c11574; }
@media (max-width: 640px) {
  .item { grid-template-columns: 32px 84px 1fr; }
  .thumb { width: 84px; height: 84px; }
  .item-actions { grid-column: 2 / -1; }
  .list-tools input { width: 100%; }
  .bulkbar { position: static; }
}

/* 編集ダイアログ */
.editor { width: min(1040px, 96vw); max-height: 94vh; border: none; border-radius: 12px; padding: 0; }
.editor::backdrop { background: rgba(15, 23, 42, .5); }
.editor form { display: flex; flex-direction: column; max-height: 94vh; }
.ed-head, .ed-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.ed-head h2 { margin: 0; border: 0; padding: 0; flex: 1; }
.ed-foot { border-top: 1px solid var(--line); border-bottom: 0; }
.spacer { flex: 1; }
.ed-body { display: grid; grid-template-columns: 340px 1fr; gap: 20px; padding: 18px; overflow-y: auto; }
@media (max-width: 800px) { .ed-body { grid-template-columns: 1fr; } }
.ed-main { width: 100%; aspect-ratio: 1; background: #f0f1f3; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.ed-main img { width: 100%; height: 100%; object-fit: contain; }
.ed-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.et { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #f0f1f3; }
.et img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.et-tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; background: rgba(0,0,0,.5); }
.et-tools button { background: none; border: 0; color: #fff; cursor: pointer; padding: 2px 6px; font-size: 11px; }
.et-tools button:disabled { opacity: .3; }
.ed-fields label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.ai-note { background: #fffaeb; border: 1px solid #fedf89; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--err); }

/* ---- わかりやすさ向上 ---- */
.page-title { font-size: 24px; margin: 4px 0 4px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.notice.big, .alert.big { font-size: 16px; padding: 14px 18px; }
.steps { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0; margin: 0 0 16px; }
.steps li { counter-increment: s; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 12px 56px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.steps b { display: block; font-size: 17px; } .steps span { font-size: 13px; color: var(--muted); }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }
.step-no { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 15px; margin-right: 6px; vertical-align: 1px; }
.h-step { font-size: 19px; border: 0; padding: 0; margin: 0 0 14px; }
.card h2 { font-size: 19px; }
.kw-label { display: block; font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.kw-label small { font-weight: 400; color: var(--muted); font-size: 13px; }
.kw-input { font-size: 18px !important; padding: 14px 16px !important; margin-bottom: 14px; border-width: 2px !important; }
.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 640px) { .mode-pick { grid-template-columns: 1fr; } }
.mode { display: flex; gap: 10px; align-items: flex-start; border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; background: #fff; }
.mode input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.mode b { display: block; font-size: 16px; } .mode small { color: var(--muted); font-size: 13px; }
.mode:has(input:checked) { border-color: var(--primary); background: #fff5f7; }
.mode.inline { border: 0; padding: 6px 0; background: none; }
.dropzone { padding: 34px 20px; border-width: 3px; }
.dz-icon { font-size: 48px; }
.dz-text b { font-size: 20px; color: var(--primary); } .dz-text span { font-size: 14px; color: var(--muted); }
.small-details { margin: 10px 0; } .small-details summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.progress { margin-top: 12px; padding: 12px 16px; background: #eff8ff; border-radius: 8px; font-size: 16px; font-weight: 700; color: #175cd3; }
.btn.huge { font-size: 17px; padding: 12px 22px; min-height: 52px; font-weight: 700; }
.big-check { font-size: 16px !important; } .big-check input { width: 22px; height: 22px; }
.sel-count { font-weight: 700; }
.bulkbar { gap: 10px; padding: 12px; }
.more { position: relative; } .more > summary { list-style: none; } .more > summary::-webkit-details-marker { display: none; }
.more-menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 260px; box-shadow: 0 10px 30px rgba(0,0,0,.15); z-index: 20; }
.more-menu .btn { justify-content: flex-start; }
.item { padding: 12px; }
.item-title { font-weight: 700; font-size: 17px; margin: 2px 0 6px; word-break: break-all; }
.title-skel { font-size: 16px; }
.cat-ok { color: #067647; } .cat-auto { color: var(--muted); }
.fix-btn { font-size: 16px; padding: 10px 18px; }
.err-text { font-size: 15px; }
.empty { text-align: center; font-size: 17px; color: var(--muted); padding: 30px 0; }
.cat-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; background: #fafbfc; }
.cat-head { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.cat-current { font-size: 16px; margin-bottom: 8px; color: #067647; }
.cat-cands { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.cand { text-align: left; border: 1px solid #cfd4da; background: #fff; border-radius: 8px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.cand:hover { border-color: var(--accent); } .cand.on { border-color: var(--ok); background: #ecfdf3; font-weight: 700; }
.cat-search { display: flex; gap: 8px; } .cat-search input { margin: 0; }
.advanced > summary { cursor: pointer; font-weight: 700; font-size: 16px; }
.advanced[open] > summary { margin-bottom: 14px; }
.save-bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 10px; text-align: center; margin-bottom: 16px; }
.save-bar .btn { min-width: 260px; }
#basic > .card { margin-bottom: 16px; }
.copy-field { display: flex; gap: 8px; } .copy-field input { margin: 0; }
.ship-cards { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.ship-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 6px; background: #fafbfc; }
.ship-card.is-new { border-style: dashed; background: #fff; }
.ship-new-title { font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.ship-foot { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 6px; }
.danger-text { color: var(--err); }
