:root {
  --bg: #f7f9f9;
  --panel: #ffffff;
  --line: #eff3f4;
  --text: #0f1419;
  --muted: #536471;
  --accent: #1d9bf0;
  --accent-soft: rgba(29, 155, 240, 0.08);
  --translation-bg: #f3f8fc;
  --shadow: 0 12px 30px rgba(15, 20, 25, 0.06);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(29, 155, 240, 0.08), transparent 22%),
    linear-gradient(180deg, #f9fbfb 0%, var(--bg) 100%);
  color: var(--text);
  font-family:
    "Segoe UI",
    "PingFang SC",
    "Hiragino Sans GB",
    "Noto Sans SC",
    sans-serif;
}

.page-shell {
  min-height: 100vh;
}

.app-shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 14px 12px 36px;
}

.topbar,
.filter-bar {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px 16px;
}

.topbar-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.05;
}

.filter-bar {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

select,
button {
  font: inherit;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
}

.button {
  border: 0;
  border-radius: 999px;
  min-height: 40px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.button.secondary {
  background: #e7eef3;
  color: var(--text);
}

.button:hover {
  filter: brightness(0.98);
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

.status-line {
  min-height: 22px;
  margin: 10px 4px 12px;
  color: var(--muted);
  font-size: 13px;
}

.feed-list {
  display: grid;
  gap: 12px;
}

.thread-card,
.post-card {
  background: var(--panel);
}

.thread-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(15, 20, 25, 0.05);
}

.thread-item + .thread-item {
  border-top: 1px solid var(--line);
}

.post-card {
  padding: 14px 14px 16px;
}

.feed-list > .post-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(15, 20, 25, 0.05);
}

.post-header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.post-header-main {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}

.avatar,
.avatar-empty {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: 0 0 42px;
}

.avatar {
  object-fit: cover;
  background: #dfe8ee;
}

.avatar-empty {
  background: #dfe8ee;
}

.post-meta {
  min-width: 0;
}

.post-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 168px;
}

.post-action {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(29, 155, 240, 0.2);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.post-action:disabled {
  opacity: 0.62;
  cursor: default;
}

.name-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}

.post-title {
  font-size: 15px;
  font-weight: 700;
}

.screen-name,
.meta-line,
.reply-line,
.card-domain,
.load-more-sentinel {
  color: var(--muted);
}

.screen-name,
.meta-line,
.reply-line,
.card-domain {
  font-size: 13px;
}

.meta-line a {
  color: inherit;
  text-decoration: none;
}

.meta-line a:hover {
  text-decoration: underline;
}

.context-line {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.context-line strong {
  color: var(--accent);
  font-weight: 600;
}

.reply-line {
  margin-top: 10px;
}

.post-text,
.translation-text,
.card-desc {
  white-space: pre-wrap;
  word-break: break-word;
}

.post-text {
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.62;
}

.post-text a,
.translation-text a,
.card-box a,
.video-link a {
  color: var(--accent);
  text-decoration: none;
}

.post-text a:hover,
.translation-text a:hover,
.card-box a:hover,
.video-link a:hover {
  text-decoration: underline;
}

.translation-box {
  margin-top: 10px;
  padding: 8px 10px 8px 12px;
  border-left: 3px solid rgba(29, 155, 240, 0.6);
  border-radius: 12px;
  background: var(--translation-bg);
}

.translation-label {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.translation-text {
  margin-top: 4px;
  color: #24526f;
  font-size: 13px;
  line-height: 1.55;
}

.media-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.media-grid.count-1 {
  grid-template-columns: 1fr;
}

.media-grid.count-2,
.media-grid.count-4 {
  grid-template-columns: repeat(2, 1fr);
}

.media-grid.count-3 {
  grid-template-columns: repeat(2, 1fr);
}

.media-item {
  overflow: hidden;
  border-radius: 18px;
  background: #eef3f6;
}

.media-item img,
.media-item video,
.card-cover {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  background: #eef3f6;
}

.video-link {
  margin-top: 6px;
  font-size: 12px;
}

.card-box,
.embedded-post {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.embedded-post {
  background: #fafcfd;
}

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

.card-box {
  color: inherit;
  text-decoration: none;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}

.card-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.embedded-header {
  display: flex;
  gap: 10px;
}

.embedded-post .avatar,
.embedded-post .avatar-empty {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.embedded-post .post-title {
  font-size: 14px;
}

.embedded-post .post-text {
  margin-top: 8px;
  font-size: 14px;
}

.load-more-sentinel {
  padding: 14px;
  text-align: center;
  font-size: 13px;
}

.analysis-sheet[hidden] {
  display: none;
}

.analysis-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.analysis-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(15, 20, 25, 0.38);
}

.analysis-dialog {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 680px);
  max-height: 78vh;
  margin: 0 auto;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow: auto;
  border-radius: 24px 24px 0 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -18px 50px rgba(15, 20, 25, 0.18);
}

.analysis-handle {
  width: 48px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #d6dfe6;
}

.analysis-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.analysis-head h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.analysis-content {
  margin-top: 14px;
}

.analysis-meta {
  margin-bottom: 12px;
}

.analysis-summary {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.7;
}

.empty-state,
.error-state,
.loading-skeleton {
  padding: 16px;
}

.empty-state,
.error-state {
  color: var(--muted);
}

.error-state {
  color: #c0392b;
}

.skeleton-card {
  height: 118px;
  margin: 12px;
  border-radius: 18px;
  background:
    linear-gradient(90deg, #eef3f6 25%, #f7f9fb 37%, #eef3f6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.25s ease infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

.layout {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 18px 12px 40px;
}

.hero-card,
.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 20px 18px;
}

.hqdd-admin-hero {
  margin-bottom: 16px;
}

.eyebrow {
  margin-bottom: 8px;
  color: #99582a;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-copy {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.panel {
  margin-top: 16px;
  padding: 18px;
}

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

.panel-head h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
}

.hqdd-admin-shell .status-line {
  margin: 0;
}

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

.stat-card {
  min-height: 108px;
  padding: 18px 16px;
  border: 1px solid #d6c3a8;
  border-radius: 22px;
  background: rgba(255, 251, 245, 0.82);
}

.stat-number {
  margin-top: 10px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.job-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button.danger {
  background: #a93540;
}

.config-editor {
  width: 100%;
  min-height: 320px;
  padding: 14px;
  border: 1px solid #d7c6af;
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  font: 13px/1.65 Menlo, Consolas, Monaco, monospace;
  resize: vertical;
}

.sources-table,
.job-run-list {
  display: grid;
  gap: 12px;
}

.source-row,
.job-run-card {
  padding: 14px;
  border: 1px solid #e5d8c7;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
}

.source-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #d7c6af;
  border-radius: 999px;
  background: #fff9f2;
  color: #5f4a35;
  font-size: 13px;
}

.tag-chip input {
  margin: 0;
}

.job-run-card .post-header {
  justify-content: space-between;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(29, 155, 240, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 20px 14px 40px;
  }

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

  .topbar {
    padding: 20px 18px;
  }

  .layout {
    padding: 28px 18px 56px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
