:root {
  --paper: #fbfaf6;
  --ink: #1f2a44;
  --muted: #69728a;
  --line: #d9dfeb;
  --blue: #335fba;
  --blue-soft: #eaf1ff;
  --green: #34785f;
  --green-soft: #e9f5ef;
  --copper: #a65f2b;
  --copper-soft: #fff1e4;
  --violet: #7456a6;
  --violet-soft: #f1ecfb;
  --rose: #b65062;
  --shadow: 0 16px 40px rgba(31, 42, 68, 0.09);
  --radius: 8px;
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(51, 95, 186, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(51, 95, 186, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
}

button, input, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 9px 12px;
  cursor: pointer;
}

button:hover { border-color: var(--blue); color: var(--blue); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(51, 95, 186, 0.22); outline-offset: 2px; }

.app-shell { width: min(1180px, calc(100vw - 32px)); margin: 22px auto 48px; }
.boot { margin: 80px auto; width: max-content; color: var(--muted); }

.topbar {
  display: grid;
  grid-template-columns: 320px minmax(280px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255,255,255,0.88);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 12px;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand > div:last-child { min-width: 0; }
.mark {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 25px;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.18);
}
.brand h1 { margin: 0; font-size: 20px; line-height: 1.1; letter-spacing: 0; white-space: nowrap; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.searchbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.searchbar input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fff;
}
.searchbar button { min-width: 72px; white-space: nowrap; padding-left: 16px; padding-right: 16px; }

.account { display: flex; align-items: center; gap: 10px; justify-content: end; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #49a75f; box-shadow: 0 0 0 4px rgba(73,167,95,.12); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--copper-soft); color: var(--copper); font-weight: 700; border: 1px solid #e7c9ae; }

.nav { display: flex; gap: 8px; margin: 18px 0; flex-wrap: wrap; }
.nav button { background: rgba(255,255,255,.72); }
.nav button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.view { display: none; }
.view.active { display: block; }

.home-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  margin-top: 16px;
}

.side-stack { display: grid; gap: 16px; align-self: start; }

.band {
  background: rgba(255,255,255,.82);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.band + .band { margin-top: 16px; }
.band-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.band-title { display: flex; align-items: baseline; gap: 8px; }
.band-title h2 { margin: 0; font-size: 19px; letter-spacing: 0; }
.band-title span { color: var(--muted); font-size: 13px; }

.boss-strip, .boss-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.compact-list { display: grid; gap: 10px; }
.compact-list .boss-card { min-height: 0; }
.boss-card, .post-card, .export-option, .job-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.boss-card { padding: 12px; display: grid; gap: 10px; min-height: 164px; }
.boss-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.boss-avatar, .post-avatar, .detail-avatar {
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
  border: 1px solid #c7d8ff;
  flex: 0 0 auto;
}
.boss-avatar { width: 52px; height: 52px; }
.post-avatar { width: 46px; height: 46px; margin-top: 2px; }
.detail-avatar { width: 88px; height: 88px; background: var(--copper-soft); color: var(--copper); font-size: 30px; border-color: #efcaa7; }
.boss-avatar img, .post-avatar img, .detail-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.boss-name { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { border-radius: 999px; padding: 3px 8px; font-size: 12px; background: var(--blue-soft); color: var(--blue); border: 1px solid #c9d9ff; }
.tag.green { background: var(--green-soft); color: var(--green); border-color: #c6e7d8; }
.tag.copper { background: var(--copper-soft); color: var(--copper); border-color: #f0d1b7; }
.meta { color: var(--muted); font-size: 12px; line-height: 1.6; }
.card-actions { display: flex; gap: 8px; margin-top: auto; }
.card-actions button { flex: 1; padding: 8px 9px; }

.feed-list { display: grid; gap: 10px; }
.post-card { padding: 14px; display: grid; grid-template-columns: 46px minmax(0,1fr); gap: 12px; }
.time-rail { display: none; }
.post-main { min-width: 0; }
.post-title { display: block; }
.post-title strong { margin-right: 8px; }
.post-title a { color: var(--blue); text-decoration: none; font-weight: 750; display: block; margin-top: 3px; }
.post-title a:hover { text-decoration: underline; }
.post-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 5px; }
.post-content { margin: 8px 0 12px; line-height: 1.75; color: #2d3348; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-content p { margin: 0 0 10px; }
.post-content p:last-child { margin-bottom: 0; }
.reply-box {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border: 1px solid #e7cfaa;
  border-left: 4px solid var(--copper);
  border-radius: var(--radius);
  background: #fff9ed;
  color: #57402f;
}
.reply-box span {
  display: block;
  margin-bottom: 4px;
  color: var(--copper);
  font-size: 12px;
  font-weight: 750;
}
.reply-box p { margin: 0; }
.post-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.post-tools button { padding: 7px 10px; }
.load-more { width: 100%; margin-top: 12px; padding: 11px 12px; background: var(--blue-soft); color: var(--blue); border-color: #c9d9ff; }

.split-page { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
  min-width: 0;
}
.date-field {
  display: grid;
  grid-template-columns: auto minmax(128px, 1fr);
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}
.date-field input { width: 100%; color: var(--ink); }
.export-filters { margin: 4px 0 14px; }
.filter-summary { color: var(--muted); font-size: 13px; margin: -2px 0 12px; }

.detail-hero { display: grid; grid-template-columns: 96px minmax(0,1fr) auto; gap: 16px; align-items: center; }
.detail-hero h2 { margin: 0 0 8px; font-size: 27px; letter-spacing: 0; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: end; }

.analysis-panel { position: sticky; top: 102px; align-self: start; border-color: #d8c7ec; }
.quote-box { background: #fff8e9; border: 1px solid #efd5a7; border-radius: var(--radius); padding: 12px; line-height: 1.7; }
.sentiments { display: flex; gap: 8px; margin: 12px 0; }
.sentiments .tag { background: var(--violet-soft); color: var(--violet); border-color: #d7c9ef; }
.wide-options { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.export-option { padding: 14px; min-height: 118px; }
.export-option.selected { border-color: var(--violet); background: var(--violet-soft); }
.preview-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border-radius: var(--radius); overflow: hidden; }
.preview-table th, .preview-table td { border: 1px solid var(--line); padding: 9px; text-align: left; vertical-align: top; }
.preview-table th { background: #f4f7fb; }
.job-row { padding: 10px 12px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }

.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(255,255,255,.62); }
.status-line { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.danger { color: var(--rose); border-color: #e4bdc5; background: #fff7f8; }
.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.primary:hover { color: #fff; filter: brightness(.95); }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr; position: static; }
  .account { justify-content: start; }
  .home-workspace, .split-page { grid-template-columns: 1fr; }
  .analysis-panel { position: static; }
  .detail-hero { grid-template-columns: 72px minmax(0,1fr); }
  .detail-actions { grid-column: 1 / -1; justify-content: start; }
  .wide-options { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100vw - 18px, 1180px); margin-top: 10px; }
  .post-card { grid-template-columns: 40px minmax(0,1fr); padding: 12px; }
  .post-avatar { width: 40px; height: 40px; }
  .post-tools button { flex: 1 1 42%; }
  .filters input, .filters select, .date-field { flex: 1 1 100%; }
  .date-field { grid-template-columns: 58px minmax(0, 1fr); }
  .boss-strip, .boss-grid { grid-template-columns: 1fr; }
  .wide-options { grid-template-columns: 1fr; }
}

/* ---- setup / first-run cookie page ---- */
.setup-overlay {
  display: grid; place-items: center; min-height: 98vh;
  padding: 20px;
}
.setup-card {
  max-width: 560px; width: 100%;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 32px 28px;
}
.setup-logo {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--brand, var(--blue)); color: #fff;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 900;
  margin-bottom: 18px;
}
.setup-card h1 { margin: 0 0 6px; font-size: 22px; color: var(--ink); }
.setup-card > p { color: var(--muted); margin: 0 0 18px; line-height: 1.6; }
.setup-steps { margin-bottom: 18px; }
.setup-steps h3 { margin: 0 0 8px; font-size: 14px; color: var(--ink); }
.setup-steps ol { margin: 0; padding-left: 18px; color: var(--ink); line-height: 1.8; font-size: 14px; }
.setup-steps li { margin: 4px 0; }
.setup-steps kbd {
  font-family: inherit; font-size: 13px;
  background: var(--blue-soft); border: 1px solid var(--blue);
  border-radius: 4px; padding: 1px 5px;
}
.setup-steps code {
  display: inline-block; margin-top: 3px;
  background: #f4f5f8; border: 1px solid var(--line);
  border-radius: 5px; padding: 6px 8px;
  font-size: 12px; word-break: break-all;
  line-height: 1.5;
}
.setup-steps details { margin-top: 8px; font-size: 13px; color: var(--muted); }
.setup-steps details p { margin: 4px 0 0; }
.setup-form input,
.setup-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font: inherit; font-size: 14px;
  background: #fafbfc; margin-bottom: 10px;
}
.setup-form input:focus,
.setup-form textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.setup-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; gap: 12px;
}
.setup-actions .error { color: #c0392b; font-size: 13px; }
.setup-actions .success { color: var(--green); font-size: 13px; }
.setup-note {
  margin: 18px 0 0; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 14px;
}
.step-row {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 10px; font-size: 14px; color: var(--ink); line-height: 1.5;
}
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--blue); color: #fff; display: grid;
  place-items: center; font-size: 13px; font-weight: 700;
  flex-shrink: 0; margin-top: 1px;
}
.step-link {
  color: var(--blue); font-weight: 700; text-decoration: none;
  border-bottom: 1px dashed var(--blue);
}
.step-link:hover { border-bottom-style: solid; }
.step-row kbd {
  font-family: inherit; font-size: 12px;
  background: var(--blue-soft); border: 1px solid var(--blue);
  border-radius: 4px; padding: 1px 5px;
}
.step-row code {
  display: inline-block; margin: 3px 0;
  background: #f4f5f8; border: 1px solid var(--line);
  border-radius: 5px; padding: 3px 6px;
  font-size: 12px; word-break: break-all;
}
.snippet-box {
  display: block; width: 100%; margin: 6px 0; padding: 8px;
  background: #f4f5f8; border: 1px solid var(--line);
  border-radius: 6px; font-size: 12px; word-break: break-all;
  line-height: 1.4; font-family: monospace; resize: none;
  -webkit-user-select: all; user-select: all;
}
