:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-strong: #111827;
  --text: #17202f;
  --muted: #697386;
  --line: #d9e0ea;
  --green: #0f9f6e;
  --red: #d64545;
  --amber: #b7791f;
  --blue: #2563eb;
  --cyan: #0891b2;
  --shadow: 0 18px 50px rgba(20, 32, 54, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.topbar,
main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

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

.topbar h1,
h2,
p {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(1.6rem, 4vw, 2.7rem);
  line-height: 1.02;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
}

.seo-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.seo-nav a {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-weight: 750;
  padding: 9px 11px;
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.hero {
  display: grid;
  gap: 16px;
}

.forecast-switcher {
  align-items: center;
  background: rgba(245, 247, 250, 0.94);
  border: 1px solid rgba(217, 224, 234, 0.9);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(20, 32, 54, 0.12);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 0 16px;
  padding: 8px;
  position: sticky;
  top: 0;
  z-index: 50;
}

@supports (backdrop-filter: blur(10px)) {
  .forecast-switcher {
    backdrop-filter: blur(10px);
  }
}

.forecast-panel,
.chart-section,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.forecast-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  min-height: 230px;
  overflow: hidden;
  padding: clamp(22px, 5vw, 38px);
  position: relative;
}

.forecast-panel::before {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.12), rgba(8, 145, 178, 0.08), transparent);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.forecast-copy,
.confidence {
  position: relative;
  z-index: 1;
}

.pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 18px;
  padding: 7px 11px;
}

.warning {
  background: #fff4d6;
  color: #7a4c00;
}

#forecastValue {
  color: var(--surface-strong);
  font-size: clamp(3.4rem, 14vw, 7.2rem);
  line-height: 0.92;
  margin: 6px 0 14px;
}

#forecastSummary {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  max-width: 700px;
}

.horizon-block {
  border-left: 4px solid var(--blue);
  display: grid;
  gap: 4px;
  margin-top: 22px;
  padding-left: 14px;
}

.horizon-block span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.horizon-block strong {
  font-size: clamp(1.25rem, 3vw, 1.8rem);
}

.reliability-block {
  border-left-color: var(--green);
}

.bias-block {
  border-left-color: var(--amber);
}

.confidence {
  align-self: center;
  display: grid;
  justify-items: center;
  min-width: 142px;
}

.confidence svg {
  height: 132px;
  transform: rotate(-90deg);
  width: 132px;
}

.confidence circle {
  fill: none;
  stroke-linecap: round;
  stroke-width: 11;
}

.track {
  stroke: #e6ecf3;
}

.meter {
  stroke: var(--blue);
  stroke-dasharray: 301.59;
  stroke-dashoffset: 301.59;
  transition: stroke-dashoffset 250ms ease, stroke 250ms ease;
}

.confidence strong {
  font-size: 1.45rem;
  margin-top: -82px;
}

.confidence span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 48px;
}

.segmented {
  background: #e9eef5;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  gap: 4px;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  padding: 4px;
}

