/* メルサクと同じトーン：メルカリの赤を少し落ち着かせた色を軸に、毎日見ても疲れない配色 */
:root {
  --bg: #f7f5f2; --surface: #ffffff; --surface-2: #f3f0ec; --text: #2a2624; --sub: #7a726d; --line: #ebe6e1;
  --accent: #e0483e; --accent-strong: #c43c33; --accent-soft: #fcefed; --accent-line: #f3cbc6;
  --ok: #2e9e6a; --ok-soft: #e6f4ec; --warn-bg: #fff6e0; --warn: #8a5a00; --danger: #c43c33;
  --shadow: 0 1px 2px rgba(60, 40, 30, .04), 0 6px 20px rgba(60, 40, 30, .05);
  --overlay: rgba(42, 38, 36, .45);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171513; --surface: #211e1c; --surface-2: #2b2725; --text: #ede8e4; --sub: #a39a94; --line: #36312e;
    --accent: #ef645a; --accent-strong: #f27a71; --accent-soft: #3a2523; --accent-line: #6b3833;
    --ok: #5cc48f; --ok-soft: #1d3328; --warn-bg: #3a3017; --warn: #f5c66b; --danger: #f27a71; --shadow: none;
    --overlay: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171513; --surface: #211e1c; --surface-2: #2b2725; --text: #ede8e4; --sub: #a39a94; --line: #36312e;
  --accent: #ef645a; --accent-strong: #f27a71; --accent-soft: #3a2523; --accent-line: #6b3833;
  --ok: #5cc48f; --ok-soft: #1d3328; --warn-bg: #3a3017; --warn: #f5c66b; --danger: #f27a71; --shadow: none;
  --overlay: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* 画面全体は動かさず、真ん中だけスクロールさせる（下のバーがずれないように） */
html, body { height: 100%; }
body {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.scroller { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
svg { flex-shrink: 0; display: block; }
button, input, textarea { font: inherit; color: inherit; }
.pre { white-space: pre-wrap; word-break: break-word; }
.sub { color: var(--sub); }

/* ===== 上のバー ===== */
.appbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.appbar .in { max-width: 640px; margin: 0 auto; padding: 10px 16px; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.wm {
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif; font-weight: 800;
  font-size: 21px; letter-spacing: .04em; color: var(--text); line-height: 1;
}
.wm b { color: var(--accent); font-weight: 800; }
.back { display: inline-flex; align-items: center; gap: 0; height: 36px; padding: 0 10px 0 2px; margin-left: -8px; border: 0; background: none; border-radius: 10px; color: var(--text); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.back:active { background: var(--surface-2); }
.pill {
  flex: none; font: inherit; font-size: 13px; color: var(--accent-strong); background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; white-space: nowrap;
}
.pill:active { opacity: .7; }
.pill.small { font-size: 12px; padding: 2px 10px; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 24px; }
.hero { padding: 22px 2px 6px; }
.hero h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: .02em; text-wrap: balance; }
.hero p { margin: 0; color: var(--sub); font-size: 13px; }

/* ステップ見出し */
.sec { display: flex; align-items: center; gap: 10px; margin: 26px 2px 10px; font-size: 14px; font-weight: 700; }
.sec span {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--accent-strong); background: var(--accent-soft);
  border-radius: 6px; padding: 2px 7px; white-space: nowrap;
}
.sec .aside { margin-left: auto; font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--sub); background: none; padding: 0; }
.sec.done span:first-child { color: #fff; background: var(--ok); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.lbl { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.lbl .right { display: flex; align-items: center; gap: 8px; }
.field + .field { margin-top: 18px; }
.field .lbl { margin-bottom: 8px; }
.hint { color: var(--sub); font-size: 12px; margin: 8px 0 0; }
.badge { flex: none; font-size: 11px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); border-radius: 999px; padding: 1px 9px; }
.badge.draft { color: var(--sub); background: var(--surface-2); }
.count { font-size: 12px; color: var(--sub); font-weight: 500; font-variant-numeric: tabular-nums; }
.count.ok { color: var(--ok); font-weight: 700; }
.count.ng { color: var(--accent); font-weight: 700; }

input[type=text], input[type=search], textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  border: 1px solid transparent; border-radius: 12px; padding: 11px 13px; outline: none; transition: border-color .15s, background .15s;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus { border-color: var(--accent-line); background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--sub); opacity: .7; }
textarea { line-height: 1.75; resize: vertical; display: block; }
textarea.desc { min-height: 320px; font-size: 15px; }
.yen { position: relative; }
.yen span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--sub); }
.yen input { padding-left: 30px; font-variant-numeric: tabular-nums; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 13px; margin: 10px 0 0; }
.warn:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font: inherit; font-size: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px; cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-strong); font-weight: 700; }
.chip.on::before { content: "✓ "; }
.chip b { font-weight: 500; color: var(--sub); margin-left: 4px; font-size: 12px; }
.chip.on b { color: inherit; }

