/* システムフォント・1カラム中央寄せ・アクセント1色。 */

:root {
  color-scheme: light;
  --bg: #fbfbfc;
  --surface: #ffffff;
  --border: #e2e4e8;
  --text: #2b2f36;
  --text-muted: #6b7280;
  --accent: #2563a8;
  --accent-weak: #eaf1f8;
  --danger: #a63a34;
  --danger-weak: #fbeeed;
  --warn: #8a5a17;
  --warn-weak: #fdf3e3;
  --radius: 6px;
  --thumb-bg: #ffffff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-weak: #1c2733;
  --danger: #f85149;
  --danger-weak: #2d1214;
  --warn: #d29922;
  --warn-weak: #2b2111;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-weak: #1c2733;
    --danger: #f85149;
    --danger-weak: #2d1214;
    --warn: #d29922;
    --warn-weak: #2b2111;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP",
    Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  transition: background 0.15s ease, color 0.15s ease;
}

h2 {
  font-size: 20px;
  margin: 0 0 8px;
}

h4 {
  font-size: 14px;
  margin: 0 0 8px;
}

a {
  color: var(--accent);
}

/* ------------------------------------------------------------------ ヘッダ */

.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-head-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-title {
  margin: 0;
  font-weight: 600;
}

.site-nav {
  display: flex;
  gap: 16px;
}

.site-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
}

.site-nav a.is-active {
  color: var(--accent);
  font-weight: 600;
}

.site-head-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--accent-weak);
}

/* ------------------------------------------------------------------ レイアウト */

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.lead {
  color: var(--text-muted);
  margin-top: 0;
}

.note {
  color: var(--text-muted);
  font-size: 13px;
}

