/*
  CTR vs average view duration simulator (/tools/ctr-vs-average-view-duration).

  The widget keeps its own dark palette in every site theme, because its
  script paints the scatter plot directly. Everything is scoped under
  .avd-tool so it does not touch the page chrome around it.
*/
.avd-tool {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #9aa1ad;
  --ctr: #4ea1ff;
  --avd: #ffb547;
  --pos: #4cd18a;
  --neg: #ff6b6b;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}
.avd-tool *, .avd-tool *::before, .avd-tool *::after { box-sizing: border-box; }
.avd-tool h2 { font-size: 0.98rem; margin: 0 0 10px; color: var(--text); }
.avd-tool .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.avd-tool .hint { color: var(--muted); font-size: 0.82rem; margin: 6px 0 0; }
.avd-tool .pos { color: var(--pos); }
.avd-tool .neg { color: var(--neg); }

.avd-tool { min-width: 0; }
.avd-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.avd-results { display: grid; gap: 20px; min-width: 0; }
@media (max-width: 860px) { .avd-grid { grid-template-columns: minmax(0, 1fr); } }

.avd-field + .avd-field { margin-top: 18px; }
.avd-field label { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.92rem; }
.avd-field output { font-variant-numeric: tabular-nums; font-weight: 650; }
.avd-field input[type=range] { width: 100%; margin: 8px 0 0; }
#ctr { accent-color: var(--ctr); }
#avd { accent-color: var(--avd); }
#sensitivity { accent-color: #9aa1ad; }

.avd-reset {
  margin-top: 18px; background: #222733; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 0.85rem; cursor: pointer;
}
.avd-reset:hover { border-color: #3d4452; }

.avd-total { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.avd-total__value { font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.avd-total__change { font-size: 0.95rem; font-variant-numeric: tabular-nums; }

.avd-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.avd-stat { background: #1e222b; border-radius: 8px; padding: 10px; }
.avd-stat .k { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.avd-stat .v { font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.avd-bars { display: grid; gap: 8px; }
.avd-bar-row { display: grid; grid-template-columns: 96px 1fr 72px; align-items: center; gap: 10px; font-size: 0.9rem; }
.avd-bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.avd-track { background: #22262f; border-radius: 4px; height: 18px; }
.avd-bar { height: 18px; border-radius: 4px; width: 0; transition: width 0.15s ease-out; }
.avd-bar--ctr { background: var(--ctr); }
.avd-bar--avd { background: var(--avd); }
.avd-verdict { margin: 14px 0 0; font-size: 0.95rem; color: #d6dae2; }

#scatter { width: 100%; display: block; margin-top: 12px; }

.avd-note { color: var(--muted); font-size: 0.85rem; margin: 18px 0 0; }
.avd-model { margin-top: 14px; color: #c9cdd6; font-size: 0.92rem; line-height: 1.6; }
.avd-model summary { cursor: pointer; color: var(--text); font-weight: 600; }
.avd-model p { margin: 10px 0 0; }

@media (max-width: 600px) {
  .avd-tool { padding: 12px; border-radius: 12px; }
  .avd-tool .card { padding: 14px; }
  .avd-bar-row { grid-template-columns: 80px 1fr 64px; }
}
