/* Home page, Design D: one chart at a time, trends picked from the left nav, insights below.
   Desktop fills the window with no page scroll; phones stack and scroll. */

body { height: 100vh; overflow: hidden; }
.main { height: 100vh; }
.top { height: 72px; flex: none; justify-content: center; padding: 0 24px; }
.top .msg { position: absolute; margin-top: 64px; }
.search input { height: 44px; }

/* ---------- left nav: logo, About, Trends accordion, account links pinned bottom ---------- */
.nav { gap: 0; padding: 0; }
.nav .brand { padding: 20px 20px 10px; }
.nav .menu { margin: 0; padding: 0 12px; }
.nav .menu a { min-height: 38px; padding: 0 10px; border-radius: 6px; }
.nav .links { flex-direction: row; gap: 8px; margin-top: auto; padding: 14px 16px 18px; }
.nav .links a { flex: 1; min-height: 38px; font-size: 14px; }

.trends { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 8px; border-top: 1px solid var(--line); }
.trends-head { display: flex; align-items: center; gap: 8px; padding: 14px 22px 8px; }
.trends-head h2 { margin: 0; font-size: 15px; font-weight: 600; color: #fff; }
.trends-head .count {
  margin-left: auto; padding: 2px 8px; border-radius: 5px; background: var(--bg); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.trends-head .count:empty { display: none; }
.trends-close { display: none; }
.trends-filter { padding: 0 12px 8px; }
.trends-filter input {
  width: 100%; height: 34px; padding: 0 10px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
}
.trends-filter input::placeholder { color: #8a8f9c; }
.trends-filter input:focus { border-color: var(--accent); outline: none; }

.trend-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.group-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 10px; flex: none;
  border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 14px; text-align: left; cursor: pointer;
}
.group-btn:hover { background: var(--hover); }
.group-btn .chev { width: 14px; height: 14px; flex: none; color: var(--muted); transition: transform .15s; }
.group-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.group-btn .label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.group-btn .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.group-btn.best { color: #fff; font-weight: 600; height: 34px; }
.group-rows { display: flex; flex-direction: column; gap: 1px; margin: 0 0 6px 10px; padding-left: 8px; border-left: 1px solid var(--line); }
.group-rows[hidden] { display: none; }
.trend-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 32px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 13.5px; text-align: left; cursor: pointer; text-decoration: none;
}
.trend-btn:hover { background: var(--hover); }
.trend-btn .nm { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.trend-btn .sc { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.trend-btn.nofit .nm { color: var(--muted); }
.trend-btn.nofit .sc { font-size: 12px; }
.trend-btn[aria-current="true"] { background: rgba(41, 98, 255, .22); color: #fff; font-weight: 600; }
.trend-btn[aria-current="true"] .sc { color: #fff; }
.trend-btn:disabled { cursor: default; }
.trend-row { display: flex; align-items: center; gap: 2px; }
.trend-row .trend-btn { flex: 1; min-width: 0; }
.guide-link {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 5px; color: var(--muted); opacity: .55;
}
.guide-link svg { width: 14px; height: 14px; }
.trend-row:hover .guide-link, .guide-link:focus-visible { opacity: 1; }
.guide-link:hover { background: var(--hover); color: var(--text); }
.all-trends { margin-left: auto; font-size: 12.5px; color: var(--muted); text-decoration: none; }
.all-trends:hover { color: var(--text); }
.all-trends + .count { margin-left: 0; }
.what-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qc-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: 5px;
  background: transparent; color: var(--muted); font-size: 12px; cursor: pointer;
}
.qc-btn svg { width: 13px; height: 13px; }
.qc-btn:hover { color: var(--text); border-color: #3a3f4d; }
.qc-btn[hidden] { display: none; }
.trend-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ---------- main column ---------- */
#content { flex: 1; min-height: 0; padding: 0; display: flex; flex-direction: column; }

.toolbar { height: 56px; flex: none; display: flex; align-items: center; gap: 20px; padding: 0 24px; }
.periods { display: flex; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; flex: none; }
.periods button {
  height: 34px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.periods button:hover { color: var(--text); background: var(--hover); }
.periods button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.quote { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; min-width: 0; overflow: hidden; }
.quote > span { flex: none; }
.quote .sym { font-family: var(--font-head); font-variation-settings: normal; font-size: 20px; font-weight: 700; color: #fff; }
.quote .px { font-size: 18px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.quote .chg { font-size: 14px; font-weight: 600; }
.quote .chg.up { color: var(--up); }
.quote .chg.down { color: var(--down); }
.quote > .meta { flex: 0 1 auto; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.trends-open { display: none; }

.chart-wrap { flex: 1; min-height: 260px; padding: 0 24px; }
.chart-panel { position: relative; height: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.chart { position: absolute; inset: 0; }
.chart-title {
  position: absolute; left: 16px; top: 12px; right: 400px; z-index: 3; pointer-events: none;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
}
.chart-title h2 { margin: 0; font-size: 15px; font-weight: 700; color: #fff; }
.chart-title .chip {
  padding: 3px 8px; border-radius: 5px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; color: var(--text);
}
.chart-title .sub { flex-basis: 100%; font-size: 12px; color: var(--muted); }
/* drawing toolbar (js/draw.js), top-right inside the chart, clear of the price axis */
.draw-tools {
  position: absolute; top: 10px; right: 76px; z-index: 4; display: flex; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
}
.draw-tools button {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; border: 0; border-radius: 5px;
  background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer;
}
.draw-tools button svg { width: 15px; height: 15px; flex: none; }
.draw-tools button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.draw-tools button[aria-pressed="true"] { background: rgba(242, 184, 75, .16); color: var(--gold); }
.draw-tools button:disabled { opacity: .35; cursor: default; }
.draw-tools button[hidden] { display: none; }
.draw-tools button.danger { color: var(--down); }
.draw-tools button.danger:hover { background: rgba(239, 83, 80, .14); color: var(--down); }
.draw-hint {
  position: absolute; top: 48px; right: 76px; z-index: 4; padding: 4px 9px; border-radius: 5px;
  background: rgba(242, 184, 75, .12); border: 1px solid rgba(242, 184, 75, .4); color: var(--gold); font-size: 12px;
}
.chart-panel.drawing .chart { cursor: crosshair; }

.chart-msg {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 24px; text-align: center;
  color: var(--muted); font-size: 15px; line-height: 1.5; pointer-events: none;
}
.chart-msg[hidden] { display: none; }
.chart-msg.solid { background: var(--bg); pointer-events: auto; }
.chart-msg strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }
.chart-msg .examples { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.chart-msg .examples a {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text);
  text-decoration: none; font-size: 13px; font-weight: 600;
}
.chart-msg .examples a:hover { border-color: var(--accent); }
.chart-msg .examples a { pointer-events: auto; }  /* clickable even when the message lets the chart through */
.chart-panel.loading .chart { opacity: .25; transition: opacity .15s; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- insights strip ---------- */
/* at least 184px; grows when the text needs it so the disclaimer is never cut off */
.insights { min-height: 184px; flex: none; padding: 14px 24px 16px; display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 12px; }
.insights .card { min-width: 0; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.insights h3 {
  margin: 0; font-family: var(--font-text); font-size: 11.5px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.insights .what p { margin: 8px 0 0; font-size: 14px; line-height: 1.55; color: var(--text); }
.insights dl { margin: 0; }
.insights dl div { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 14px; }
.insights dl div:first-child { margin-top: 10px; }
.insights dt { flex: none; max-width: 65%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.insights dd { min-width: 0; margin: 0; color: #fff; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- short desktop windows: allow scrolling instead of crushing the chart ---------- */
@media (min-width: 721px) and (max-height: 640px) {
  body { overflow: auto; }
  .main { height: auto; min-height: 100vh; }
  .chart-wrap { flex: none; height: 420px; }
}

/* ---------- phones ---------- */
@media (max-width: 720px) {
  body { height: auto; overflow: auto; }
  .main { height: auto; }
  .top { height: auto; padding: 12px 14px; }
  .top .msg { position: static; margin-top: 6px; }
  .nav { gap: 8px 12px; padding: 10px 14px; }
  .nav .brand { padding: 0; }
  .nav .menu { padding: 0; }
  .nav .links { margin-top: 0; padding: 0; }
  .nav .links a { flex: none; padding: 0 12px; }

  /* the Trends accordion becomes a full-screen sheet */
  .trends {
    position: fixed; inset: 0; z-index: 50; margin: 0; border: 0; background: var(--panel);
    display: none;
  }
  .trends[data-open] { display: flex; }
  .trends-head { padding: 16px 16px 10px; }
  .trends-close {
    display: grid; place-items: center; width: 36px; height: 36px; margin-left: 4px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 22px; cursor: pointer;
  }
  .trend-btn { min-height: 40px; font-size: 15px; }
  .group-btn { height: 42px; font-size: 15px; }

  .toolbar { height: auto; flex-wrap: wrap; gap: 10px 12px; padding: 12px 14px; }
  .periods { order: 1; width: 100%; }
  .periods button { flex: 1; padding: 0 4px; }
  .quote { order: 2; flex: 1; flex-wrap: wrap; row-gap: 2px; }
  .quote .meta { flex-basis: 100%; }
  .trends-open {
    order: 3; display: inline-flex; align-items: center; height: 36px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text);
    font-size: 14px; font-weight: 600; cursor: pointer;
  }

  .chart-wrap { flex: none; height: 60vh; min-height: 320px; padding: 0 14px; }
  .chart-title { left: 10px; top: 46px; right: 70px; }
  .draw-tools { top: 8px; left: 10px; right: auto; }
  .draw-tools button span { display: none; }
  .draw-hint { top: 8px; right: 70px; }
  .insights { min-height: 0; grid-template-columns: 1fr; padding: 12px 14px 20px; }
}
