/* === QDII FundDrift Light Theme === */
:root {
  --bg: #ffffff;
  --bg-card: #f8f9fa;
  --bg-hover: #eef0f3;
  --bg-sheet: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --border: #e5e7eb;
  --accent: #2563eb;
  --up: #16a34a;
  --down: #dc2626;
  --flat: #9ca3af;
  --radius: 12px;
  --radius-sm: 8px;
  --fs-scale: 1;
  font-size: calc(14px * var(--fs-scale));
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input { font: inherit; }

/* === Skeleton === */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand-mark {
  display: flex;
  align-items: center;
  color: var(--accent);
}
.brand-title {
  font-weight: 700;
  font-size: 1em;
  color: var(--text);
  letter-spacing: 0.5px;
}
.header-stats {
  display: flex;
  gap: 12px;
  margin-left: auto;
}
.hstat {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.85em;
  color: var(--text-muted);
}
.hstat b {
  font-size: 1.2em;
  min-width: 20px;
  text-align: right;
}
.hstat b.up { color: var(--up); }
.hstat b.down { color: var(--down); }
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.font-btn-label {
  font-weight: 700;
  font-size: 0.9em;
}

/* === Container === */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

/* === Notice === */
.notice {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  font-size: 0.82em;
  color: #1e40af;
  margin-bottom: 12px;
}

/* === Indexes === */
.indexes {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}
.idx {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  max-width: 200px;
  padding: 7px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  white-space: nowrap;
  font-size: 0.82em;
}
.idx-name {
  color: var(--text-muted);
}
.idx-val {
  font-weight: 600;
}
.idx-val.up { color: var(--up); }
.idx-val.down { color: var(--down); }
.idx-val.flat { color: var(--flat); }

/* === Section Head === */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-head h2 {
  font-size: 1em;
  font-weight: 600;
  color: var(--text);
}
.section-count {
  font-size: 0.8em;
  color: var(--text-muted);
}

/* === Fund List === */
.fund-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* === Row === */
.row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.row.open {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.08);
}
.row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.row-main:active {
  background: var(--bg-hover);
}
.row-rank {
  font-size: 0.75em;
  color: var(--text-dim);
  min-width: 20px;
  font-weight: 500;
}
.row-info {
  flex: 1;
  min-width: 0;
}
.row-name {
  display: block;
  font-size: 0.9em;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  font-size: 0.75em;
  color: var(--text-dim);
}
.row-impact {
  font-size: 1em;
  font-weight: 700;
  white-space: nowrap;
  min-width: 68px;
  text-align: right;
}
.row-impact.up { color: var(--up); }
.row-impact.down { color: var(--down); }
.row-impact.flat { color: var(--flat); }
.row-caret {
  color: var(--text-dim);
  display: flex;
  align-items: center;
  transition: transform 0.2s;
}
.row.open .row-caret {
  transform: rotate(90deg);
}

/* === Row Detail === */
.row-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.row.open .row-detail {
  max-height: 800px;
}
.row-detail-inner {
  padding: 0 14px 12px;
  border-top: 1px solid var(--border);
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 6px;
  font-size: 0.72em;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.82em;
}
.stock-row + .stock-row {
  border-top: 1px solid var(--border);
}
.stock-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.stock-weight {
  color: var(--text-muted);
  min-width: 48px;
  text-align: right;
}
.stock-change {
  min-width: 56px;
  text-align: right;
  font-weight: 600;
}
.stock-change.up { color: var(--up); }
.stock-change.down { color: var(--down); }
.stock-change.flat { color: var(--flat); }

/* === Mover Tags === */
.movers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 8px;
}
.mover {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.72em;
}
.mover-name {
  color: var(--text-muted);
}
.mover-change {
  font-weight: 600;
}
.mover-change.up { color: var(--up); }
.mover-change.down { color: var(--down); }

/* === Skeleton === */
.sk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sk-pill {
  background: #e5e7eb;
  border-radius: 4px;
  animation: pulse 1.5s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 24px 0;
  font-size: 0.72em;
  color: var(--text-dim);
}

/* === Font Sheet === */
.font-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.font-sheet[hidden] {
  display: none !important;
}
.font-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
}
.font-sheet-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px 24px 28px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.font-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.font-sheet-title {
  font-weight: 600;
  font-size: 1em;
  color: var(--text);
}
.font-sheet-close {
  font-size: 1.4em;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.font-sheet-close:hover { background: var(--bg-hover); }
.font-sheet-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.font-preset {
  padding: 8px 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8em;
  text-align: center;
  color: var(--text);
  transition: all 0.15s;
}
.font-preset:hover { border-color: var(--accent); }
.font-preset.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #eff6ff;
  font-weight: 600;
}
.font-sheet-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.font-step {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  color: var(--text);
  transition: all 0.15s;
}
.font-step:hover { border-color: var(--accent); }
.font-step-value {
  min-width: 48px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9em;
  color: var(--text);
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 10px 20px;
  background: var(--text);
  border-radius: var(--radius);
  font-size: 0.85em;
  color: #fff;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === Responsive === */
@media (max-width: 480px) {
  .container { padding: 8px 10px; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .row-main { padding: 12px 12px; }
  .row-impact { font-size: 0.95em; min-width: 60px; }
  .row-name { font-size: 0.85em; }
  .header-stats { gap: 8px; }
  .hstat { font-size: 0.8em; }
  .idx { font-size: 0.78em; padding: 4px 10px; }
  .font-sheet-card { padding: 16px 16px 24px; }
}
