:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: #0b1020;
  color: #e8ecf4;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #0b1020;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

header,
main {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 0 20px;
}

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

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
}

header p,
.hint {
  color: #9aa7bd;
}

header p,
.hint,
.news-source,
.news-meta {
  margin-bottom: 0;
  font-size: 0.88rem;
}

main {
  display: grid;
  gap: 16px;
  padding-bottom: 48px;
}

.panel,
.news-card {
  border: 1px solid #25304a;
  border-radius: 14px;
  background: #121a2d;
}

.panel {
  padding: 20px;
}

.section-heading,
.row,
.news-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading,
.news-meta {
  justify-content: space-between;
}

.section-heading h2 {
  margin-bottom: 4px;
}

input,
button {
  min-height: 44px;
  border-radius: 9px;
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid #34415e;
  padding: 0 12px;
  background: #0c1426;
  color: inherit;
}

button {
  border: 0;
  padding: 0 16px;
  cursor: pointer;
  background: #4c7dff;
  color: white;
  font-weight: 700;
}

button.secondary {
  border: 1px solid #34415e;
  background: transparent;
}

.compact input {
  width: 120px;
}

.status {
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status.connected {
  background: #153d2b;
  color: #7fe0a7;
}

.status.disconnected {
  background: #42232a;
  color: #ff9da8;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 7px 10px;
  background: #253556;
}

.chip button {
  min-width: 28px;
  min-height: 28px;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: #b8c4d8;
  font-size: 1.2rem;
}

.watchlist-toggle {
  min-height: 34px;
  border: 1px solid #34415e;
  border-radius: 999px;
  padding: 0 12px;
  background: transparent;
  color: #b8c4d8;
}

.watchlist-count {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
}

.status-grid,
.statistics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.status-box,
.statistic-box {
  border: 1px solid #2a3651;
  border-radius: 10px;
  padding: 12px;
}

.statistic-box strong,
.statistic-box span {
  display: block;
}

.statistic-box strong {
  font-size: 1.45rem;
}

.statistic-box span,
.statistics-time {
  margin-top: 4px;
  color: #9aa7bd;
  font-size: 0.84rem;
}

.status-box strong,
.status-box span {
  display: block;
}

.status-box span {
  margin-top: 4px;
  color: #9aa7bd;
  font-size: 0.84rem;
}

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

.news-card {
  padding: 16px;
  overflow: hidden;
}

.news-image {
  width: calc(100% + 32px);
  max-height: 360px;
  margin: -16px -16px 16px;
  object-fit: cover;
}

.news-card h3 {
  margin: 12px 0 8px;
  line-height: 1.3;
}

.news-card a {
  color: #f2f5fa;
  text-decoration: none;
}

.news-card a:hover {
  text-decoration: underline;
}

.news-symbols {
  display: flex;
  gap: 6px;
}

.news-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.news-tag {
  border: 1px solid #34415e;
  border-radius: 999px;
  padding: 3px 7px;
  background: #1b2740;
  color: #b8c4d8;
  font-size: 0.72rem;
  font-weight: 700;
}

.news-tag.importance-critical,
.news-tag.sentiment-negative {
  border-color: #7f3540;
  background: #42232a;
  color: #ffb2bb;
}

.news-tag.importance-important {
  border-color: #87671e;
  background: #3d3218;
  color: #f3d47a;
}

.news-tag.sentiment-positive {
  border-color: #236343;
  background: #153d2b;
  color: #7fe0a7;
}

.news-tag.sentiment-neutral,
.news-tag.sentiment-mixed {
  border-color: #3d537d;
  background: #223354;
  color: #b8ceff;
}

.symbol {
  border-radius: 6px;
  padding: 3px 6px;
  background: #294882;
  color: #dbe7ff;
  font-size: 0.75rem;
  font-weight: 800;
}

.news-summary {
  color: #c2cad8;
  line-height: 1.5;
}

.news-source,
.news-meta {
  color: #8e9bb1;
}

.error {
  margin-bottom: 12px;
  border-radius: 8px;
  padding: 10px;
  background: #42232a;
  color: #ffb2bb;
}

dialog {
  width: min(820px, calc(100% - 24px));
  max-height: calc(100vh - 40px);
  border: 1px solid #34415e;
  border-radius: 14px;
  padding: 24px;
  background: #121a2d;
  color: #e8ecf4;
}

dialog::backdrop {
  background: rgb(2 6 16 / 78%);
}

.reader-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #2a3651;
  padding-bottom: 16px;
}

.reader-header h2 {
  margin: 12px 0 6px;
  line-height: 1.25;
}

.reader-content {
  padding: 12px 0;
  color: #d8deea;
  font-size: 1.03rem;
  line-height: 1.65;
}

.reader-image {
  width: calc(100% + 48px);
  max-height: 480px;
  margin: 0 -24px;
  object-fit: cover;
}

.reader-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 16px auto;
  border-radius: 8px;
}

.reader-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.reader-content th,
.reader-content td {
  border: 1px solid #34415e;
  padding: 8px;
}

.reader-content pre {
  overflow-x: auto;
  border-radius: 8px;
  padding: 12px;
  background: #091021;
}

.reader-content a {
  color: #8fb0ff;
}

.reader-content blockquote {
  margin-left: 0;
  border-left: 3px solid #4c7dff;
  padding-left: 14px;
  color: #b7c2d5;
}

.source-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 9px;
  padding: 0 16px;
  background: #4c7dff;
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.hidden {
  display: none;
}

@media (max-width: 620px) {
  :root {
    font-size: 17px;
  }

  body {
    padding-right: env(safe-area-inset-right);
    padding-left: env(safe-area-inset-left);
  }

  header,
  main {
    width: min(100% - 16px, 960px);
  }

  header {
    gap: 12px;
    padding: max(18px, env(safe-area-inset-top)) 4px 14px;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    gap: 12px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .panel {
    border-radius: 16px;
    padding: 16px;
  }

  .section-heading .row {
    width: 100%;
  }

  input,
  button,
  .source-button {
    min-height: 50px;
    font-size: 1rem;
  }

  input {
    padding: 0 14px;
  }

  button {
    padding: 0 18px;
  }

  .compact input {
    width: 100%;
  }

  .status {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .chips {
    gap: 9px;
    margin-top: 14px;
  }

  .chip {
    min-height: 44px;
    padding: 6px 8px 6px 12px;
  }

  .chip button {
    min-width: 32px;
    min-height: 32px;
  }

  .status-grid,
  .statistics-grid {
    grid-template-columns: 1fr;
  }

  .news-list {
    gap: 14px;
  }

  .news-card {
    border-radius: 16px;
    padding: 16px;
  }

  .news-card h3 {
    margin: 12px 0 10px;
    font-size: 1.18rem;
    line-height: 1.38;
  }

  .news-summary {
    font-size: 1rem;
    line-height: 1.6;
  }

  .news-meta,
  .news-source,
  header p,
  .hint {
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .news-tag {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .symbol {
    padding: 4px 7px;
    font-size: 0.8rem;
  }

  dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: max(16px, env(safe-area-inset-top)) 16px
      max(20px, env(safe-area-inset-bottom));
  }

  .reader-header {
    flex-direction: column-reverse;
    gap: 12px;
  }

  .reader-header h2 {
    font-size: 1.45rem;
    line-height: 1.3;
  }

  .reader-image {
    width: calc(100% + 32px);
    max-height: 42vh;
    margin: 0 -16px;
  }

  .reader-content {
    font-size: 1.08rem;
    line-height: 1.72;
  }

  .source-button {
    width: 100%;
    justify-content: center;
  }
}

