:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #fffdf8;
  --surface-2: #efede6;
  --text: #11161a;
  --muted: #687170;
  --line: #d8d5cc;
  --accent: #654bd6;
  --accent-soft: #e8e3ff;
  --success: #16865b;
  --danger: #b63843;
  --shadow: 0 14px 38px rgba(30, 26, 18, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131318;
  --surface: #1b1b21;
  --surface-2: #25252c;
  --text: #f6f5f8;
  --muted: #a4a3ad;
  --line: #373740;
  --accent: #9b8cff;
  --accent-soft: #302a50;
  --success: #67d9a7;
  --danger: #ff8a94;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { min-width: 280px; overflow-x: hidden; background: var(--bg); color: var(--text); }
button { color: inherit; font: inherit; }
.shell { width: 100%; max-width: 760px; min-height: 100vh; margin: 0 auto; padding: 14px; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 2px 14px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark { display: block; width: 34px; height: 34px; flex: 0 0 auto; object-fit: contain; }
.brand-copy { display: grid; min-width: 0; }
.brand-copy strong { font-size: .9rem; letter-spacing: .02em; }
.brand-copy small { overflow: hidden; color: var(--muted); font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.intro { padding: 20px 2px 12px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: .66rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.35rem, 6vw, 2rem); line-height: 1.08; }
.intro-copy { margin: 8px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.filters { margin: 0 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.filters-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.filters-title strong { font-size: .72rem; letter-spacing: .04em; }
.filters-title button { padding: 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: .68rem; font-weight: 700; }
.filters-title button:disabled { color: var(--muted); cursor: default; opacity: .55; }
.symbol-list { display: flex; flex-wrap: wrap; gap: 7px; }
.symbol-chip { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; font-size: .68rem; font-weight: 750; }
.symbol-chip.is-active { border-color: var(--accent); background: var(--accent); color: #fff; }
.topics-grid { display: grid; gap: 10px; }
.topic-card { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; width: 100%; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.topic-card > span:first-child { display: grid; gap: 5px; min-width: 0; }
.topic-card strong { font-size: .92rem; line-height: 1.3; }.topic-card small { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: .72rem; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.topic-count { color: var(--muted); font-size: .66rem; white-space: nowrap; }.topic-arrow { color: var(--accent); font-size: 1rem; }
.topic-intro .back { margin-bottom: 14px; }
.feed { display: grid; gap: 10px; }
.card { width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.card:focus-visible, .topic-card:focus-visible, .icon-button:focus-visible, .back:focus-visible, .symbol-chip:focus-visible, .filters-title button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.state { color: var(--accent); font-size: .61rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.state-success { color: var(--success); }.state-failed { color: var(--danger); }.state-canceled { color: var(--muted); }
.direction { margin-left: 7px; padding-left: 7px; border-left: 1px solid var(--line); font-size: .61rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.direction-buy { color: var(--success); }.direction-sell { color: var(--danger); }
time { color: var(--muted); font-size: .65rem; }
.card h2 { margin: 0; font-size: .98rem; line-height: 1.28; }
.summary { display: -webkit-box; margin: 8px 0 0; overflow: hidden; color: var(--muted); font-size: .76rem; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.card-topics { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.card-topics span { padding: 3px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font-size: .61rem; }
.empty, .error { padding: 22px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: center; }
.empty strong, .error strong { display: block; font-size: .9rem; }.empty p, .error p { margin: 6px 0 0; color: var(--muted); font-size: .76rem; }
.article { padding: 16px 2px 30px; }
.back { margin-bottom: 18px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: .72rem; }
.article h1 { margin-bottom: 10px; font-size: clamp(1.45rem, 7vw, 2.3rem); }
.article-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .68rem; }
.article-body { overflow-wrap: anywhere; font-size: .86rem; line-height: 1.65; }
.article-body h1, .article-body h2, .article-body h3 { margin: 1.35em 0 .55em; line-height: 1.2; }
.article-body p { margin: 0 0 1em; }.article-body ul, .article-body ol { padding-left: 22px; }
.article-body img { display: block; width: 100%; max-height: 560px; margin-top: 18px; border-radius: 10px; object-fit: contain; }
.article-body figure { margin: 18px 0; }.article-body figcaption { margin-top: 7px; color: var(--muted); font-size: .68rem; text-align: center; }
.article-body .link-text { color: var(--accent); text-decoration: underline; }
.disclaimer { margin-top: 16px; padding: 12px 2px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: .61rem; line-height: 1.45; }
.loading .card { min-height: 105px; cursor: default; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 220% 100%; animation: pulse 1.1s linear infinite; }
@keyframes pulse { to { background-position: -120% 0; } }

body[data-placement="block"] .shell { max-width: 502px; }
body[data-placement="overview"] { overflow: hidden; }
body[data-placement="overview"] .shell { max-width: none; min-height: 0; padding: 10px 12px; }
body[data-placement="overview"] .masthead, body[data-placement="overview"] .intro-copy, body[data-placement="overview"] .disclaimer { display: none; }
body[data-placement="overview"] .intro { padding: 0 0 8px; }
body[data-placement="overview"] .intro h1 { font-size: 1rem; }
body[data-placement="overview"] .filters { margin-bottom: 8px; padding: 7px; }
body[data-placement="overview"] .filters-title { margin-bottom: 6px; }
body[data-placement="overview"] .symbol-list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
body[data-placement="overview"] .symbol-list::-webkit-scrollbar { display: none; }
body[data-placement="overview"] .symbol-chip { flex: 0 0 auto; padding: 4px 7px; }
body[data-placement="overview"] .feed { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
body[data-placement="overview"] .topics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
body[data-placement="overview"] .topic-card { display: block; min-width: 0; padding: 10px; box-shadow: none; }
body[data-placement="overview"] .topic-count, body[data-placement="overview"] .topic-arrow { display: none; }
body[data-placement="overview"] .card { min-width: 0; padding: 10px; box-shadow: none; }
body[data-placement="overview"] .summary, body[data-placement="overview"] .card-topics { display: none; }
body[data-placement="overview"] .card h2 { display: -webkit-box; overflow: hidden; font-size: .76rem; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

@media (max-width: 430px) {
  .shell { padding: 10px; }.intro { padding-top: 16px; }
  body[data-placement="overview"] .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-placement="overview"] .topics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-placement="overview"] .card:nth-child(3) { display: none; }
  body[data-placement="overview"] .topic-card:nth-child(3) { display: none; }
}
@media (max-height: 240px) {
  .shell { padding: 8px; }.masthead, .intro-copy, .disclaimer, .filters-title { display: none; }.intro { padding: 0 0 7px; }
  .filters { margin-bottom: 6px; padding: 5px; }.symbol-list { flex-wrap: nowrap; overflow-x: auto; }.symbol-chip { flex: 0 0 auto; padding: 3px 6px; }
  .intro h1 { font-size: .95rem; }.feed { gap: 6px; }.card { padding: 9px; }.summary, .card-topics { display: none; }
  .card:nth-child(n+2) { display: none; }
  .topics-grid { gap: 6px; }.topic-card { padding: 9px; }.topic-card small, .topic-count { display: none; }.topic-card:nth-child(n+2) { display: none; }
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
