* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.app { min-height: 100%; display: flex; flex-direction: column; }

.top {
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 20px;
  gap: 18px;
}
.brand { font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.site-tabs { display: flex; gap: 8px; align-items: center; }
.site-tab {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.site-tab.is-active { border-color: var(--ink); font-weight: 700; }

.mission-page { flex: 1; background: #fcfcfc; }
.mission-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.check-filter { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; }
.check-filter input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.mission-content { max-width: 1040px; padding: 16px 20px 36px; }
.mission-cards { display: grid; gap: 12px; }
.mission-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  background: #fff;
}
.mission-card-head { display: flex; justify-content: space-between; gap: 12px; }
.mission-card h2 { margin: 0; font-size: 17px; line-height: 1.4; }
.mission-card-desc { margin: 12px 0 0; font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.mission-card-date { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.mission-rewards { margin-top: 14px; }
.mission-rewards h3 { margin: 0 0 8px; font-size: 13px; }
.mission-card-skeleton {
  min-height: 170px;
  background: linear-gradient(90deg, #f0f0f0 25%, #fafafa 37%, #f0f0f0 63%);
  background-size: 400% 100%;
  animation: shine 1.1s infinite;
}
.mission-pager { margin-top: 18px; }

.toolbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px 14px;
  display: grid;
  gap: 10px;
}
.row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: end; }
.field .hint {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  width: 190px;
  max-width: none;
  background: var(--panel);
  z-index: 2;
}
.field, .combo { display: flex; flex-direction: column; gap: 4px; min-width: 0; position: relative; }
.field.grow { flex: 1 1 220px; }
.field label, .combo label { font-size: 12px; color: var(--muted); }
.field input, .field select, .combo input {
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  padding: 0 10px;
}
.q { width: 100%; min-width: 180px; }
.min { width: 128px; }
select.narrow { min-width: 112px; }
select.position-select { min-width: 148px; }
.hint { font-size: 11px; color: var(--faint); line-height: 1.35; max-width: 168px; }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }

.btn {
  height: 36px;
  border-radius: 4px;
  padding: 0 16px;
  border: 1px solid transparent;
}
.btn-search {
  background: var(--accent);
  color: #fff;
  border-bottom: 2px solid var(--accent-deep);
  font-weight: 700;
}
.btn-search:hover { background: var(--accent-deep); }
.btn-reset { background: #fff; border-color: var(--line-strong); }
.btn-reset:hover { background: var(--tile); }
.btn:disabled { opacity: 0.45; cursor: default; }

.combo { position: relative; min-width: 168px; }
.combo input { width: 100%; }
.menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  display: none;
}
.menu.open { display: block; }
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  padding: 8px 10px;
}
.menu button:hover, .menu button.active { background: var(--chip); }
.menu .empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }

.workspace {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 16px 20px 32px;
  background: #fcfcfc;
}
.list { flex: 1 1 auto; min-width: 0; }
.meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 22px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 108px);
  gap: 8px;
  justify-content: start;
  align-content: start;
}
.tile {
  position: relative;
  width: 108px;
  height: 148px;
  background: var(--tile);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 4px 8px;
  text-align: center;
  color: inherit;
  overflow: hidden;
}
.tile:hover { background: var(--tile-hover); }
.tile.is-selected {
  border: 2px solid var(--selected);
  padding: 5px 3px 7px;
  background: var(--tile-well);
}
.icon, .tile .ph {
  width: 84px;
  height: 84px;
  margin: 0 auto;
  object-fit: contain;
  background: var(--tile-well);
  border-radius: 2px;
}
.ph { display: grid; place-items: center; color: var(--faint); }
.ph svg { width: 42%; height: 42%; }
.tile .name {
  margin: 6px 2px 0;
  font-size: 12px;
  line-height: 1.35;
  height: 2.7em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.badge {
  position: absolute;
  top: 68px;
  left: 8px;
  max-width: calc(100% - 16px);
  padding: 0 4px;
  border-radius: 2px;
  background: rgba(255, 252, 248, 0.92);
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.skel {
  width: 108px;
  height: 148px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #fafafa 37%, #f0f0f0 63%);
  background-size: 400% 100%;
  animation: shine 1.1s infinite;
}
@keyframes shine { to { background-position: -400% 0; } }

.idle, .status {
  min-height: 420px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}
.idle-card, .status-card { max-width: 440px; }
.idle .ph, .status .ph {
  width: 108px;
  height: 108px;
  margin: 0 auto 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--tile);
}
.idle h2, .status h2, .detail-empty h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}
.idle p, .status p, .detail-empty p { margin: 0; line-height: 1.65; }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
}
.chip:hover { border-color: var(--ink); }

.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.page {
  min-width: 34px;
  height: 32px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 4px;
  padding: 0 8px;
}
.page[aria-current="page"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 700;
}
.page:disabled { opacity: 0.4; }
.ellipsis { display: grid; place-items: center; min-width: 20px; color: var(--muted); }

