:root {
  --text-primary: #1e293b;
  --text-secondary: #465165;
  --muted: #64748b;
  --border-color: #e2e8f0;
  --primary-color: #2563eb;
  --plot-height: clamp(280px, 54vw, 460px);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: #fff; color: var(--text-secondary);
  font-family: "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased;
}
body.difficulty-demo { --plot-height: clamp(280px, 54vw, 460px); }
body.search-demo { --plot-height: clamp(360px, 54vw, 460px); }
.wrap { width: 100%; max-width: 850px; margin: 0 auto; padding: 0; }
.stage { position: relative; }
#plot, #plot2d { width: 100%; height: var(--plot-height); }
#plot2d {
  position: absolute; left: 0; top: 0; opacity: 0;
  visibility: hidden; pointer-events: none; z-index: 1; background: #fff;
}
.controls {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px; margin: 14px 0 12px;
}
.controls button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--border-color); border-radius: 10px;
  background: #f8fafc; color: var(--text-primary);
  font: inherit; font-size: .9rem; font-weight: 600;
  line-height: 1.4; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.controls button:hover:not(:disabled) { background: #eef2f8; border-color: #b9c7db; }
.controls button:disabled { color: #94a3b8; cursor: default; }
.controls #play { background: var(--text-primary); color: white; border-color: var(--text-primary); }
.controls #play:hover { background: var(--primary-color); border-color: var(--primary-color); }

.animation-title { margin: 0 0 14px; color: var(--text-primary); font-size: 1.1rem; font-weight: 650; }
.caption { font-size: .95rem; line-height: 1.7; color: var(--text-secondary); }
.caption b { display: block; margin-bottom: 6px; color: var(--text-primary); font-size: 1rem; font-weight: 650; }
.hint { color: var(--muted); font-size: .85rem; line-height: 1.6; }
.hint { margin: 0 0 4px; }
.difficulty-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 12px 0 0; font-size: .8rem; line-height: 1.6; }

.difficulty-key span { white-space: nowrap; }
.difficulty-key i { display: inline-block; width: 14px; height: 3px; margin-right: 5px; vertical-align: middle; }
.dots { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.dots span { width: 9px; height: 9px; border-radius: 50%; background: #d5deeb; cursor: pointer; }
.dots span.on { background: var(--primary-color); }
.cbar { position: absolute; right: 8px; top: 40px; width: 64px; font-size: 12px; z-index: 2; pointer-events: none; }
.cbar .bars { position: relative; width: 14px; height: clamp(170px, 26vw, 220px); }
.cbar .bar { position: absolute; inset: 0; border: 1px solid #888; }
.cbar .ticks { position: absolute; left: 20px; top: 0; height: clamp(170px, 26vw, 220px); }
.cbar .ticks span { position: absolute; transform: translateY(-50%); white-space: nowrap; }
.cbar .label { writing-mode: vertical-rl; transform: rotate(180deg); position: absolute; left: 48px; top: 0; width: 16px; height: 100%; white-space: nowrap; text-align: center; font-size: 11px; line-height: 1; }
.inflegend { position: absolute; right: 0; top: 285px; font-size: 12px; z-index: 2; opacity: 0; pointer-events: none; background: rgba(255,255,255,.9); padding: 2px 4px; }
.inflegend svg { vertical-align: middle; margin-right: 4px; }
button:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 3px; }
@media (max-width: 600px) {
  .controls { gap: 6px; margin: 12px 0 8px; }
  .controls button { padding: 8px 12px; }
  .dots { gap: 5px; }
  .inflegend { top: 235px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { .controls button { transition: none; } }
