/* trendline — dark, minimal, mobile-first. Palette follows the dataviz skill:
   one neutral surface ramp + a single accent per semantic role. */
:root {
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #1f242d;
  --border: #2a303b;
  --text: #e6e9ef;
  --muted: #8b93a1;
  --accent: #46b1c9;          /* price / primary */
  --line: #e0a23c;            /* CAGR trend line */
  --pos: #3fb27f;             /* above trend */
  --neg: #e5674b;             /* below trend */
  --zone: rgba(139, 147, 161, 0.10);
  --radius: 10px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.muted { color: var(--muted); }

/* header */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}
.brand { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; font-size: 15px; }
.brand .dot { color: var(--muted); margin: 0 6px; }
.brand .muted { font-weight: 400; }

.search { position: relative; flex: 1; min-width: 0; }
.search input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.search-results .row {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.search-results .row:last-child { border-bottom: none; }
.search-results .row:hover, .search-results .row.active { background: var(--surface-2); }
.search-results .row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .row .mkt { color: var(--muted); font-size: 12px; flex: none; }
.search-results .empty { padding: 10px 12px; color: var(--muted); }

/* presets */
.presets {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.presets::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #06232b; font-weight: 600; }

/* controls */
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.ctl-spacer { flex: 1; }
.ctl-group { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ctl-group button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.ctl-group button + button { border-left: 1px solid var(--border); }
.ctl-group button.active { background: var(--surface-2); color: var(--text); }
.ctl-group button:hover { color: var(--text); }

/* line panel */
.line-panel {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.lp-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.lp-title { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.lp-actions { display: flex; align-items: center; gap: 12px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--accent); }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 12px; cursor: pointer; }
button.ghost:hover { color: var(--text); }

.calib { margin-top: 10px; gap: 16px; }
.calib.disabled { opacity: 0.45; pointer-events: none; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 9px;
  font-size: 13px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.rate-row { display: flex; align-items: center; gap: 10px; }
.rate-row input[type=number] { width: 84px; }
.rate-row input[type=range] { flex: 1; min-width: 120px; accent-color: var(--line); }

/* chart */
.chart { flex: 1; min-height: 420px; width: 100%; }

.dev-badge {
  margin: 0 14px 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.dev-badge b { color: var(--text); }

.foot { padding: 8px 14px 14px; }
.foot .muted { font-size: 12px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 50;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}

@media (min-width: 720px) {
  .chart { min-height: 520px; }
}
