/* ============================================================
   分形艺术馆 —— 玻璃拟态样式
   零依赖：无外部字体 / 图片 / CDN
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #e7ecff;
  background: radial-gradient(circle at 50% 30%, #171a3a, #0b0e20);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------- 玻璃拟态 ---------------- */
.glass {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ---------------- 顶部栏 ---------------- */
.topbar {
  flex: none;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(11, 14, 32, .55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
}

.logo {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 2px;
  white-space: nowrap;
  background: linear-gradient(90deg, #22d3ee, #7c5cff 55%, #ff5ca8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tabs {
  display: flex;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  color: #b9c2e8;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.tab:hover { color: #fff; border-color: rgba(124, 92, 255, .7); background: rgba(124, 92, 255, .18); }
.tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, rgba(124, 92, 255, .9), rgba(34, 211, 238, .75));
  box-shadow: 0 4px 16px rgba(124, 92, 255, .35);
}

.top-actions { display: flex; gap: 10px; flex: none; }

/* ---------------- 按钮 ---------------- */
.btn-primary, .btn-ghost {
  font-family: inherit;
  font-size: 14px;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
  text-align: center;
  white-space: nowrap;
}
.btn-primary {
  flex: 1;
  color: #fff;
  border: 1px solid transparent;
  background: linear-gradient(120deg, #7c5cff, #22d3ee);
  box-shadow: 0 6px 18px rgba(124, 92, 255, .35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(34, 211, 238, .35); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  flex: 1;
  color: #d6ddf8;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .05);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.btn-sm { flex: none; padding: 8px 14px; font-size: 13px; border-radius: 10px; }

/* ---------------- 主体布局 ---------------- */
.app { flex: 1; position: relative; min-height: 0; }

.hall {
  position: absolute;
  inset: 0;
  display: none;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  padding: 16px;
}
.hall.active { display: grid; }

.panel {
  padding: 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  color: #fff;
}

.ctl-group { margin-bottom: 18px; }
.ctl-group:last-child { margin-bottom: 4px; }

.ctl-label { font-size: 13px; color: #aab4dc; }

.ctl-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.ctl-value { font-size: 13px; color: #8f9ac4; }
.ctl-value b { font-size: 17px; color: #22d3ee; margin-right: 2px; font-variant-numeric: tabular-nums; }
.ctl-value i { font-style: normal; font-size: 12px; }

.scale-hint {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #6e78a4;
  margin-top: 5px;
}

.btn-row { display: flex; gap: 10px; }

.seg-row { display: flex; gap: 8px; margin-top: 8px; }
.seg {
  flex: 1;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .04);
  color: #b9c2e8;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all .18s ease;
}
.seg:hover { color: #fff; }
.seg.active {
  color: #fff;
  border-color: rgba(34, 211, 238, .7);
  background: rgba(34, 211, 238, .16);
  box-shadow: inset 0 0 12px rgba(34, 211, 238, .18);
}

.group-title {
  font-size: 12px;
  color: #7e88b4;
  font-weight: 600;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.read-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, .07);
  font-size: 13px;
}
.read-row:last-child { border-bottom: none; }
.rd-k { color: #99a4cf; flex: none; }
.rd-v { color: #eaf0ff; text-align: right; font-variant-numeric: tabular-nums; }
.rd-small { font-size: 12px; color: #b9c2e8; }

/* ---------------- 滑块 ---------------- */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #7c5cff, #ff5ca8);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #7c5cff;
  box-shadow: 0 2px 10px rgba(124, 92, 255, .7);
  cursor: grab;
}
.slider::-webkit-slider-thumb:active { cursor: grabbing; }
.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #7c5cff;
  box-shadow: 0 2px 10px rgba(124, 92, 255, .7);
  cursor: grab;
}

/* ---------------- 开关 ---------------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  cursor: pointer;
}
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .18);
  transition: background .2s ease;
}
.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #cfd6f5;
  transition: all .2s ease;
}
.switch input:checked + .track { background: linear-gradient(90deg, #7c5cff, #22d3ee); border-color: transparent; }
.switch input:checked + .track .knob { left: 23px; background: #fff; }

/* ---------------- 舞台与画布 ---------------- */
.stage {
  position: relative;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, .1);
  overflow: hidden;
  min-height: 0;
  background: rgba(8, 10, 26, .4);
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.fact-bar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: #cdd6f6;
  pointer-events: none;
}
.fact-bar b { color: #22d3ee; font-weight: 600; font-variant-numeric: tabular-nums; }
.fact-bar .fact-title { color: #ffb347; font-weight: 600; margin-right: 6px; }

/* ---------------- 底部提示 ---------------- */
.tips {
  flex: none;
  padding: 9px 18px;
  font-size: 12px;
  color: #7882ad;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, .06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- 生成中提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 26px;
  border-radius: 14px;
  font-size: 14px;
  color: #fff;
  letter-spacing: 1px;
  background: rgba(23, 26, 58, .85);
  border: 1px solid rgba(124, 92, 255, .55);
  box-shadow: 0 8px 30px rgba(124, 92, 255, .35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
}
.toast[hidden] { display: none; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .logo { font-size: 17px; }
  .tabs { order: 3; width: 100%; }
  .top-actions { margin-left: auto; }

  .hall {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 10px;
    gap: 10px;
  }
  .panel {
    order: 2;
    max-height: 38vh;
    padding: 14px;
  }
  .stage { order: 1; min-height: 260px; }
  .ctl-group { margin-bottom: 12px; }
  .fact-bar { font-size: 12px; padding: 10px 12px; }
}