/* ===== ボタン ===== */
.btn { font: inherit; border: none; border-radius: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-main {
  flex: 1; background: var(--accent); color: #fff; font-size: 16px; font-weight: 700; padding: 14px; letter-spacing: .03em;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn-main:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface-2); color: var(--sub); font-size: 13px; padding: 14px 12px; }
.btn-ghost:active { opacity: .7; }
.btn-ghost.danger { color: var(--danger); }
.btn-copy {
  width: 100%; background: var(--surface); color: var(--accent-strong); border: 1.5px solid var(--accent-line);
  font-weight: 700; padding: 12px; font-size: 15px; margin-top: 10px;
}
.btn-copy:active { background: var(--accent-soft); }
.btn-copy.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-link { background: none; color: var(--sub); font-size: 13px; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }
.block { display: flex; width: 100%; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }

/* 下の固定バー */
.bar { flex: none; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
.bar[hidden] { display: none; }
.bar .in { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.progress { font-size: 11px; color: var(--sub); text-align: center; line-height: 1.3; min-width: 52px; }
.progress b { display: block; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ===== 一覧 ===== */
.tools { display: grid; gap: 10px; margin: 14px 0 12px; }
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; margin: 0; color: inherit; text-decoration: none; padding: 12px; }
.item:active { background: var(--surface-2); }
.thumb {
  flex: none; width: 72px; height: 72px; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); color: var(--sub); display: flex; align-items: center; justify-content: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.info { min-width: 0; flex: 1; display: grid; gap: 4px; }
.info .t { font-weight: 700; font-size: 15px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--sub); }
.meta .price { font-weight: 700; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--sub); font-size: 14px; padding: 32px 8px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; }
.steps b { color: var(--accent-strong); }

/* ===== 写真 ===== */
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
@media (min-width: 480px) { .photos { grid-template-columns: repeat(5, 1fr); } }
.ph { position: relative; aspect-ratio: 1; max-width: 100%; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .num {
  position: absolute; left: 4px; top: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: rgba(42, 38, 36, .62); color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
}
.ph:first-child .num { background: var(--accent); }
.ph.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1.5px dashed var(--accent-line); background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; font-weight: 700; }
.ph:active { opacity: .7; }

/* ===== 詳細 ===== */
.title-box { font-size: 16px; font-weight: 600; background: var(--surface-2); border-radius: 12px; padding: 13px; word-break: break-all; margin-top: 10px; }
.desc-box { font-size: 14px; line-height: 1.75; background: var(--surface-2); border-radius: 12px; padding: 13px; margin-top: 10px; white-space: pre-wrap; word-break: break-word; }
.desc-box.clamp { max-height: 11em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 65%, transparent); mask-image: linear-gradient(#000 65%, transparent); }
.memo p { margin: 8px 0 0; font-size: 14px; }
.more { display: grid; gap: 8px; margin-top: 22px; }

/* ===== 設定 ===== */
.tpl { display: block; width: 100%; padding: 10px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.tpl:first-of-type { border-top: 0; }
.tpl b { display: block; font-size: 15px; }
.tpl span { display: block; font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch-row > span { flex: 1; font-size: 15px; font-weight: 700; }
.switch-row small { display: block; font-size: 12px; font-weight: 400; color: var(--sub); margin-top: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; border-radius: 16px;
  background: var(--line); position: relative; transition: background .2s; margin: 0; cursor: pointer;
}
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }

/* ===== シート・ダイアログ・写真ビューア ===== */
.sheet-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.sheet-root.open { pointer-events: auto; }
.sheet-root:empty { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--overlay); opacity: 0; transition: opacity .2s; }
.sheet-root.open .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet-root.open .sheet { transform: none; }
.sheet-box { background: var(--surface); border-radius: 16px; overflow: hidden; }
.sheet-title { padding: 12px; text-align: center; font-size: 13px; color: var(--sub); border-bottom: 1px solid var(--line); }
.sheet-list { max-height: 60vh; overflow-y: auto; }
.sheet-btn {
  display: block; width: 100%; min-height: 54px; padding: 12px 16px; border: 0; border-top: 1px solid var(--line);
  background: var(--surface); color: var(--accent-strong); font-size: 16px; text-align: center; cursor: pointer;
}
.sheet-list .sheet-btn:first-child { border-top: 0; }
.sheet-btn small { display: block; font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-btn.danger { color: var(--danger); }
.sheet-btn.cancel { margin-top: 8px; border-radius: 16px; border-top: 0; font-weight: 700; color: var(--text); }
.sheet-btn:active { background: var(--surface-2); }
.dialog {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(320px, calc(100% - 48px)); padding: 20px 16px 16px;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(42, 38, 36, .25);
  opacity: 0; transition: opacity .15s;
}
.sheet-root.open .dialog { opacity: 1; }
.dialog p { margin: 0 0 16px; text-align: center; font-size: 15px; }
.dialog .btn-row .btn { padding: 12px; font-size: 15px; }
.btn-main.danger { background: var(--danger); box-shadow: none; }
.viewer {
  position: absolute; inset: 0; background: #000; color: #fff; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
.viewer-top { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 16px; font-size: 14px; }
.viewer-top button { width: 44px; height: 44px; border: 0; background: none; color: #fff; font-size: 20px; cursor: pointer; }
.viewer-img { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-bar { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 8px; padding: 12px 16px; }
.viewer-bar .btn-ghost { background: rgba(255, 255, 255, .14); color: #fff; }

/* ===== トースト・処理中 ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); z-index: 70;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 700; white-space: nowrap;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.busy { position: fixed; inset: 0; z-index: 80; background: var(--overlay); display: flex; align-items: center; justify-content: center; }
.busy[hidden] { display: none; }
.busy-box { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-radius: 16px; background: var(--surface); font-size: 15px; font-weight: 700; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .spinner { animation-duration: 2s; } }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 登録画面：下書き／出品中の切り替え */
.bar-stack { flex: 1; display: grid; gap: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; }
.seg button {
  font: inherit; font-size: 14px; font-weight: 700; color: var(--sub); background: none; border: 1px solid transparent;
  border-radius: 10px; padding: 9px 8px; cursor: pointer; line-height: 1.3;
}
.seg button.on { background: var(--surface); color: var(--accent-strong); border-color: var(--accent-line); box-shadow: var(--shadow); }
.seg button.on::before { content: "✓ "; }

/* 詳細画面：削除ボタン */
.btn-delete {
  width: 100%; background: var(--surface); color: var(--danger); border: 1.5px solid var(--danger);
  font-weight: 700; font-size: 15px; padding: 12px;
}
.btn-delete:active { background: var(--accent-soft); }
.detail-seg { margin-top: 16px; }

/* 詳細画面：再出品カウンター */
.relist { display: flex; align-items: center; gap: 12px; margin: 10px 0 0; }
.relist-info { flex: 1; min-width: 0; }
.relist-label { font-size: 12px; font-weight: 700; color: var(--sub); }
.relist-num { font-size: 14px; font-weight: 700; line-height: 1.2; }
.relist-num b { font-size: 30px; color: var(--accent-strong); margin-right: 2px; font-variant-numeric: tabular-nums; }
.relist-last { font-size: 12px; color: var(--sub); }
.relist-btns { display: flex; gap: 8px; }
.relist-btns .btn { margin: 0; width: auto; }
.relist-minus { width: 48px !important; font-size: 20px; padding: 10px 0; }
.relist-plus { padding: 12px 16px; font-size: 16px; }
