:root {
  --tz-bg: #f4f1fa;
  --tz-surface: #ffffff;
  --tz-ink: #3c3449;
  --tz-muted: #6b5f7d;
  --tz-accent: #777dcc;
  --tz-accent-soft: #eceafb;
  --tz-border: #e4ddf0;
  --tz-radius: 16px;
}

* { box-sizing: border-box; }

.tz-body {
  margin: 0;
  background: var(--tz-bg);
  color: var(--tz-ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.tz-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--tz-border);
}

.tz-header-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--tz-ink);
}

.tz-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--tz-border);
  border-radius: 999px;
  background: var(--tz-surface);
  color: var(--tz-accent);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.tz-back:hover { background: var(--tz-accent-soft); border-color: var(--tz-accent); }
.tz-back:focus-visible { outline: 2px solid var(--tz-accent); outline-offset: 2px; }

.tz-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.tz-intro { margin-bottom: 22px; }

.tz-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--tz-accent);
  font-weight: 700;
}

.tz-title {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
  color: var(--tz-ink);
}

.tz-brief {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--tz-ink);
}

.tz-disclaimer {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--tz-accent);
  background: var(--tz-accent-soft);
  border-radius: 0 12px 12px 0;
  font-size: 13px;
  color: var(--tz-muted);
}

.tz-controls {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 14px;
  align-items: end;
  padding: 16px;
  background: var(--tz-surface);
  border: 1px solid var(--tz-border);
  border-radius: var(--tz-radius);
  margin-bottom: 20px;
}

.tz-subjects {
  display: inline-flex;
  gap: 8px;
  padding: 4px;
  background: var(--tz-bg);
  border: 1px solid var(--tz-border);
  border-radius: 999px;
}

.tz-subject {
  min-height: 38px;
  padding: 6px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--tz-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tz-subject.is-active {
  background: var(--tz-accent);
  color: #fff;
}

.tz-subject:focus-visible { outline: 2px solid var(--tz-accent); outline-offset: 2px; }

.tz-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tz-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--tz-muted);
}

.tz-field select {
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--tz-border);
  border-radius: 10px;
  background: var(--tz-surface);
  color: var(--tz-ink);
  font: inherit;
  max-width: 100%;
}

.tz-field select:focus-visible { outline: 2px solid var(--tz-accent); outline-offset: 1px; }

.tz-panel {
  padding: 20px;
  background: var(--tz-surface);
  border: 1px solid var(--tz-border);
  border-radius: var(--tz-radius);
  min-width: 0;
}

.tz-panel-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.tz-subject-badge {
  flex: 0 0 auto;
  margin-top: 3px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--tz-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.tz-panel-heading { min-width: 0; }

.tz-topic-title {
  margin: 0;
  font-size: 21px;
  line-height: 1.3;
  color: var(--tz-ink);
  overflow-wrap: anywhere;
}

.tz-topic-parent {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--tz-muted);
  overflow-wrap: anywhere;
}

.tz-topic-description {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--tz-muted);
  overflow-wrap: anywhere;
}

.tz-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.tz-open3d {
  min-height: 42px;
  padding: 8px 18px;
  border: 1px solid var(--tz-accent);
  border-radius: 999px;
  background: var(--tz-accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tz-open3d:hover:not(:disabled) { background: #6a70c2; }
.tz-open3d:focus-visible { outline: 2px solid var(--tz-accent); outline-offset: 2px; }
.tz-open3d:disabled {
  background: #eceaf0;
  border-color: #ddd5e6;
  color: #9a8fa8;
  cursor: not-allowed;
}

.tz-open3d-note {
  font-size: 12px;
  color: var(--tz-muted);
}

.tz-diagram { min-width: 0; }

/* Diagram cards (from diagram-2d.js) already scale via student-view.css; keep them tight. */
.tz-diagram .diagram-card { margin-top: 4px; }

@media (max-width: 640px) {
  .tz-header { padding: 10px 12px; }
  .tz-main { padding: 20px 12px 56px; }
  .tz-title { font-size: 24px; }
  .tz-controls { grid-template-columns: 1fr; gap: 12px; }
  .tz-subjects { width: 100%; }
  .tz-subject { flex: 1 1 0; text-align: center; }
  .tz-panel { padding: 14px; }
}

@media (max-width: 430px) {
  .tz-back { font-size: 13px; padding: 7px 12px; min-height: 38px; }
  .tz-header-title { font-size: 14px; }
  .tz-topic-title { font-size: 19px; }
}
