:root {
  --bg: rgb(18, 22, 27);
  --render: rgb(22, 26, 32);
  --panel: rgb(27, 32, 40);
  --panel-border: rgb(30, 34, 40);
  --topbar: rgb(32, 38, 46);
  --btn: rgb(70, 78, 90);
  --btn-primary: rgb(96, 128, 255);
  --btn-active: rgb(65, 180, 130);
  --text: rgb(230, 234, 238);
  --text-strong: rgb(245, 248, 252);
  --muted: rgb(80, 88, 100);
  --track: rgb(200, 210, 225);
  --input-bg: rgb(40, 46, 56);

  /* drawing colors */
  --trail: rgb(96, 128, 255);
  --rod: rgb(94, 105, 120);
  --origin-dot: rgb(245, 248, 252);
  --bob1: rgb(255, 152, 99);
  --bob2: rgb(86, 160, 255);
  --arrow1: rgb(255, 180, 120);
  --arrow2: rgb(140, 200, 255);
}

html[data-theme="light"] {
  --bg: rgb(245, 247, 250);
  --render: rgb(250, 252, 255);
  --panel: rgb(238, 242, 247);
  --panel-border: rgb(210, 218, 228);
  --topbar: rgb(225, 232, 241);
  --btn: rgb(210, 218, 228);
  --btn-primary: rgb(96, 128, 255);
  --btn-active: rgb(65, 180, 130);
  --text: rgb(30, 36, 44);
  --text-strong: rgb(18, 22, 27);
  --muted: rgb(150, 160, 172);
  --track: rgb(120, 132, 148);
  --input-bg: rgb(250, 252, 255);

  --trail: rgb(96, 128, 255);
  --rod: rgb(120, 132, 148);
  --origin-dot: rgb(18, 22, 27);
  --bob1: rgb(255, 152, 99);
  --bob2: rgb(86, 160, 255);
  --arrow1: rgb(255, 180, 120);
  --arrow2: rgb(140, 200, 255);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.topbar {
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--topbar);
  border-bottom: 1px solid var(--panel-border);
}

.topbar-title {
  font-size: 18px;
  color: var(--text);
}

.back-link {
  text-decoration: none;
}

.theme-toggle {
  width: 44px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-btn {
  flex: none;
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 10px;
}

.download-btn {
  width: 40px;
  height: 32px;
}

.hidden {
  display: none !important;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.tab-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--btn);
  border: 2px solid var(--panel-border);
  color: var(--text-strong);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--btn-primary);
}

.content {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

.render {
  flex: 1;
  background: var(--render);
  position: relative;
}

.plot {
  display: none;
  flex: 1;
  background: var(--render);
}

.graph-sim-controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: none;
  justify-content: center;
  gap: 8px;
  pointer-events: auto;
}

.graph-sim-controls .btn {
  flex: none;
  height: 42px;
}

.graph-sim-controls .btn.btn-primary {
  min-width: 120px;
}

.app[data-view="graphs"] .graph-sim-controls {
  display: flex;
}

#plotCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.panel {
  width: 340px;
  background: var(--panel);
  border-left: 1px solid var(--panel-border);
  flex: none;
  height: 100%;
}

.app[data-view="graphs"] .panel,
.app[data-view="graphs"] .panel-toggle {
  display: none;
}

.app[data-view="graphs"] .plot {
  display: block;
}

.app[data-view="graphs"] .render {
  flex: none;
  width: 420px;
  border-left: 1px solid var(--panel-border);
}

.panel.collapsed {
  display: none;
}

.panel-inner {
  height: 100%;
  overflow-y: auto;
  padding: 18px 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-icon {
  margin-left: auto;
  width: 36px;
  height: 32px;
  border-radius: 10px;
}

.panel-title {
  font-size: 18px;
}

.options {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}

.options-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.options-title {
  font-size: 15px;
  color: var(--text);
}

.options.collapsed .option-row {
  display: none;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
}

.option-label {
  font-size: 15px;
  color: var(--text);
}

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 28px;
}

.toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 48px;
  height: 28px;
  margin: 0;
  cursor: pointer;
  outline: none;
}

.toggle-ui {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--btn);
  border: 2px solid var(--panel-border);
  pointer-events: none;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--text-strong);
}

.toggle input:checked + .toggle-ui {
  background: var(--btn-active);
}

.toggle input:checked + .toggle-ui::after {
  left: 22px;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn {
  flex: 1;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--btn);
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text-strong);
  font-size: 15px;
  cursor: pointer;
}

.btn.btn-icon {
  flex: none;
  width: 44px;
  padding: 0;
}

.btn.btn-primary {
  background: var(--btn-primary);
}

.btn.active {
  background: var(--btn-active);
}

.icon {
  font-size: 18px;
  line-height: 1;
}

.sliders {
  margin-top: 18px;
}

.slider {
  margin-bottom: 18px;
}

.slider-label {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.slider-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

input[type="range"] {
  flex: 1;
}

input[type="number"] {
  width: 132px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid rgb(70, 78, 90);
  background: var(--input-bg);
  color: var(--text-strong);
  padding: 0 8px;
  font-size: 14px;
}

.panel-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 96px;
  border-radius: 12px;
  border: 2px solid var(--panel-border);
  background: var(--btn);
  color: var(--text-strong);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-toggle.collapsed {
  right: 6px;
  background: var(--btn-primary);
}

.panel-toggle.expanded {
  right: calc(340px - 14px);
}

.about {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.about.hidden {
  display: none;
}

.about-box {
  width: min(600px, calc(100% - 80px));
  height: min(600px, calc(100% - 80px));
  background: rgb(32, 38, 46);
  border: 2px solid rgb(70, 78, 90);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}

.about-title {
  font-size: 18px;
  margin-bottom: 14px;
  color: rgb(235, 240, 245);
}

.about-content {
  flex: 1;
  font-size: 15px;
  color: rgb(210, 216, 224);
  line-height: 1.6;
  overflow-y: auto;
}

.about-section {
  margin-bottom: 16px;
}

.about-section h3 {
  font-size: 16px;
  color: rgb(96, 128, 255);
  margin: 0 0 8px 0;
  font-weight: 600;
}

.key {
  display: inline-block;
  background: rgb(70, 78, 90);
  color: rgb(245, 248, 252);
  padding: 0 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  margin-right: 6px;
  min-width: 24px;
  text-align: center;
}

.sub-item {
  margin-left: 24px;
  color: rgb(180, 190, 200);
  font-size: 0.95em;
}

.about-actions {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}
