/* ==========================================================================
   九宝图中心 — 现代简洁主题 (modern minimal)
   单一克制强调色 · 浅灰底纯白卡片 · 柔和阴影 · 弱装饰 · 移动优先
   ========================================================================== */

:root {
  color-scheme: light;

  /* 中性表面 */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-sunken: #f1f3f5;

  /* 文字 */
  --ink: #11181c;
  --ink-soft: #3c4753;
  --muted: #6b7682;
  --faint: #98a1ab;

  /* 线条 */
  --line: rgba(17, 24, 28, 0.08);
  --line-strong: rgba(17, 24, 28, 0.14);

  /* 强调色（克制蓝） */
  --accent: #2563eb;
  --accent-press: #1d4ed8;
  --accent-soft: #eaf1ff;
  --accent-ink: #1e40af;

  /* 语义色 */
  --good: #0f9d6b;
  --good-soft: #e7f6ef;
  --warn: #b7791f;
  --bad: #dc2626;
  --bad-soft: #fdecec;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(17, 24, 28, 0.05);
  --shadow: 0 1px 2px rgba(17, 24, 28, 0.04), 0 8px 24px rgba(17, 24, 28, 0.06);
  --shadow-lg: 0 12px 40px rgba(17, 24, 28, 0.14);

  /* 圆角 */
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
  --r-pill: 999px;

  /* 顶栏高度（开奖表头吸顶用） */
  --chrome: 64px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo,
    Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

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

.muted {
  color: var(--muted);
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ---- Topbar -------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: var(--chrome);
  padding: 10px clamp(14px, 3vw, 28px);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  flex: 0 0 auto;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}

/* ---- Top navigation (segmented control) --------------------------------- */

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  flex: 0 0 auto;
}

.top-nav button {
  min-height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.top-nav button:hover {
  color: var(--ink);
}

.top-nav button.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ---- Search (desktop only) ---------------------------------------------- */

.top-actions {
  display: flex;
  align-items: center;
  min-width: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  border: 1px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.search-box:focus-within {
  background: var(--surface);
  border-color: var(--accent);
}

.search-box > span {
  font-size: 12px;
  color: var(--faint);
}

.search-box input {
  border: 0;
  background: transparent;
  outline: none;
  width: 180px;
  font-size: 14px;
}

.is-detail .search-box {
  opacity: 0.5;
  pointer-events: none;
}

/* ---- View container ------------------------------------------------------ */

.view {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 28px) 56px;
  outline: none;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.05s ease;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.primary-button:hover {
  background: var(--accent-press);
}

.primary-button:active {
  transform: translateY(1px);
}

.secondary-button {
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--line-strong);
}

.secondary-button:hover {
  background: var(--surface-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button-icon {
  font-size: 15px;
  line-height: 1;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  background: var(--surface-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.back-button {
  margin-right: 2px;
}

.back-button[hidden] {
  display: none;
}

/* ==========================================================================
   Generic cards / sections
   ========================================================================== */

.dashboard {
  display: grid;
  gap: 18px;
}

.data-panel,
.tool-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.4vw, 22px);
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h1,
.section-title h2 {
  font-size: 18px;
  font-weight: 700;
}

.section-title p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.section-title.compact {
  margin-bottom: 12px;
}

.section-title.compact h1 {
  font-size: 16px;
}

/* ==========================================================================
   Home — image-first dashboard
   ========================================================================== */

.image-first-dashboard {
  gap: 16px;
}

.image-hero-panel {
  display: grid;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 12px;
}

.featured-image-shell {
  display: block;
}

.featured-image-card {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-sunken);
  box-shadow: var(--shadow-sm);
}

.featured-image-card:disabled {
  cursor: default;
}

.featured-image {
  display: block;
  width: 100%;
  height: auto;
  min-height: 220px;
  object-fit: contain;
  background: #fffdf7;
}

.placeholder-image {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 4;
  color: var(--faint);
  font-size: 40px;
  font-weight: 700;
}

.featured-image-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: rgba(17, 24, 28, 0.62);
  backdrop-filter: blur(6px);
  color: #fff;
}

.featured-image-badge span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}

.featured-image-badge strong {
  font-size: 16px;
  font-weight: 700;
}

.featured-image-badge em {
  font-size: 11px;
  font-style: normal;
  opacity: 0.85;
}

.featured-image-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 28px 14px 12px;
  background: linear-gradient(
    to top,
    rgba(17, 24, 28, 0.78),
    rgba(17, 24, 28, 0)
  );
  color: #fff;
}

.featured-image-overlay strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.featured-image-overlay span {
  display: block;
  font-size: 12px;
  opacity: 0.85;
}

