:root {
  --bg0: #0e1418;
  --bg1: #152028;
  --ink: #e8eef2;
  --muted: #8fa3b0;
  --line: rgba(232, 238, 242, 0.12);
  --accent: #d4a24c;
  --accent-2: #3db8a0;
  --down: #e07a5f;
  --up: #3db8a0;
  --panel: rgba(21, 32, 40, 0.72);
  --radius: 10px;
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg0);
  line-height: 1.5;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(212, 162, 76, 0.18), transparent 55%),
    radial-gradient(700px 420px at 90% 8%, rgba(61, 184, 160, 0.12), transparent 50%),
    linear-gradient(165deg, #101820 0%, #0e1418 45%, #121a1f 100%);
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-end;
  padding: 2rem clamp(1.25rem, 3vw, 3rem) 1.25rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 4vw, 2.75rem);
  letter-spacing: -0.03em;
  color: var(--accent);
  line-height: 1;
}

.top h1 {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0.4rem 0 0;
  color: var(--muted);
  max-width: 36rem;
}

.lede.click-hint {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  opacity: 0.85;
}

.top-actions {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(21, 32, 40, 0.55);
}

.lang-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.lang-btn[aria-pressed="true"] {
  background: rgba(212, 162, 76, 0.22);
  color: var(--ink);
}

.lang-btn:hover {
  color: var(--ink);
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.btn {
  appearance: none;
  border: 1px solid rgba(212, 162, 76, 0.55);
  background: rgba(212, 162, 76, 0.12);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.btn:hover {
  background: rgba(212, 162, 76, 0.22);
  border-color: var(--accent);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

main {
  padding: 1.25rem clamp(1.25rem, 3vw, 3rem) 3rem;
  display: grid;
  gap: 1.5rem;
}

.ai-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem 1.1rem;
  backdrop-filter: blur(10px);
  animation: rise 480ms ease both;
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
}

.ai-head h2,
.cat h2,
.chart-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stance {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.stance.bull {
  color: var(--up);
  border-color: rgba(61, 184, 160, 0.45);
  background: rgba(61, 184, 160, 0.1);
}

.stance.bear {
  color: var(--down);
  border-color: rgba(224, 122, 95, 0.45);
  background: rgba(224, 122, 95, 0.1);
}

.stance.neutral {
  color: var(--accent);
  border-color: rgba(212, 162, 76, 0.45);
  background: rgba(212, 162, 76, 0.1);
}

.ai-headline {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 500;
}

.ai-bullets {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.ai-bullets li {
  margin-bottom: 0.35rem;
}

.ai-note {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.85;
}

.board {
  display: grid;
  gap: 1.25rem;
}

.cat h2 {
  margin-bottom: 0.65rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  min-height: 7.2rem;
  animation: rise 520ms ease both;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.tile:hover {
  border-color: rgba(212, 162, 76, 0.45);
  background: rgba(28, 40, 48, 0.88);
}

.tile:focus-visible {
  outline: 2px solid rgba(212, 162, 76, 0.65);
  outline-offset: 2px;
}

.tile:nth-child(2) { animation-delay: 40ms; }
.tile:nth-child(3) { animation-delay: 80ms; }

.tile .name {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.tile .price {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.tile .unit {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 0.25rem;
}

.tile .changes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  margin-top: 0.55rem;
  font-size: 0.78rem;
}

.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.flat { color: var(--muted); }

.tile .err {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--down);
}

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.chart-wide {
  grid-column: 1 / -1;
}

.chart-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 0.75rem;
  animation: rise 600ms ease both;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.chart-head p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

footer {
  padding: 0 clamp(1.25rem, 3vw, 3rem) 2rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.sources {
  margin: 0 clamp(1.25rem, 3vw, 3rem) 1.5rem;
  padding: 1.25rem 1.35rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sources-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sources-head p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 48rem;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.source-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 0.95rem;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 160ms ease, background 160ms ease;
}

.source-card:hover {
  border-color: rgba(212, 162, 76, 0.45);
  background: rgba(28, 40, 48, 0.88);
}

.source-card .src-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
}

.source-card .src-via {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--accent);
}

.source-card .src-note {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.source-card .src-url {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  color: #6cb6ff;
  word-break: break-all;
}

.sources-disclaimer {
  margin: 0.9rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.modal-source {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
}

.modal-source a {
  color: #6cb6ff;
  text-decoration: none;
}

.modal-source a:hover {
  text-decoration: underline;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 12, 0.72);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(90vh, 880px);
  overflow: auto;
  background: linear-gradient(165deg, rgba(22, 32, 40, 0.98), rgba(14, 20, 24, 0.98));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem 1.35rem 1.1rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: rise 220ms ease both;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.modal-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.modal-close {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--ink);
  border-color: rgba(212, 162, 76, 0.45);
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
}

.stat .label {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.stat .value {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.stat .value .unit {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}

.stat .value .up { color: var(--up); }
.stat .value .down { color: var(--down); }
.stat .value.up { color: var(--up); }
.stat .value.down { color: var(--down); }

.modal-chart-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem 0.5rem;
  height: 300px;
}

.modal-chart-wrap .chart-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.modal-foot {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

body.modal-open {
  overflow: hidden;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .tiles {
    grid-template-columns: 1fr 1fr;
  }

  .charts {
    grid-template-columns: 1fr;
  }

  .sources-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .top {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-actions {
    text-align: left;
    width: 100%;
    align-items: flex-start;
  }

  .top-actions .btn {
    align-self: flex-start;
  }

  .tiles {
    grid-template-columns: 1fr;
  }

  .modal-stats {
    grid-template-columns: 1fr 1fr;
  }
}