.segmented button {
  background: transparent;
  border-color: transparent;
  display: grid;
  gap: 2px;
  justify-items: center;
  min-height: 58px;
  min-width: 118px;
  padding: 8px 12px;
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.segmented button .mode-title {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 850;
}

.segmented button .mode-horizon {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.segmented button.active,
.segmented button[aria-pressed="true"] {
  background: #17202f;
  border-color: #17202f;
  box-shadow: 0 8px 18px rgba(23, 32, 47, 0.18);
}

.segmented button.active .mode-title,
.segmented button[aria-pressed="true"] .mode-title,
.segmented button.active .mode-horizon,
.segmented button[aria-pressed="true"] .mode-horizon {
  color: #ffffff;
}

.forecast-switcher.is-loading .segmented button.active,
.forecast-switcher.is-loading .segmented button[aria-pressed="true"] {
  box-shadow: none;
}

.chart-section {
  margin-top: 18px;
  padding: clamp(16px, 3vw, 24px);
}

.section-title {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title h2,
.panel h2 {
  font-size: clamp(1.1rem, 3vw, 1.55rem);
  line-height: 1.15;
  margin-top: 4px;
}

#lastPrice {
  font-size: clamp(1.1rem, 4vw, 2rem);
  font-weight: 850;
}

.chart-range {
  color: var(--muted);
  margin-top: 6px;
}

canvas {
  aspect-ratio: 12 / 5.2;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: auto;
  max-height: 520px;
  width: 100%;
}

.legend {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.legend span {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.legend i {
  display: inline-block;
}

.close-line,
.band-line,
.fib-line {
  height: 3px;
  width: 24px;
}

.close-line {
  background: var(--blue);
}

.band-line {
  background: var(--cyan);
}

.fib-line {
  background: var(--amber);
}

.pivot-dot {
  background: var(--red);
  border-radius: 999px;
  height: 9px;
  width: 9px;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  margin-top: 18px;
}

.lower {
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.75fr);
  padding-bottom: 32px;
}

.forecast-types {
  grid-column: 1 / -1;
}

.history-panel {
  margin-top: 18px;
}

.why-panel {
  margin-top: 18px;
}

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

.why-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 13px;
}

.why-grid span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.why-grid strong {
  line-height: 1.35;
}

.diagnostics {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 14px;
}

.diagnostics summary {
  cursor: pointer;
  font-weight: 850;
}

.diagnostics-body {
  color: var(--muted);
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.panel {
  padding: clamp(16px, 3vw, 24px);
}

.compact {
  align-items: center;
}

.score {
  background: #edf4ff;
  border-radius: 999px;
  color: var(--blue);
  font-weight: 850;
  padding: 8px 12px;
  text-align: right;
  white-space: normal;
}

.indicator-list {
  display: grid;
  gap: 10px;
}

.indicator {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 7px;
  padding: 13px;
}

.indicator header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.indicator h3 {
  font-size: 1rem;
  margin: 0;
}

.indicator p {
  color: var(--muted);
  line-height: 1.45;
}

.stance {
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 850;
  padding: 5px 9px;
}

.stance.Up {
  background: #daf5e9;
  color: #08734e;
}

.stance.Down {
  background: #ffe0e0;
  color: #a62b2b;
}

.stance.Neutral,
.stance.Trend {
  background: #eef2f7;
  color: #475569;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.history-stats {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.history-stats span {
  background: #edf4ff;
  border-radius: 999px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 850;
  padding: 7px 10px;
}

.history-table-wrap {
  overflow-x: auto;
}

.accuracy-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.accuracy-card {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 13px;
}

.accuracy-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.accuracy-card strong {
  font-size: 1.4rem;
}

.history-table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.history-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.history-table td {
  font-size: 0.92rem;
}

.result {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 850;
  padding: 5px 9px;
}

.result.correct {
  background: #daf5e9;
  color: #08734e;
}

.result.incorrect {
  background: #ffe0e0;
  color: #a62b2b;
}

.result.pending {
  background: #eef2f7;
  color: #475569;
}

.status-list div {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.warnings {
  color: #8a5c00;
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.warnings:empty {
  display: none;
}

.import-box {
  border: 1px dashed #aebbd0;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 6px;
  padding: 16px;
}

.import-box span {
  font-weight: 850;
}

.import-box small,
.explain-list p,
.type-list p,
.support p,
.disclaimer {
  color: var(--muted);
  line-height: 1.5;
}

.type-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.type-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.type-list h3 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.import-box input {
  margin-top: 6px;
  max-width: 100%;
}

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

.support {
  background: var(--surface-strong);
  color: #fff;
}

.support .eyebrow,
.support p,
.support .disclaimer {
  color: #cbd5e1;
}

.crypto-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.crypto-row {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  padding: 10px;
}

.crypto-row span {
  color: #ffffff;
  font-weight: 900;
}

.crypto-row code {
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.crypto-row button {
  background: #ffffff;
  color: var(--text);
  min-height: 34px;
  padding: 0 10px;
}

.disclaimer {
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: 16px;
}

.seo-page {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 18px auto;
  padding: clamp(18px, 4vw, 30px);
  width: min(1180px, calc(100% - 32px));
}

main .seo-page {
  width: 100%;
}

.seo-page h1,
.seo-page h2,
.seo-page h3 {
  margin: 14px 0 8px;
}

.seo-page p,
.seo-page li {
  color: var(--muted);
  line-height: 1.6;
}

.seo-metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 18px 0;
}

.seo-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 14px;
}

.seo-metrics span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.seo-metrics strong {
  font-size: 1.35rem;
}

.seo-list {
  display: grid;
  gap: 10px;
  padding-left: 20px;
}

.disclaimer-light {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

.site-footer {
  color: var(--muted);
  display: grid;
  gap: 6px;
  margin: 0 auto;
  padding: 24px 0 36px;
  width: min(1180px, calc(100% - 32px));
}

.site-footer a {
  color: var(--blue);
}

.is-up #forecastValue {
  color: var(--green);
}

.is-down #forecastValue {
  color: var(--red);
}

.is-neutral #forecastValue {
  color: var(--amber);
}

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

  .forecast-panel,
  .grid,
  .lower {
    grid-template-columns: 1fr;
  }

  .confidence {
    justify-self: start;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .forecast-switcher {
    gap: 8px;
    padding: 7px;
  }

  .segmented {
    display: flex;
    flex: 1 1 auto;
    grid-template-columns: none;
    min-width: 0;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .segmented button {
    flex: 0 0 136px;
    min-width: 136px;
    scroll-snap-align: start;
  }

  #refreshButton {
    flex: 0 0 auto;
    min-width: 86px;
    padding: 0 12px;
  }

  .type-list {
    grid-template-columns: 1fr;
  }

  .accuracy-strip {
    grid-template-columns: 1fr;
  }

  .seo-metrics {
    grid-template-columns: 1fr;
  }

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

  .crypto-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar,
  main {
    width: min(100% - 20px, 1180px);
  }

  .forecast-panel {
    padding: 18px;
  }

  #forecastValue {
    font-size: 3.15rem;
  }
}
