@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/inter-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/inter-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: Fraunces;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/fraunces-latin-600-normal.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #0e1210;
  --card: #171c19;
  --card-2: #202722;
  --line: rgba(231, 239, 233, 0.1);
  --text: #e7efe9;
  --muted: #9aa89f;
  --dim: #738078;
  --orange: #f0a04b;
  --up: #8fceab;
  --down: #ef8b7a;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  --sans: Inter, ui-sans-serif, system-ui, sans-serif;
  --serif: Fraunces, ui-serif, Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(240, 160, 75, 0.14), transparent 55%),
    var(--bg);
  line-height: 1.45;
}
body.chart-open { overflow: hidden; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.wrap {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 0 calc(28px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.kicker {
  margin: 0 0 2px;
  color: var(--orange);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.clock {
  margin: 0;
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.85rem;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.seg button, .ghost, .text-btn {
  background: transparent;
  border: 0;
  color: var(--text);
}
.seg button { padding: 8px 12px; }
.seg button[aria-pressed="true"] { background: var(--text); color: #121614; }
.ghost, .text-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
}
.ghost:hover, .text-btn:hover, .seg button:hover { border-color: rgba(240, 160, 75, 0.6); }

.board {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  grid-template-areas:
    "btc" "fng" "strc" "fx" "ex" "etf" "stocks" "news";
}
.tile-btc { grid-area: btc; }
.tile-fng { grid-area: fng; }
.tile-strc { grid-area: strc; }
.tile-fx { grid-area: fx; }
.tile-ex { grid-area: ex; }
.tile-etf { grid-area: etf; }
.tile-stocks { grid-area: stocks; }
.tile-news { grid-area: news; }

.tile {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 42%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.tile-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.tile h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.src, .updated, .fine {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 0.78rem;
}
.updated { font-family: var(--mono); text-align: right; white-space: nowrap; }
.src a { color: var(--muted); }

.price-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}
.price-line { display: flex; align-items: baseline; gap: 0.45rem; flex-wrap: wrap; }
.num, .chart-price, .dividend-value, .kpi-value, .gauge-value {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.num { font-size: clamp(2.7rem, 10vw, 4.7rem); line-height: 0.95; }
.ccy { color: var(--muted); font-size: 1rem; }
.chg { display: inline-block; margin-top: 8px; font-weight: 600; }
.eur-line, .meta { display: block; margin-top: 6px; color: var(--muted); }
.chart-hint {
  display: inline-block;
  margin-top: 12px;
  color: var(--orange);
  font-size: 0.92rem;
}
.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}
.live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  display: block;
}
.live.on i { background: var(--up); }

.up { color: var(--up); }
.down { color: var(--down); font-weight: 600; }
.flat { color: var(--muted); }
.down-detail, .loading { color: var(--dim); margin: 4px 0; }
.banner {
  background: rgba(240, 160, 75, 0.1);
  border: 1px solid rgba(240, 160, 75, 0.35);
  color: #f3d7b4;
  border-radius: 12px;
  padding: 8px 10px;
  margin: 0 0 10px;
}

.gauge-layout { display: grid; grid-template-columns: minmax(160px, 230px) 1fr; gap: 8px; align-items: end; }
.gauge { position: relative; }
.gauge svg { width: 100%; height: auto; display: block; }
.gauge-value {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  text-align: center;
  font-size: 2.5rem;
}
.gauge-label { margin: 0; font-family: var(--serif); font-size: 1.8rem; }

.kpi-row, .fx-grid { display: grid; gap: 12px; }
.kpi-row { grid-template-columns: 1fr 1fr; }
.kpi-label { margin: 0; color: var(--dim); font-size: 0.78rem; }
.kpi-value { margin: 2px 0 0; font-size: 1.55rem; line-height: 1.1; }
.badge {
  display: inline-block;
  border: 1px dashed rgba(240, 160, 75, 0.55);
  color: #f3d7b4;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  margin-bottom: 6px;
}
.dividend { margin: 4px 0 12px; }
.note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.days, .chips, .quotes, .news-list { list-style: none; margin: 0; padding: 0; }
.day {
  display: grid;
  grid-template-columns: 4.4rem 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 5px 0;
  font-variant-numeric: tabular-nums;
}
.bar { height: 8px; background: rgba(231, 239, 233, 0.08); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; }
.bar .up { background: var(--up); }
.bar .down { background: var(--down); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  display: flex;
  gap: 8px;
  align-items: baseline;
  background: var(--card-2);
  border-radius: 999px;
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
}
.chip-sym { font-family: var(--mono); font-size: 0.82rem; }
.cross {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
h3 { margin: 12px 0 6px; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.add-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.add-form input {
  width: 8.5rem;
  background: #101512;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  text-transform: uppercase;
}
.primary {
  background: var(--orange);
  color: #1c1308;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
}
.quote {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto auto;
  gap: 8px 14px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.symbol { font-family: var(--mono); font-weight: 500; }
.quote .name { color: var(--dim); font-size: 0.82rem; }
.quote .px { text-align: right; font-variant-numeric: tabular-nums; }
.form-msg { min-height: 1.2em; color: var(--dim); font-size: 0.85rem; }

.news-item { padding: 12px 0; border-top: 1px solid var(--line); }
.news-meta { margin: 0; color: var(--muted); font-size: 0.86rem; }
.news-item p { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.news-link { color: var(--orange); }

.foot {
  margin-top: 18px;
  color: var(--dim);
  font-size: 0.8rem;
}
.ios-hint { display: none; }

.chart-view {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
}
.chart-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}
.chart-price { margin: 0; font-size: clamp(1.6rem, 3vw, 2.4rem); }
.chart-sub { margin: 0; }
.tfs { display: flex; gap: 6px; overflow-x: auto; margin-left: auto; }
.tfs button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}
.tfs button[aria-pressed="true"] { background: var(--orange); color: #1c1308; border-color: transparent; }
.chart-status { min-height: 1.2em; margin: 6px 0; }
.chart-canvas { flex: 1; min-height: 240px; }
.chart-foot { color: var(--dim); font-size: 0.8rem; margin: 6px 0 0; }
.chart-foot a { color: var(--muted); }

.login-card {
  width: min(420px, calc(100% - 28px));
  margin: 12vh auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.login-card label { display: block; margin: 12px 0; }
.login-card input {
  width: 100%;
  margin-top: 6px;
  background: #101512;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
}

@media (max-width: 720px) {
  .updated { white-space: normal; text-align: left; }
  .tile-head { flex-direction: column; }
  .gauge-layout, .kpi-row { grid-template-columns: 1fr; }
  .quote { grid-template-columns: 1fr auto; }
  .quote .remove { grid-column: 1 / -1; justify-self: start; }
  .ios-hint { display: block; }
  .tfs { margin-left: 0; width: 100%; }
}

@media (min-width: 980px) {
  .wrap { width: min(1280px, calc(100% - 40px)); }
  .board {
    grid-template-columns: minmax(0, 1.35fr) minmax(420px, 0.92fr);
    grid-template-areas:
      "btc fng"
      "btc fx"
      "strc ex"
      "etf etf"
      "stocks stocks"
      "news news";
  }
  .tile-btc { min-height: 320px; }
  .tile-fng h2,
  .tile-fx h2,
  .tile-fx .kpi-label,
  .tile-fx .kpi-value,
  .gauge-label { white-space: nowrap; }
  .tile-fng .gauge-layout {
    grid-template-columns: 210px minmax(0, 1fr);
    align-items: center;
  }
  .tile-fng .updated,
  .tile-fx .updated { white-space: nowrap; }
}

html.tv { font-size: 18px; }
html.tv .wrap { width: min(1800px, calc(100% - 48px)); }
html.tv h1 { font-size: 3.4rem; }
html.tv .num { font-size: 5.4rem; }
html.tv .tile { padding: 22px 22px 18px; border-radius: 28px; }
html.tv .tile h2 { font-size: 1.35rem; }
html.tv .gauge-value { font-size: 3.2rem; }
html.tv .gauge-label { font-size: 2.4rem; }
html.tv .kpi-value { font-size: 2rem; }
html.tv .board {
  grid-template-columns: 1.45fr 1fr 1fr;
  gap: 18px;
  grid-template-areas:
    "btc fng fx"
    "btc strc ex"
    "etf etf etf"
    "stocks stocks stocks"
    "news news news";
}
html.tv .day { font-size: 1.05rem; }
html.tv .ios-hint { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