.overlay-pill {
  flex: 0 0 auto;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 12px;
  font-weight: 600;
}

.mobile-image-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.image-refresh-button {
  min-height: 34px;
  padding: 0 14px;
}

/* ---- Thumbnail strip (horizontal scroll) -------------------------------- */

.image-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.image-strip::-webkit-scrollbar {
  height: 6px;
}

.image-strip::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
}

.image-card {
  flex: 0 0 auto;
  width: 110px;
  display: grid;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  scroll-snap-align: start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.image-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.image-card img {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 7px;
  background: var(--surface-sunken);
}

.image-card span {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Similar list (history riddle images) ------------------------------- */

.similar-list {
  display: grid;
  gap: 8px;
}

.similar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-soft);
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.similar-row:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.similar-row span:not(.num-chip) {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.similar-row strong {
  font-size: 14px;
  font-weight: 650;
}

.similar-row em {
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
}

.similar-row b {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

/* ==========================================================================
   Summary / KPI cards
   ========================================================================== */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.summary-label {
  font-size: 12px;
  color: var(--muted);
}

.summary-value {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.summary-card .muted {
  font-size: 11px;
}

/* mobile-kpis / image-kpis become horizontal scroll on small screens (see media) */

/* ==========================================================================
   Number chips
   ========================================================================== */

.chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.num-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.focus-cloud .num-chip {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
}

/* ==========================================================================
   Draw list
   ========================================================================== */

.draw-list {
  display: grid;
  gap: 6px;
}

.compact-draw {
  display: grid;
  grid-template-columns: minmax(64px, 0.9fr) 1fr minmax(78px, 0.9fr);
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-soft);
}

.compact-draw > span {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.compact-draw strong {
  justify-self: center;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.compact-draw em {
  justify-self: end;
  font-size: 12px;
  font-style: normal;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Draw history page
   ========================================================================== */

.draw-history-surface {
  padding-top: 18px;
}

.draw-history-head {
  position: sticky;
  top: var(--chrome);
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(64px, 0.9fr) 1fr minmax(78px, 0.9fr);
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.draw-history-head span:nth-child(2) {
  text-align: center;
}

.draw-history-head span:nth-child(3) {
  text-align: right;
}

.draw-history-list {
  max-height: none;
}

/* ==========================================================================
   Tools guide page
   ========================================================================== */

.tool-guide-page {
  gap: 16px;
}

.tool-guide-hero {
  display: grid;
  gap: 16px;
  padding: clamp(18px, 3vw, 26px);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: var(--shadow);
}

.tool-guide-copy {
  display: grid;
  gap: 8px;
}

.hero-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.85;
}

.tool-guide-copy h1 {
  font-size: 26px;
  font-weight: 750;
}

.tool-guide-copy p {
  font-size: 14px;
  opacity: 0.92;
  max-width: 46ch;
}

.tool-guide-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tool-guide-status > div {
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tool-guide-status span {
  font-size: 11px;
  opacity: 0.85;
}

.tool-guide-status strong {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tool-guide-status em {
  font-size: 11px;
  font-style: normal;
  opacity: 0.8;
}

/* ---- Catalog sections / module rows ------------------------------------- */

.catalog-section {
  display: grid;
  gap: 10px;
}

.catalog-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  padding-left: 2px;
}

.module-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.module-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.05s ease;
}

.module-row:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.module-row:active {
  transform: translateY(1px);
}

.module-row > span:not(.nav-icon):not(.chevron) {
  flex: 1;
  min-width: 0;
}

.module-row h3 {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 2px;
}

.module-row p {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.nav-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
}

.chevron {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 18px;
}

/* ==========================================================================
   Detail pages
   ========================================================================== */

.detail-page,
.numbers-workbench {
  display: grid;
  gap: 16px;
}

.tool-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.tool-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.tool-header p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

/* ---- Forms --------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field,
.wide-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.wide-field {
  grid-column: 1 / -1;
}

.field label,
.wide-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
  font-family: var(--mono);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7682' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.unit {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
}

/* ---- Filter sub-sections ------------------------------------------------- */

.filter-section {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}

.filter-section h2 {
  font-size: 15px;
  font-weight: 650;
}

.filter-section .muted {
  font-size: 12px;
}

/* ---- Number workbench output -------------------------------------------- */

.number-output {
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.4vw, 22px);
}

/* ==========================================================================
   Guided filter workbench (引导式条件卡过滤台)
   ========================================================================== */

.filter-workbench {
  display: grid;
  gap: 16px;
  padding-bottom: 84px; /* leave room for sticky result bar */
}

/* ---- Length picker ---- */
.length-picker {
  display: grid;
  gap: 8px;
}

.picker-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.seg-chip-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.seg-chip {
  display: grid;
  gap: 1px;
  justify-items: center;
  padding: 10px 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 700;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.seg-chip em {
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
  color: var(--faint);
}

.seg-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.seg-chip.is-on em {
  color: rgba(255, 255, 255, 0.85);
}

/* ---- Condition group ---- */
.condition-group {
  display: grid;
  gap: 10px;
}

.condition-group-head {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding-left: 2px;
}

.condition-list {
  display: grid;
  gap: 8px;
}

/* ---- Condition card ---- */
.condition-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.condition-card.is-open {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.condition-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 0;
  background: transparent;
  text-align: left;
}

.cc-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.condition-card.is-active .cc-dot {
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft);
}

.cc-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.cc-main strong {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}

.cc-main em {
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.condition-card.is-active .cc-main em {
  color: var(--accent-ink);
  font-weight: 600;
}

.cc-chevron {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 16px;
}

.condition-card-body {
  padding: 4px 14px 16px;
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.editor-hint {
  font-size: 12px;
  margin-top: 8px;
}

/* ---- Digit / set chip pad ---- */
.chip-pad {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

.digit-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.digit-chip.wide {
  min-width: 46px;
}

.digit-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.digit-chip.is-kill {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

/* ---- Segmented single-select ---- */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.seg-pill {
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

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

/* ---- Steppers ---- */
.range-stepper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.range-stepper.single {
  justify-content: flex-start;
}

.range-sep {
  color: var(--faint);
  padding-bottom: 12px;
}

.stepper {
  display: grid;
  gap: 5px;
}

.stepper-label {
  font-size: 12px;
  color: var(--muted);
}

.stepper-ctrl {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.stepper-ctrl button {
  width: 44px;
  height: 44px;
  border: 0;
  background: var(--surface-soft);
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.stepper-ctrl button:active {
  background: var(--accent-soft);
}

.stepper-val {
  min-width: 54px;
  text-align: center;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.set-chip {
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.set-chip:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ---- Position picker ---- */
.position-row {
  display: grid;
  gap: 6px;
}

.position-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* ---- Sticky result bar ---- */
.filter-resultbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 calc(-1 * clamp(14px, 3vw, 28px)) -56px;
  padding: 12px clamp(14px, 3vw, 28px);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}

.resultbar-count {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.resultbar-count strong {
  font-size: 24px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.resultbar-count span {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resultbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.resultbar-actions .primary-button {
  min-height: 44px;
}



/* ==========================================================================
   Result tiles
   ========================================================================== */

.results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.result-tile {
  display: grid;
  gap: 3px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  text-align: center;
}

.result-label {
  font-size: 12px;
  color: var(--muted);
}

.result-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--accent);
  word-break: break-word;
}

.result-note {
  font-size: 11px;
  color: var(--faint);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-sunken);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:nth-child(even) td {
  background: var(--surface-soft);
}

/* ==========================================================================
   Record cards (countdown / age / counter)
   ========================================================================== */

.records {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.record-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.record-main {
  min-width: 0;
}

.record-title {
  font-size: 14px;
  font-weight: 650;
}

.record-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.record-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

/* ==========================================================================
   Pills / tool cards
   ========================================================================== */

.tool-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.tool-card h3 {
  font-size: 15px;
  font-weight: 650;
}

.tool-card p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

/* quick-action (legacy home shortcut, kept for safety) */
.quick-action {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.quick-action > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}

.quick-action strong {
  font-size: 14px;
}

.quick-action em {
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
}

/* ==========================================================================
   Guide page
   ========================================================================== */

.guide-page {
  display: grid;
  gap: 16px;
}

.guide-page .section-title h1 {
  font-size: 20px;
}

.guide-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-soft);
}

.guide-content h1,
.guide-content h2,
.guide-content h3 {
  color: var(--ink);
  margin: 18px 0 8px;
  line-height: 1.3;
}

.guide-content h1 {
  font-size: 19px;
}

.guide-content h2 {
  font-size: 16px;
}

.guide-content h3 {
  font-size: 15px;
}

.guide-content p {
  margin: 8px 0;
}

.guide-content ul,
.guide-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.guide-content li {
  margin: 4px 0;
}

.guide-content a {
  color: var(--accent);
  text-decoration: none;
}

.guide-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
}

.guide-content table {
  margin: 12px 0;
}

.mobile-guide {
  display: grid;
  gap: 18px;
}

.guide-hero-block {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background:
    radial-gradient(circle at 12% 18%, rgba(37, 99, 235, 0.16), transparent 34%),
    linear-gradient(135deg, var(--surface-soft), var(--surface));
}

.guide-eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 750;
  color: var(--accent);
  letter-spacing: 0.12em;
}

.guide-section {
  display: grid;
  gap: 10px;
}

.guide-steps,
.guide-list {
  display: grid;
  gap: 10px;
  padding-left: 0;
  list-style: none;
}

.guide-steps {
  counter-reset: guide-step;
}

.guide-steps li,
.guide-list li,
.guide-note {
  position: relative;
  padding: 12px 12px 12px 42px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}

.guide-steps li::before {
  counter-increment: guide-step;
  content: counter(guide-step);
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.guide-list li::before,
.guide-note::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 18px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.guide-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.guide-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}

.guide-card h3 {
  margin-top: 0;
}

.guide-dictionary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.guide-dictionary > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}

.guide-dictionary dt {
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 750;
}

.guide-dictionary dd {
  margin: 0;
  color: var(--muted);
}

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.image-modal,
.history-image-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(17, 24, 28, 0.6);
  backdrop-filter: blur(4px);
}

.image-modal-card,
.history-image-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px;
}

.image-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.image-modal-head strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
}

.image-modal-head span {
  display: block;
  font-size: 11px;
  color: var(--faint);
  word-break: break-all;
  margin-top: 2px;
}

.image-modal-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-md);
  background: #fffdf7;
}

.history-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.history-image-tile {
  display: grid;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  text-align: center;
  transition: border-color 0.15s ease;
}

.history-image-tile:hover {
  border-color: var(--accent);
}

.history-image-tile img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 7px;
  background: var(--surface-sunken);
}

.history-image-tile span {
  font-size: 12px;
  color: var(--muted);
}

.history-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  border-radius: 7px;
  background: var(--surface-sunken);
  color: var(--faint);
  font-size: 13px;
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  z-index: 200;
  max-width: 90vw;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Responsive — tablet
   ========================================================================== */

@media (max-width: 920px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-guide-status {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================================================
   Responsive — mobile (≤640px)  — 移动优先目标场景
   ========================================================================== */

@media (max-width: 640px) {
  :root {
    --chrome: 92px;
  }

  body {
    font-size: 14px;
  }

  /* ---- Compact topbar: brand row + 4-up nav grid ---- */
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px 10px;
  }

  .brand-title {
    font-size: 15px;
    max-width: 70vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-subtitle {
    display: none;
  }

  /* hide search on mobile per requirements */
  .top-actions,
  .search-box {
    display: none;
  }

  .top-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
  }

  .top-nav button {
    padding: 0 4px;
    min-height: 32px;
    font-size: 13px;
  }

  .view {
    padding: 14px 12px 44px;
  }

  /* ---- Home ---- */
  .image-hero-panel {
    padding: 8px;
    gap: 10px;
  }

  .featured-image {
    min-height: 0;
  }

  /* KPI rows become horizontal scroll so they don't push the image down */
  .mobile-kpis,
  .image-kpis {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-kpis .summary-card,
  .image-kpis .summary-card {
    flex: 0 0 auto;
    width: 140px;
  }

  .summary-value {
    font-size: 21px;
  }

  /* ---- Tools ---- */
  .tool-guide-copy h1 {
    font-size: 22px;
  }

  /* status strip becomes horizontal scroll */
  .tool-guide-status {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .tool-guide-status > div {
    flex: 0 0 auto;
    width: 120px;
  }

  /* module grid: keep two columns, big touch targets */
  .module-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .module-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    min-height: 96px;
  }

  .module-row .chevron {
    display: none;
  }

  /* ---- Forms stack to single column ---- */
  .form-grid,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .results {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .result-tile {
    padding: 10px 8px;
  }

  .result-value {
    font-size: 18px;
  }

  /* ---- Detail header keeps action inline ---- */
  .tool-header {
    gap: 10px;
  }

  .tool-header h1 {
    font-size: 18px;
  }

  /* ---- Modals full-width ---- */
  .image-modal,
  .history-image-modal {
    padding: 12px;
  }

  .history-image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-card-grid,
  .guide-dictionary {
    grid-template-columns: 1fr;
  }

  .guide-content {
    padding: 14px;
  }

  .guide-hero-block {
    padding: 14px;
  }
}

/* ---- very small phones ---- */
@media (max-width: 380px) {
  .module-list {
    grid-template-columns: 1fr;
  }

  .results {
    grid-template-columns: 1fr 1fr;
  }
}