.detail {
  flex: 0 0 0px;
  width: 0;
  min-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  background: #fff;
  border: 0 solid var(--line);
  border-radius: 4px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  padding: 0;
  transition: flex-basis 0.22s ease, width 0.22s ease, opacity 0.16s ease, padding 0.22s ease;
}
.workspace.has-detail { gap: 16px; }
.workspace.has-detail .detail {
  flex-basis: 360px;
  width: 360px;
  opacity: 1;
  overflow: auto;
  pointer-events: auto;
  border-width: 1px;
  padding: 16px 16px 28px;
}
.detail-empty {
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 12px;
}
.detail-empty .ph {
  width: 108px;
  height: 108px;
  margin: 0 auto 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--tile);
}
.hero {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 12px;
  align-items: start;
}
.hero-icon, .hero .ph {
  width: 128px;
  height: 128px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--tile);
  object-fit: contain;
}
.hero-top { display: flex; align-items: flex-start; gap: 8px; }
.hero h2 { margin: 0; font-size: 20px; line-height: 1.35; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  background: var(--chip);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--muted);
}
.tag.id { font-variant-numeric: tabular-nums; }
.close-detail, .copy {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
}
.close-detail { display: none; font-size: 22px; line-height: 1; }
.copy { font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.copy:hover, .close-detail:hover { color: var(--ink); }
.copied { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.section { margin-top: 18px; }
.section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.prose {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 14px;
}
.desc-title { color: var(--title); font-weight: 700; }
.sentinel { min-height: 8px; color: var(--muted); font-size: 13px; padding: 8px 0 16px; }
.stats { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.stats li { font-size: 14px; line-height: 1.45; }
.stats .quiet { color: var(--muted); font-size: 12px; }
.group { margin-top: 12px; }
.group h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
.source {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 8px;
  background: #fff;
}
.source .name-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.source strong { display: block; margin-bottom: 4px; }
.source .sub, .note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.trade-note { margin: -2px 0 8px; }
.source details { margin-top: 6px; }
.source summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.more {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
}
.wrap-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 8px;
  align-items: flex-start;
}
.mini {
  position: relative;
  width: 76px;
  flex: 0 0 76px;
  border: 0;
  background: transparent;
  text-align: center;
  padding: 0;
  color: inherit;
}
.mini img, .mini .ph {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--tile);
  object-fit: contain;
}
.mini span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: 4px;
  max-height: 2.6em;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.3;
  white-space: normal;
}
.mini .qty {
  position: absolute;
  top: 52px;
  right: 2px;
  min-width: 18px;
  padding: 0 3px;
  border-radius: 2px;
  background: rgba(255, 252, 248, 0.94);
  border: 1px solid var(--line);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.mini .limit-mark {
  position: absolute;
  top: 2px;
  left: 4px;
  margin: 0;
  background: #fff;
  font-size: 10px;
  padding: 0 3px;
}
.mini.is-current img, .mini.is-current .ph { border-color: var(--ink); border-width: 2px; }
.mission-list, .exchange-list { display: flex; flex-direction: column; gap: 12px; }
.mission {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}
.mission-icon {
  width: 40px;
  height: 40px;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.mission-icon svg { width: 32px; height: 32px; }
.mission-body { min-width: 0; }
.mission-name { font-weight: 700; font-size: 14px; line-height: 1.45; }
.mission-desc { margin: 2px 0 0; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.mission-meta { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.exchange-name { margin: 0 0 6px; font-size: 13px; font-weight: 700; }
.exchange-options { display: flex; flex-direction: column; gap: 10px; }
.exchange-option { border: 1px solid var(--line); border-radius: 4px; padding: 10px; }
.exchange-flow { display: flex; gap: 10px; align-items: center; }
.exchange-flow > div { min-width: 0; }
.exchange-label { margin: 0 0 5px; color: var(--muted); font-size: 12px; }
.exchange-arrow { flex: 0 0 auto; color: var(--muted); font-size: 18px; }
.versions, .members { display: flex; flex-direction: column; gap: 8px; }
.version {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
  padding: 6px;
  color: inherit;
}
.version img, .version .ph {
  width: 48px;
  height: 48px;
  background: var(--tile);
  object-fit: contain;
}
.bonus { margin: 4px 0; font-size: 14px; }
.media-list { display: flex; flex-direction: column; gap: 8px; }
.media-row, .media-row-static {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
  padding: 6px;
  color: inherit;
}
.media-row img, .media-row .ph,
.media-row-static img, .media-row-static .ph {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: var(--tile-well);
}
.media-row span, .media-row-static span { font-size: 14px; line-height: 1.35; }
.limit-mark { color: var(--title); font-weight: 700; font-size: 12px; margin-left: 6px; }
.tile .limit-mark {
  position: absolute;
  top: 8px;
  right: 6px;
  margin: 0;
  background: #fff;
  padding: 0 3px;
}

@media (max-width: 860px) {
  .mission-toolbar { padding: 12px 14px; }
  .mission-content { padding: 14px 14px 28px; }
  .mission-card { padding: 13px; }
  .workspace, .workspace.has-detail { display: block; gap: 0; padding: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, 108px); }
  .detail, .workspace.has-detail .detail {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    width: auto;
    flex: none;
    opacity: 1;
    pointer-events: auto;
    overflow: auto;
    max-height: none;
    border: 0;
    border-radius: 0;
    top: 0;
    padding: 16px 16px 28px;
    transition: none;
  }
  .detail.open,
  .workspace.has-detail .detail.open { display: block; }
  .close-detail { display: block; }
  .hero { grid-template-columns: 96px 1fr; }
  .hero-icon, .hero .ph { width: 96px; height: 96px; }
  body.sheet-open { overflow: hidden; }
}
