/* 起源望远镜 · 本地复刻版 — 公共样式与商品总览 */

:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-2: #f5f8f9;
  --text: #12303a;
  --muted: #5f7885;
  --border: #d7e2e7;
  --accent: #14424e;
  --accent-soft: #e2eff1;
  --accent-line: #b9d3d8;
  --peak: #c8503f;
  --normal: #3f7f92;
  --off: #7c8c94;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(18, 48, 58, 0.06), 0 6px 16px rgba(18, 48, 58, 0.05);
  --font: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

button { font-family: inherit; cursor: pointer; }

/* ---------- 顶栏 ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 8px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #eaf5f6;
  font-size: 18px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 11px; }

.primary-nav { display: flex; gap: 4px; }

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--accent); color: #eaf5f6; }

.header-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.game-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
}

.game-clock__month { font-size: 12px; font-weight: 600; }
.game-clock__next { color: var(--muted); font-size: 11px; }

.data-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.data-status.is-ready .status-dot { background: #2f9e6b; }

/* ---------- 布局 ---------- */

.workspace {
  max-width: 1560px;
  margin: 0 auto;
  padding: 14px 20px 40px;
}

.toolbar { display: flex; align-items: center; gap: 10px; }

.search-field {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-field input {
  width: 100%;
  padding: 8px 40px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.search-field input:focus { outline: 2px solid var(--accent-line); outline-offset: -1px; }

.search-field kbd {
  position: absolute;
  right: 10px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.view-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-button {
  padding: 8px 14px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.view-button + .view-button { border-left: 1px solid var(--border); }
.view-button.is-active { background: var(--accent); color: #eaf5f6; }

.goods-search-context {
  margin: 8px 0 0;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.context-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.result-summary { font-size: 13px; font-weight: 600; }

.season-legend { display: flex; gap: 12px; margin-left: auto; }

/* 只作用于图例与商品卡片上的季节计数；不能命中季节表的单元格，
   否则 display: inline-flex 会覆盖 table-cell，把整行挤压到第一列。 */
.season-legend .season,
.row-counts .season {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.season b { font-size: 11px; }
.season.peak, .season-legend .peak { color: var(--peak); }
.season.normal, .season-legend .normal { color: var(--normal); }
.season.off, .season-legend .off { color: var(--off); }

.usage-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- 收藏 / 筛选 折叠架 ---------- */

.catalog-layout { margin-top: 12px; }

.catalog-column { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.shelf {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.shelf-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}

.shelf-toggle:hover { background: var(--surface-2); }
.shelf-icon { color: #c9a227; font-size: 14px; }
.shelf-label { display: flex; align-items: baseline; gap: 8px; }
.shelf-label small { color: var(--muted); font-size: 12px; }

.count-badge {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  text-align: center;
}

.shelf-chevron {
  width: 7px; height: 7px;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
}

.shelf-toggle[aria-expanded="true"] .shelf-chevron { transform: rotate(225deg) translate(-1px, -1px); }

.shelf-panel {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.filter-row { display: flex; gap: 10px; padding: 8px 0; align-items: flex-start; }

.filter-label {
  flex: 0 0 62px;
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.chip small { color: var(--muted); font-size: 10px; }
.chip:hover { border-color: var(--accent-line); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #eaf5f6; }
.chip.is-active small { color: #c7dde1; }

.clear-button {
  margin-top: 4px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.clear-button:hover { border-color: var(--accent-line); }

/* ---------- 收藏列表 ---------- */

.favorite-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

.favorite-item:last-child { border-bottom: 0; }

.favorite-open {
  flex: 1;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}

.favorite-open:hover { color: var(--accent); text-decoration: underline; }

.favorite-remove {
  width: 22px; height: 22px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  line-height: 1;
}

.favorite-empty { margin: 8px 0; color: var(--muted); font-size: 12px; }

/* ---------- 商品网格 / 列表 ---------- */

.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; }
.catalog.is-list { display: flex; flex-direction: column; gap: 6px; }

.goods-card, .goods-row {
  position: relative;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.goods-card { flex-direction: column; }
.goods-card.is-selected, .goods-row.is-selected { border-color: var(--accent); box-shadow: var(--shadow); }

.goods-main {
  display: flex;
  flex: 1;
  gap: 8px;
  padding: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}

.goods-card .goods-main { flex-direction: column; gap: 6px; }
.goods-row .goods-main { flex-direction: row; align-items: center; gap: 12px; }

.goods-tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
}

.goods-card .goods-tile { width: 44px; height: 44px; flex-basis: 44px; font-size: 18px; }
.goods-tile-letter { line-height: 1; }

.goods-thumb, .detail-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface);
}

/* 商品图标加载失败（原站也无图）时隐藏，露出兜底的首字方块或占位文字。 */
#catalog-workspace img.is-broken,
#goods-inspector img.is-broken,
#barter-workspace img.is-broken { visibility: hidden; }

.detail-title { display: flex; align-items: center; gap: 8px; }
.detail-tile { width: 48px; height: 48px; flex-basis: 48px; font-size: 18px; }

.goods-tile.tone-1 { background: #e6f0e6; color: #3f6b45; }
.goods-tile.tone-2 { background: #f2ece0; color: #7a6335; }
.goods-tile.tone-3 { background: #e6eaf4; color: #45547f; }
.goods-tile.tone-4 { background: #f3e8e8; color: #7d4744; }
.goods-tile.tone-5 { background: #e8eef0; color: #40595f; }
.goods-tile.tone-6 { background: #ece7f2; color: #584a75; }

.goods-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.goods-name { font-weight: 600; }

.special-ribbon {
  padding: 1px 6px;
  border: 1px solid #d9c07a;
  border-radius: 999px;
  background: #fdf6e3;
  color: #8a6d1f;
  font-size: 10px;
}

.goods-cat { color: var(--muted); font-size: 12px; }
.goods-row .goods-cat { flex: 0 0 108px; }

.goods-ports { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: auto; }
.goods-row .goods-ports { flex: 1; margin: 0; }

.port-line {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

.port-line b { font-size: 10px; }
.port-line.is-peak b { color: var(--peak); }
.port-line.is-normal b { color: var(--normal); }
.port-line.is-off b { color: var(--off); }
.port-line.is-none { color: var(--muted); }

.row-counts { display: flex; gap: 8px; flex: 0 0 auto; }
.row-counts b { font-size: 12px; font-weight: 600; }

.goods-fav {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #c8cfd3;
  font-size: 14px;
  line-height: 1;
}

.goods-fav:hover { background: var(--surface-2); color: #c9a227; }
.goods-fav.is-on { color: #e0a92c; }

.goods-row .goods-fav { position: static; order: 2; margin: 0 8px 0 0; align-self: center; }

.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- 商品详情浮层 ---------- */

/* 外层只负责定位，不拦截点击，页面其余部分照常可交互。 */
.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.detail-modal[hidden] { display: none; }

.goods-inspector {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.detail-modal__panel {
  /* 首选宽度放在变量里，脚本按卡片两侧的剩余空间收窄时不会覆盖它。 */
  --detail-panel-width: 400px;
  position: fixed;
  width: var(--detail-panel-width);
  max-width: calc(100vw - 24px);
  pointer-events: auto;
  box-shadow: 0 10px 30px rgba(18, 48, 58, 0.18);
}

.inspector-status {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
}

.inspector-close {
  width: 24px; height: 24px;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}

.inspector-close:hover { border-color: var(--accent-line); color: var(--text); }

#inspector-content { padding: 12px; }

.inspector-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 12px;
  color: var(--muted);
  font-size: 13px;
}

.inspector-empty-mark { font-size: 20px; color: var(--accent-line); }

.detail-head h2 { font-size: 16px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.tag.is-special { border-color: #d9c07a; background: #fdf6e3; color: #8a6d1f; }
.tag.is-current { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.tag.season.peak { border-color: #e6c3bd; background: #fbeeec; color: var(--peak); }
.tag.season.normal { border-color: #c3d8de; background: #eef5f7; color: var(--normal); }
.tag.season.off { border-color: #d8dfe2; background: #f4f6f7; color: var(--off); }

.detail-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.detail-block h3 { font-size: 13px; }
.detail-block h4 { margin-top: 8px; color: var(--muted); font-size: 12px; }
.detail-note { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.season-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 11px;
}

.season-table th, .season-table td {
  padding: 3px 2px;
  border: 1px solid var(--border);
  text-align: center;
}

.season-table thead th { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.season-table th.is-current { background: var(--accent-soft); color: var(--accent); }
.season-table tbody th { text-align: left; font-weight: 500; white-space: nowrap; padding-left: 6px; }
.season-table td { font-weight: 600; }
.season-table td.peak { color: var(--peak); }
.season-table td.normal { color: var(--normal); }
.season-table td.off { color: var(--off); }
.season-table td.is-current { background: var(--accent-soft); }

.preference-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.preference {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.preference-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.preference-head .bonus { color: var(--peak); font-weight: 600; }
.preference-scope { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

.preference-ports { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.port-chip {
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 11px;
}

/* ---------- 页脚 / 提示条 ---------- */

.site-footer {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1560px;
  margin: 0 auto;
  padding: 14px 20px 24px;
  color: var(--muted);
  font-size: 12px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #eaf5f6;
  font-size: 13px;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .detail-modal__panel { --detail-panel-width: 360px; }
}

@media (max-width: 720px) {
  .brand-row { flex-wrap: wrap; gap: 8px; }
  .header-actions { width: 100%; margin-left: 0; justify-content: space-between; }
  .goods-row .goods-cat, .goods-row .row-counts { display: none; }
}