:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.06);
  --panel2: rgba(255, 255, 255, 0.10);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.65);
  --accent: #6ee7ff;
  --danger: #ff6b6b;
}

html, body { height: 100%; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, rgba(110, 231, 255, 0.20), transparent 45%),
              radial-gradient(900px 700px at 80% 20%, rgba(167, 139, 250, 0.18), transparent 50%),
              var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Babylon.js canvas is now inside the render card */
#renderCanvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

.ui {
  position: relative;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 18px 40px;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}
.topbar { display:flex; align-items:stretch; justify-content:space-between; flex-wrap: wrap; gap: 14px; }
.brand { font-weight: 800; letter-spacing: .3px; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; }

.link { color: var(--accent); text-decoration: none; }

.stack {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 14px;
  min-height: 0;
}

.logCard,
.renderCard {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.micPanel {
  width: 380px;
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 12px;
  backdrop-filter: blur(10px);
}

@media (max-width: 700px) {
  .micPanel { width: 100%; }
}

.micTop {
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.micTitle { font-size: 13px; color: var(--muted); font-weight: 700; }
.micBtns { display:flex; gap: 8px; align-items:center; }
.micMeta { display:flex; justify-content: space-between; gap: 10px; margin-top: 8px; }

.grid { display:grid; grid-template-columns: 340px 1fr; gap: 14px; }
.card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(10px);
}

.card h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }

.row { display:flex; gap: 10px; align-items: center; }
.row + .row { margin-top: 10px; }

label { font-size: 13px; color: var(--muted); display:block; margin-bottom: 6px; }
input[type="range"], select, input[type="number"], input[type="text"] { width: 100%; }
select, input[type="number"], input[type="text"] {
  background: var(--panel2);
  border: 1px solid rgba(255,255,255,.14);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
}

.btn {
  background: rgba(110, 231, 255, 0.18);
  border: 1px solid rgba(110, 231, 255, 0.35);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 650;
}

.btn.primary { background: rgba(110,231,255,0.18); border-color: rgba(110,231,255,.35); }

.askBox {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 360px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 12px;
  backdrop-filter: blur(10px);
}

.askInput {
  flex: 1;
  background: var(--panel2);
  border: 1px solid rgba(255,255,255,.14);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

.cornerBrand {
  position: fixed;
  right: 14px;
  bottom: 12px;
  z-index: 2;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2px;
  user-select: none;
}

.micPanel .btn {
  padding: 8px 10px;
  border-radius: 11px;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.danger { background: rgba(255,107,107,.12); border-color: rgba(255,107,107,.35); }

.meter {
  height: 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  overflow: hidden;
}
.meter > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(110,231,255,0.9), rgba(167,139,250,0.9));
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.log {
  height: 560px;
  overflow: auto;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0,0,0,.20);
  border: 1px solid rgba(255,255,255,.10);
}

.logSmall {
  height: 100%;
  flex: 1;
  min-height: 0;
}

.renderBox {
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.10);
}

.renderOverlay {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.renderOverlay .btn { pointer-events: auto; padding: 8px 10px; border-radius: 11px; }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.tabBtn {
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.tabBtn.active {
  border-color: rgba(110,231,255,.40);
  background: rgba(110,231,255,.14);
}

@media (max-width: 700px) {
  /* 小屏上避免一半高度过小，允许自然滚动 */
  body { overflow: auto; }
  .wrap { height: auto; display: block; }
  .topbar { margin-bottom: 14px; }
  .stack { display: flex; flex-direction: column; }
  .logSmall { height: 220px; }
  .renderBox { height: 56vh; min-height: 360px; }
}
.bubble { padding: 10px 12px; border-radius: 12px; margin: 10px 0; border: 1px solid rgba(255,255,255,.10); }
.bubble.user { background: rgba(110,231,255,.08); }
.bubble.ai { background: rgba(167,139,250,.08); }
.bubble .who { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.bubble .txt { white-space: pre-wrap; line-height: 1.45; }

.err { color: var(--danger); font-size: 13px; }

@media (max-width: 920px) {
  .grid { grid-template-columns: 1fr; }
}
