:root {
  --bg0: #f4f7fb;
  --bg1: #ffffff;
  --ink: #172033;
  --muted: #4f5d78;
  --line: #d5dceb;
  --accent: #1759ff;
  --card: #f9fbff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #eaf1ff 0%, var(--bg0) 45%, #edf2ff 100%);
}

#app {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 400px;
  gap: 14px;
  height: calc(100dvh - 48px);
  padding: 14px;
}

#scene-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #fcfdff 0%, #f4f8ff 100%);
  min-height: 300px;
  position: relative;
  min-width: 0;
}

#panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  min-width: 0;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

h1 { margin: 0; font-size: 20px; }
h2 { margin: 0 0 6px; font-size: 14px; color: var(--muted); }

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.85; }
button:last-of-type:not(.btn-analyze) { background: #3d4b68; }
.btn-analyze { background: #6b5ce7; }

.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 10px;
}

.card-eigen {
  border-color: #c8d4f5;
  background: linear-gradient(135deg, #f4f7ff, #eef3ff);
}

pre {
  margin: 0;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  line-height: 1.4;
  color: var(--muted);
  font-size: 12px;
}

/* Colored vector names in panel A */
.vec-u { color: #d94b4b; font-weight: bold; }
.vec-v { color: #2f9a58; font-weight: bold; }
.vec-w { color: #2a67d6; font-weight: bold; }
.volume { color: #7b6ec4; font-weight: 600; }

.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

label { font-size: 12px; min-width: 48px; }

select {
  flex: 1;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 6px;
}

@media (max-width: 1024px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(340px, 54vh) auto;
    height: auto;
    min-height: 100vh;
  }
  #panel { max-height: none; }
}

.course-nav { height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 20px; font-size: 13px; background: #fff; border-bottom: 1px solid var(--line); }
.course-nav a { color: #087f83; text-decoration: none; font-weight: 600; }
.course-nav a:hover { text-decoration: underline; }
#scene-wrap canvas { display: block; touch-action: none; }
#scene-status { padding: 24px; }
.presets .controls { margin-top: 10px; }
.presets button { background: #087f83; }
button, select { min-height: 40px; }
select { min-width: 0; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid #0c888e; outline-offset: 3px; }
@media (max-width: 600px) {
  #app { padding: 8px; gap: 8px; grid-template-columns: minmax(0, 1fr); grid-template-rows: 44dvh auto; }
  #panel { padding: 12px; }
  .course-nav { padding: 0 12px; gap: 8px; font-size: 12px; }
}
