:root {
  color-scheme: light;
  --bg: #f2f4f1;
  --surface: #fcfdfb;
  --ink: #172326;
  --muted: #5b6968;
  --line: #d6dfda;
  --brand: #12373c;
  --brand-soft: #dfe8e3;
  --accent: #b34e2e;
  --accent-soft: #f6e5df;
  --success: #247066;
  --nav-height: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(185, 82, 49, 0.34);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.signal-header {
  position: relative;
  overflow: hidden;
  color: #f8faf7;
  background: var(--brand);
  padding: max(16px, env(safe-area-inset-top)) 20px 30px;
}

.signal-header::after {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  right: -92px;
  bottom: -122px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  box-shadow:
    0 0 0 38px rgba(255, 255, 255, 0.045),
    0 0 0 76px rgba(255, 255, 255, 0.025);
  pointer-events: none;
}

.header-bar,
.briefing,
main {
  width: min(100%, 720px);
  margin-inline: auto;
}

.header-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.identity-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--brand);
  background: #d8e0d5;
  font-size: 17px;
  font-weight: 900;
}

.header-action {
  min-height: 44px;
  padding: 0 12px;
  color: #f8faf7;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.briefing {
  position: relative;
  z-index: 1;
  padding-top: 32px;
}

.briefing-date {
  margin: 0 0 8px;
  color: rgba(248, 250, 247, 0.72);
  font-size: 13px;
}

.briefing h1 {
  max-width: 12ch;
  margin: 0;
  font-size: 34px;
  line-height: 1.14;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.briefing-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 22px;
  color: rgba(248, 250, 247, 0.75);
  font-size: 13px;
}

.briefing-stats strong {
  color: #fff;
  font-size: 17px;
}

.offline-banner {
  width: 100%;
  padding: 10px 20px;
  color: #5c3a0a;
  background: #f5e9c9;
  font-size: 13px;
  text-align: center;
}

main {
  padding: 0 18px 28px;
}

.control-dock {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -18px;
  padding: 16px 18px 12px;
  background: rgba(242, 244, 241, 0.96);
  border-bottom: 1px solid transparent;
}

.control-dock.is-stuck {
  border-color: var(--line);
}

.search-box {
  display: grid;
  grid-template-columns: 24px 1fr 44px;
  align-items: center;
  min-height: 48px;
  padding-left: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.search-box > span {
  color: var(--brand);
  font-size: 22px;
  line-height: 1;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 15px;
}

.search-box input::placeholder {
  color: #687574;
  opacity: 1;
}

.search-box button {
  width: 44px;
  height: 44px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 3px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #3f4d4c;
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
}

.filter-chip.is-active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.filter-chip.signal-chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
}

.secondary-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 10px;
}

.secondary-controls label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px 0 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-size: 12px;
}

.secondary-controls select {
  min-width: 0;
  height: 42px;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.stream-section {
  padding-top: 22px;
}

.stream-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--brand);
}

.stream-heading p {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.stream-heading h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.stream-heading > span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.intel-stream {
  margin: 0;
  padding: 0;
  list-style: none;
}

.intel-item {
  border-bottom: 1px solid var(--line);
}

.intel-button {
  width: 100%;
  min-height: 116px;
  padding: 18px 2px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.item-topline,
.item-bottomline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.item-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.item-kind::before {
  content: "";
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
}

.item-kind.video {
  color: var(--accent);
}

.heat {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.heat.is-hot {
  color: var(--accent);
  font-weight: 800;
}

.intel-button h3 {
  margin: 9px 0 12px;
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.source {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-tag {
  flex: 0 0 auto;
  padding: 3px 8px;
  color: #445451;
  background: var(--brand-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.loading-state,
.error-state,
.empty-state {
  padding: 42px 16px;
  text-align: center;
}

.loading-state p,
.error-state p,
.empty-state p {
  color: var(--muted);
  font-size: 14px;
}

.loading-line {
  display: block;
  width: 100%;
  height: 12px;
  margin: 12px 0;
  background: #e0e6e2;
  border-radius: 4px;
  animation: pulse 1.4s ease-in-out infinite;
}

.loading-line.short {
  width: 68%;
}

.error-state button,
.empty-state button,
.primary-button {
  min-height: 46px;
  padding: 0 18px;
  color: #fff;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding: 6px 16px var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.nav-item {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  min-height: 54px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.nav-symbol {
  font-size: 22px;
  line-height: 1;
}

.nav-item.is-active {
  color: var(--brand);
}

.back-to-top {
  position: fixed;
  z-index: 18;
  right: 18px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 14px);
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 4px 8px rgba(18, 55, 60, 0.22);
  font-size: 20px;
}

.reader {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--surface);
}

.reader::backdrop {
  background: rgba(13, 29, 31, 0.65);
}

.reader-shell {
  min-height: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.reader-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: calc(60px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 18px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.reader-header button,
.reader-header a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 0;
  color: var(--brand);
  background: transparent;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.reader article {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 28px 22px 64px;
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.reader article h2 {
  margin: 15px 0 28px;
  font-size: 27px;
  line-height: 1.34;
  letter-spacing: -0.025em;
  text-wrap: pretty;
}

.reader-body {
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
  line-height: 1.9;
}

.reader-body p {
  max-width: 70ch;
  margin: 0 0 1.2em;
  text-wrap: pretty;
}

.reader-fallback {
  padding: 20px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 12px;
}

.install-dialog {
  width: min(calc(100% - 36px), 420px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
}

.install-dialog::backdrop {
  background: rgba(13, 29, 31, 0.68);
}

.install-dialog form {
  position: relative;
  padding: 30px 24px 24px;
}

.dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 26px;
}

.install-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: #fff;
  background: var(--brand);
  font-size: 26px;
  font-weight: 900;
}

.install-dialog h2 {
  margin: 18px 0 12px;
  font-size: 22px;
}

.install-dialog ol {
  padding-left: 22px;
  color: #3e4d4b;
}

.install-dialog li + li {
  margin-top: 8px;
}

.primary-button {
  width: 100%;
  margin-top: 12px;
}

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  width: max-content;
  max-width: calc(100% - 36px);
  padding: 11px 15px;
  color: #fff;
  background: #1f2d2f;
  border-radius: 9px;
  font-size: 13px;
  transform: translateX(-50%);
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

@media (min-width: 721px) {
  .signal-header {
    padding-bottom: 38px;
  }

  .briefing h1 {
    font-size: 40px;
  }

  main {
    padding-inline: 0;
  }

  .control-dock {
    margin-inline: 0;
    padding-inline: 0;
  }
}

@media (max-width: 374px) {
  .secondary-controls {
    grid-template-columns: 1fr;
  }

  .briefing h1 {
    font-size: 31px;
  }

  .reader-header button span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