.note-warn {
  color: var(--warn);
  background: var(--warn-weak);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.empty-note {
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ 入力 */

.dropzone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
}

.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.file-summary {
  margin: 8px 0 0;
  color: var(--text);
  font-weight: 600;
}

.option {
  margin: 20px 0;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.button {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button-quiet {
  color: var(--accent);
}

.button-danger {
  color: var(--danger);
}

/* ------------------------------------------------------------------ 進捗 */

.progress {
  margin: 20px 0;
}

.progress-status {
  margin: 0 0 4px;
  font-weight: 600;
}

.progress-count {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ------------------------------------------------------------------ 通知 */

.notice {
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
}

.notice-warn {
  background: var(--warn-weak);
  color: var(--warn);
}

.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 16px 0;
}

.banner-error {
  background: var(--danger-weak);
  color: var(--danger);
}

.banner-title {
  margin: 0;
  font-weight: 600;
}

.banner-detail {
  margin: 4px 0 0;
  font-size: 13px;
}

.error-code {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.75;
}

/* ------------------------------------------------------------------ ジョブヘッダ */

.job-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.job-title {
  margin: 0 0 4px;
  font-size: 20px;
  word-break: break-all;
}

.job-meta {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.job-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* コピーボタンの直後に並ぶため、間隔だけ足す(見た目は.button-quietを流用)。 */
.job-edit-keyword {
  margin-left: 8px;
}

/* ------------------------------------------------------------------ itemカード */

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

.item-not-found,
.item-error {
  color: var(--text-muted);
}

.item-error .item-state {
  color: var(--warn);
}

.item-head {
  margin-bottom: 8px;
}

.item-number {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.item-title {
  font-weight: 600;
  word-break: break-word;
}

.item-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.item-ebay-link {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.item-ebay-link:hover {
  color: var(--accent);
}

.item-open-hint {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  text-align: right;
  font-size: 13px;
  color: var(--text-muted);
}

.item.is-clickable:hover .item-open-hint {
  color: var(--accent);
}

.item-ebay {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.item-ebay-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--thumb-bg);
}

.item-ebay-price {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.item-state {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ 候補 */

.candidates {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.candidates-label {
  color: var(--text-muted);
  font-weight: 600;
}

.candidates-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.candidate-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.candidate {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.candidate-list > .candidate:first-child {
  border-top: none;
}

.candidate-top {
  background: var(--accent-weak);
  border-radius: var(--radius);
  padding: 12px;
}

.candidate-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--thumb-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.candidate-body {
  min-width: 0;
}

.candidate-title {
  margin: 0 0 4px;
  font-size: 14px;
  word-break: break-word;
}

.candidate-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.candidate-price {
  font-weight: 600;
  color: var(--text);
}

.candidates-rest > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  padding: 8px 0;
}

/* ------------------------------------------------------------------ 履歴 */

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.history-body {
  min-width: 0;
}

.history-name {
  margin: 0;
  font-weight: 600;
  word-break: break-all;
}

.history-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .history-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* -------------------------------------------------------- 詳細ポップアップ */

.item.is-clickable {
  cursor: pointer;
}

.item.is-clickable:hover {
  border-color: var(--accent);
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
  background: rgba(20, 24, 31, 0.4);
  backdrop-filter: blur(6px);
}

.detail-dialog {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(20, 24, 31, 0.2);
}

.detail-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.detail-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.detail-dialog-body {
  padding: 20px;
}

.detail-summary {
  margin-bottom: 20px;
}

.detail-number {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.detail-title {
  display: block;
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  word-break: break-word;
}

/* 貼り付け入力(商品番号なし)・NOT_FOUND(タイトルなし)で空欄が残らないようにする。 */
.detail-number:empty,
.detail-title:empty {
  display: none;
}

.detail-ebay-thumb {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--thumb-bg);
}

.detail-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.detail-figure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.detail-figure-label {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.detail-figure-value {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.detail-verdict {
  display: inline-block;
  margin: 0;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.verdict-recommended {
  background: var(--accent-weak);
  color: var(--accent);
}

.verdict-hold {
  background: var(--warn-weak);
  color: var(--warn);
}

.verdict-not-recommended {
  background: var(--danger-weak);
  color: var(--danger);
}

.verdict-unmatched {
  background: var(--bg);
  color: var(--text-muted);
}

.detail-flags {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-flag {
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-weak);
  border-radius: 4px;
  padding: 1px 8px;
}

.detail-state {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.detail-profit,
.detail-market,
.detail-sold,
.detail-basis {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.detail-label {
  font-size: 14px;
  color: var(--text-muted);
}

.detail-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ウォーターフォール */

.waterfall-row {
  display: grid;
  grid-template-columns: 92px 1fr 108px;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.waterfall-label {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.waterfall-track {
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}

.waterfall-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.waterfall-minus .waterfall-bar {
  background: var(--warn);
}

.waterfall-total .waterfall-bar {
  background: var(--text);
}

.waterfall-value {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.waterfall-total .waterfall-value {
  font-weight: 600;
}

.detail-rate,
.detail-p75,
.detail-shipping-basis {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ヒストグラム */

.detail-market-range,
.detail-market-quartiles {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.histogram {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 12px;
}

.histogram-column {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.histogram-track {
  height: 96px;
  display: flex;
  align-items: flex-end;
}

.histogram-bar {
  width: 100%;
  min-height: 1px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}

.histogram-count {
  margin: 4px 0 0;
  font-size: 12px;
}

.histogram-label {
  margin: 0;
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-muted);
}

/* 落札事例 */

.sold-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sold-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.sold-row:last-child {
  border-bottom: none;
}

.sold-thumb {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--thumb-bg);
  flex-shrink: 0;
}

.sold-body {
  min-width: 0;
}

.sold-title {
  display: block;
  margin: 0;
  font-size: 14px;
  word-break: break-word;
}

.sold-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.sold-price {
  font-weight: 600;
  color: var(--text);
}

.sold-condition {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 6px;
}

/* 照合根拠・候補一覧 */

.detail-basis-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.detail-matched-title {
  margin: 4px 0 0;
  word-break: break-word;
}

.detail-truncated {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* トークンピル */

.token-panel {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.token-pills {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.token-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  cursor: pointer;
}

/* 型番は実線の強調、辞書概念は破線。色だけに頼らず形でも見分けられるようにする。 */
.token-kind-model-number {
  border-color: var(--accent);
}

.token-kind-concept {
  border-style: dashed;
}

.token-pill.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.token-pill:disabled {
  opacity: 0.5;
  cursor: default;
}

.token-kind {
  font-size: 11px;
  opacity: 0.75;
}

.token-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.token-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.token-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.token-note-done {
  color: var(--accent);
}

.token-note-error {
  color: var(--danger);
}

/* 画像マッチングの2ボタン */

.image-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.image-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.image-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.image-note-done {
  color: var(--accent);
}

.image-note-error {
  color: var(--danger);
}

.detail-image-mode {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* 出品中検索(design-live-search §5.3)。落札事例と同じ骨格なので sold-* を流用し、
   ここでは出品中に固有の欄と操作だけを足す。 */
.live-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.live-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.live-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.live-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.live-filter.is-selected {
  border-color: var(--accent);
  color: var(--accent);
}

.live-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.live-note-done {
  color: var(--accent);
}

.live-note-error {
  color: var(--danger);
}

.live-candidates:empty {
  display: none;
}

/* 締切が読み取りの主目的なので、残り時間だけ本文色で立たせる。 */
.live-ends-at {
  color: var(--text);
}

.live-condition {
  font-weight: 600;
}

.live-stage-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* -------------------------------------------------------- 取り込みモードの切替 */

.mode-switch {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 20px;
}

.mode-tab {
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: none;
  color: var(--text-muted);
  padding: 8px 16px;
  margin-bottom: -1px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.mode-tab.is-active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

/* ------------------------------------------------------------ キーワード検索 */

.keyword-field {
  margin: 0 0 16px;
}

.keyword-label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.keyword-query,
.keyword-max-items {
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: 15px;
}

.keyword-max-items {
  max-width: 140px;
}

.keyword-query:disabled,
.keyword-max-items:disabled {
  opacity: 0.5;
}

.keyword-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.keyword-status-box {
  margin-top: 20px;
}

/* 0件は失敗ではないので、エラーの赤ではなく通常の面で出す。 */
.keyword-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ------------------------------------------------------ 商品名の貼り付け */

.paste-field {
  margin: 0 0 16px;
}

.paste-label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.paste-textarea {
  width: 100%;
  max-width: 640px;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: 15px;
  resize: vertical;
}

.paste-textarea:disabled {
  opacity: 0.5;
}

.paste-line-count {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.paste-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.paste-status-box {
  margin-top: 20px;
}

@media (max-width: 600px) {
  .detail-overlay {
    padding: 0;
  }

  .detail-figures {
    grid-template-columns: repeat(2, 1fr);
  }

  .waterfall-row {
    grid-template-columns: 76px 1fr 92px;
    gap: 8px;
  }
}
