:root {
  --ink: #101820;
  --ink-2: #1c2934;
  --paper: #f4f2eb;
  --card: #fffef9;
  --line: #d8d5cb;
  --muted: #6b746f;
  --signal: #c8f135;
  --blue: #1d5eff;
  --danger: #d23c3c;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    linear-gradient(rgba(16,24,32,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,24,32,.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

.rank-app { max-width: 1560px; margin: 0 auto; padding: 24px 30px 56px; }
.topbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 28px;
  min-height: 188px;
  padding: 34px 38px;
  overflow: hidden;
  color: #fff;
  background: var(--ink);
  border: 1px solid #263642;
  border-radius: 4px;
  box-shadow: 0 18px 45px rgba(16,24,32,.16);
  animation: reveal .35s ease both;
}
.topbar::after {
  content: "";
  position: absolute;
  right: -58px;
  bottom: -158px;
  width: 330px;
  height: 330px;
  border: 55px solid var(--signal);
  border-radius: 50%;
  pointer-events: none;
}
.hero-copy,.hero-actions { position: relative; z-index: 1; }
.eyebrow,.section-kicker { color: var(--signal); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.topbar h1 { margin: 10px 0 8px; font-family: "Songti SC", "STSong", serif; font-size: clamp(32px,4vw,52px); line-height: 1.05; letter-spacing: -.04em; }
.topbar p { max-width: 660px; margin: 0; color: #b8c2c8; font-size: 13px; line-height: 1.8; }
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 18px; }
.search-entry { display: inline-flex; gap: 18px; align-items: center; padding: 11px 15px; color: var(--ink); background: var(--signal); border-radius: 99px; font-size: 12px; font-weight: 800; text-decoration: none; }
.search-entry span { font-size: 17px; line-height: 1; }
.search-entry.alt2 { background: #2a3946; color: #fff; }
.status { display: inline-flex; align-items: center; gap: 8px; color: #dce3e6; font-size: 12px; }
.status::before { content: ""; width: 7px; height: 7px; background: var(--signal); border-radius: 50%; box-shadow: 0 0 0 4px rgba(200,241,53,.12); }
.status.subtle { color: var(--muted); }
.status.subtle::before { background: var(--blue); box-shadow: 0 0 0 4px rgba(29,94,255,.1); }

.workflow { display: flex; align-items: center; padding: 16px 22px; margin: 14px 0; background: rgba(255,254,249,.94); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(16,24,32,.05); }
.workflow-item { display: flex; align-items: center; gap: 10px; min-width: 150px; color: var(--muted); }
.workflow-item b { font-family: "Avenir Next Condensed", sans-serif; font-size: 24px; color: #adb2ac; }
.workflow-item span { display: flex; flex-direction: column; font-size: 12px; font-weight: 800; }
.workflow-item small { margin-top: 2px; color: #989f9b; font-size: 10px; font-weight: 500; }
.workflow-item.active b { color: var(--blue); }
.workflow-item.active span { color: var(--ink); }
.workflow-line { flex: 1; height: 1px; margin: 0 18px; background: var(--line); }

.card { padding: 24px; margin-bottom: 16px; background: rgba(255,254,249,.97); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 8px 28px rgba(16,24,32,.06); animation: reveal .4s .05s ease both; }
.collect-card { border-top: 4px solid var(--blue); }
.result-card { padding: 0; overflow: hidden; }
.result-card .section-title { padding: 24px 24px 18px; }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 18px; }
.section-title h2 { margin: 4px 0 3px; font-family: "Songti SC", "STSong", serif; font-size: 22px; line-height: 1.25; }
.section-title p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.section-kicker { color: var(--blue); }

.grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.ai-grid { grid-template-columns: 1fr 2fr 1fr 2fr; }
label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
select,input,textarea { width: 100%; min-height: 42px; padding: 9px 12px; color: var(--ink); background: #fff; border: 1px solid #c9c6bb; border-radius: 3px; outline: none; font: inherit; font-size: 13px; transition: border-color .18s, box-shadow .18s; }
textarea { resize: vertical; line-height: 1.6; }
select:focus,input:focus,textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,94,255,.12); }
select:disabled { color: #8f9692; background: #f0eee7; }
.prompt-label { margin-top: 8px; }

button { min-height: 39px; padding: 8px 15px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 800; transition: transform .18s,box-shadow .18s,background .18s; }
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 13px rgba(16,24,32,.11); }
button.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
button.signal { color: var(--ink); background: var(--signal); border-color: var(--signal); }
button:disabled { opacity: .42; cursor: not-allowed; }
.actions,.result-actions,.capture-footer { display: flex; align-items: center; gap: 10px; }
.actions { margin-top: 14px; flex-wrap: wrap; }
.capture-footer { justify-content: space-between; }
.capture-footer p { margin: 0; color: var(--muted); font-size: 12px; }
.count-pill { padding: 7px 11px; color: var(--ink); background: #eef0e9; border-radius: 99px; font-size: 11px; font-weight: 800; }

.progress { height: 7px; margin-top: 16px; overflow: hidden; background: #ece9df; border: 1px solid var(--line); border-radius: 2px; }
.progress div { width: 0; height: 100%; background: linear-gradient(90deg,var(--blue),var(--signal)); transition: width .2s; }
.table-wrap { max-height: 600px; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 12px; }
th,td { padding: 12px 10px; border-bottom: 1px solid #e8e5dc; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; color: #dfe7ea; background: var(--ink-2); border-bottom: 0; font-size: 10px; letter-spacing: .06em; }
tbody tr:hover { background: #f3f8de; }
.title { max-width: 420px; overflow: hidden; color: var(--ink); font-weight: 650; text-overflow: ellipsis; }
.metric { color: #0a6b64; font-weight: 700; }
.empty { padding: 40px; color: #929994; text-align: center; }
.trend { width: 124px; }
.trend-svg { display: block; width: 112px; height: 30px; }
.trend-empty { color: #929994; }
.product-thumb { display: block; width: 54px; height: 54px; overflow: hidden; border: 1px solid var(--line); border-radius: 3px; background: #f0eee7; }
.product-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .18s; }
.product-thumb:hover img { transform: scale(1.08); }
.product-link { color: var(--ink); text-decoration: none; }
.product-link:hover { color: var(--blue); text-decoration: underline; }
.image-preview { max-width: min(90vw,860px); padding: 8px; border: 0; border-radius: 5px; background: #111; box-shadow: 0 18px 60px rgba(0,0,0,.45); }
.image-preview::backdrop { background: rgba(0,0,0,.68); }
.image-preview img { display: block; max-width: min(88vw,820px); max-height: 82vh; object-fit: contain; }
.image-preview button { position: absolute; top: -12px; right: -12px; min-height: 28px; width: 28px; padding: 0; color: #fff; background: var(--danger); border: 0; border-radius: 50%; font-size: 20px; line-height: 1; }

#analysis { display: none; min-height: 80px; padding: 16px; margin: 16px 0 0; white-space: pre-wrap; color: #dfe7ea; background: var(--ink); border-left: 4px solid var(--signal); border-radius: 2px; font: 12px/1.75 ui-monospace,SFMono-Regular,Menlo,monospace; }
.index-session { display: grid; grid-template-columns: minmax(280px,1fr) auto auto auto; gap: 10px; align-items: end; margin-top: 14px; padding: 14px; background: #f4f5ef; border: 1px solid var(--line); }
.index-session #syncDouyinSession { white-space: nowrap; }
.index-session .status { min-height: 39px; }
.index-status { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.keywords { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.keyword-card { position: relative; padding: 14px; background: #f8faff; border: 1px solid #d7e2ff; border-radius: 4px; }
.keyword-card.best { background: #f5fbdc; border-color: #b8d23f; box-shadow: inset 4px 0 0 var(--signal); }
.keyword-card.unavailable { background: #f4f3ef; border-color: var(--line); }
.keyword-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.keyword-select { display: flex; flex-direction: row; align-items: center; gap: 7px; min-width: 0; }
.keyword-select input { width: auto; min-height: 0; accent-color: var(--blue); }
.keyword-name { min-height: 0; padding: 0; overflow: hidden; color: #1749c6; background: transparent; border: 0; font-size: 14px; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.keyword-name:hover:not(:disabled) { box-shadow: none; transform: none; text-decoration: underline; }
.keyword-score { flex: 0 0 auto; padding: 4px 7px; color: #fff; background: var(--blue); border-radius: 99px; font-size: 11px; font-weight: 900; }
.keyword-card.best .keyword-score { color: var(--ink); background: var(--signal); }
.keyword-reason { min-height: 34px; margin: 9px 0; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.55; }
.keyword-metrics { display: flex; flex-wrap: wrap; gap: 6px; color: #4d5b61; font-size: 10px; }
.keyword-metrics span { padding: 4px 6px; background: rgba(255,255,255,.8); border: 1px solid #e0e5df; border-radius: 2px; }
.keyword-index-dialog { width: min(920px,92vw); max-height: 88vh; padding: 24px; color: var(--ink); background: var(--paper); border: 0; border-radius: 5px; box-shadow: 0 22px 80px rgba(0,0,0,.4); }
.keyword-index-dialog::backdrop { background: rgba(10,18,24,.72); }
.dialog-close { position: absolute; top: 12px; right: 12px; min-height: 30px; width: 30px; padding: 0; color: #fff; background: var(--danger); border: 0; border-radius: 50%; font-size: 20px; }
.keyword-detail-title { display: flex; align-items: center; gap: 10px; padding-right: 36px; }
.keyword-detail-title h2 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: 28px; }
.keyword-detail-summary { color: var(--muted); line-height: 1.7; }
.index-metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin: 16px 0; }
.index-metric { padding: 12px; background: #fff; border: 1px solid var(--line); }
.index-metric small { display: block; color: var(--muted); }
.index-metric strong { display: block; margin-top: 5px; font-size: 20px; }
.index-chart { display: block; width: 100%; height: auto; padding: 8px; background: #fff; border: 1px solid var(--line); }
.index-legend { display: flex; gap: 18px; margin: 8px 0 14px; color: var(--muted); font-size: 11px; }
.index-legend i { display: inline-block; width: 18px; height: 3px; margin-right: 5px; vertical-align: middle; }
.index-table { max-height: 260px; margin-top: 14px; overflow: auto; border: 1px solid var(--line); }
.index-peaks { margin-top: 18px; }
.index-peak { padding: 12px 0; border-top: 1px solid var(--line); }
.index-peak h4 { margin: 0 0 7px; }
.index-peak p { margin: 5px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.index-video-list { margin: 8px 0 0; padding-left: 20px; font-size: 11px; line-height: 1.7; }
.index-video-list a { color: var(--blue); }

@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 900px) {
  .rank-app { padding: 14px; }
  .topbar { grid-template-columns: 1fr; padding: 26px; }
  .hero-actions { align-items: flex-start; }
  .topbar::after { opacity: .35; }
  .grid,.ai-grid { grid-template-columns: 1fr 1fr; }
  .keywords { grid-template-columns: 1fr 1fr; }
  .index-metric-grid { grid-template-columns: 1fr 1fr; }
  .workflow-item { min-width: 0; }
}
@media (max-width: 560px) {
  .grid,.ai-grid { grid-template-columns: 1fr; }
  .keywords,.index-session { grid-template-columns: 1fr; }
  .workflow { align-items: flex-start; gap: 10px; }
  .workflow-line { display: none; }
  .workflow-item { flex: 1; flex-direction: column; align-items: flex-start; }
  .section-title,.capture-footer { flex-direction: column; align-items: flex-start; }
  .result-actions { width: 100%; justify-content: space-between; }
}
