* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #000; overflow: hidden; }
#glCanvas { display: block; width: 100vw; height: 100vh; }

/* ——— Panel shell — Glassmorphism ——— */
#panel {
  position: fixed; top: 16px; right: 16px; width: 276px;
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  font-family: system-ui, -apple-system, sans-serif; font-size: 13px;
  user-select: none; z-index: 10;
  transition: opacity 0.6s ease;
  color: rgba(0, 0, 0, 0.78);
}
#panel.idle { opacity: 0.12; }

/* ——— Header ——— */
#panelHeader {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px 8px; cursor: pointer;
}
#panelHeader h3 {
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
  font-size: 18px; font-weight: 400; color: rgba(0,0,0,0.82); letter-spacing: 0.02em;
}
#collapseBtn {
  background: rgba(0,0,0,0.06); border: none; color: rgba(0,0,0,0.45);
  font-size: 16px; cursor: pointer; line-height: 1; padding: 3px 7px;
  border-radius: 8px; transition: background .15s;
}
#collapseBtn:hover { background: rgba(0,0,0,0.1); }


/* ——— Panel body + scrolling ——— */
#panelBody {
  padding: 6px 14px 4px;
  max-height: 72vh; overflow-y: auto; overscroll-behavior: contain;
}
#panelBody::-webkit-scrollbar { width: 3px; }
#panelBody::-webkit-scrollbar-track { background: transparent; }
#panelBody::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }


/* ——— Compact control row ——— */
.crow {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.cicon-wrap {
  flex-shrink: 0; width: 24px; height: 24px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: help; transition: background 0.2s;
}
.cicon-wrap:hover { background: rgba(255, 255, 255, 0.7); }
.cicon {
  width: 15px; height: 15px;
  color: rgba(0,0,0,0.45); stroke-width: 1.8;
}
.cicon svg { width: 15px; height: 15px; }

.cval {
  font-size: 11px; color: rgba(0,0,0,0.42);
  min-width: 32px; text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: monospace;
}

.clabel {
  flex-shrink: 0; width: 66px;
  font-size: 11px; line-height: 1.25;
  color: rgba(0,0,0,0.55);
}
.clabel .zh {
  display: block;
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
  font-size: 12px;
}
.clabel .en {
  display: block;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.08em; color: rgba(0,0,0,0.32);
}

/* ——— Sliders — pastel pink thumb ——— */
input[type=range] {
  flex: 1; height: 3px; -webkit-appearance: none; appearance: none;
  background: rgba(0,0,0,0.1); border-radius: 2px; outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid rgba(255,255,255,0.9);
  box-shadow: 0 1px 5px rgba(0,0,0,0.22), 0 0 0 1px rgba(0,0,0,0.06);
  cursor: pointer; transition: transform .1s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* ——— Section label (used in AI tab) ——— */
.section-label {
  font-size: 12px; color: rgba(0,0,0,0.45); margin-bottom: 8px; margin-top: 2px;
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
}
.section-label .en-sub {
  display: block; font-family: system-ui, -apple-system, sans-serif;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(0,0,0,0.28); margin-top: 1px;
}

/* Labels rendered by i18n for remaining data-i18n elements */
.zh {
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
  display: block; font-size: 13px; line-height: 1.2;
}
.en-sub { display: block; font-size: 10px; color: rgba(0,0,0,0.36); margin-top: 2px; }

/* ——— Separator ——— */
.sep { height: 1px; background: rgba(255,255,255,0.5); margin: 8px 0 10px; }

/* ——— Toggle switch ——— */
.toggle-row {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.toggle-name {
  display: flex; align-items: center; gap: 6px;
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
  font-size: 13px; color: rgba(0,0,0,0.72); line-height: 1.2;
}
.toggle-icon {
  width: 14px; height: 14px; flex-shrink: 0;
  color: rgba(0,0,0,0.32); stroke-width: 1.5;
  display: flex; align-items: center;
}
.toggle-icon svg { width: 14px; height: 14px; }
.switch { position: relative; display: inline-block; width: 34px; height: 18px; }
.switch input { display: none; }
.slider-sw {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.12); border-radius: 18px; transition: .2s;
  border: 1px solid rgba(0,0,0,0.1);
}
.slider-sw:before {
  position: absolute; content: ""; height: 12px; width: 12px;
  left: 2px; bottom: 2px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: .2s;
}
.switch input:checked + .slider-sw { background: #FFB7C5; border-color: #ff8fab; }
.switch input:checked + .slider-sw:before { transform: translateX(16px); }

/* ——— Pen controls ——— */
#clearPenBtn {
  width: 100%; margin-bottom: 8px; padding: 7px 0;
  background: rgba(255,255,255,0.5); border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px; color: rgba(0,0,0,0.6); font-size: 12px; cursor: pointer;
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
  transition: background .2s;
}
#clearPenBtn:hover { background: rgba(255,255,255,0.75); }
.btn-en { font-family: system-ui, -apple-system, sans-serif; font-size: 10px; opacity: 0.6; margin-left: 4px; }

/* ——— AI Generator ——— */
#sceneInput {
  width: 100%; padding: 8px 10px; margin-top: 2px;
  background: rgba(255,255,255,0.45); border: 1px solid rgba(255,255,255,0.6);
  border-radius: 10px; color: rgba(0,0,0,0.8); font-size: 12px;
  font-family: inherit; resize: vertical; min-height: 58px; outline: none;
  line-height: 1.5; transition: border-color .2s;
}
#sceneInput::placeholder { color: rgba(0,0,0,0.3); }
#sceneInput:focus { border-color: rgba(255,183,197,0.8); background: rgba(255,255,255,0.6); }

.gen-row { display: flex; gap: 7px; margin-top: 7px; }

#modelSelect {
  flex: 0 0 auto; padding: 0 8px; height: 30px;
  background: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.6);
  border-radius: 10px; color: rgba(0,0,0,0.65); font-size: 11px; cursor: pointer; outline: none;
}
#modelSelect option { background: #fff; }

#genBtn {
  flex: 1; height: 30px; padding: 0 10px;
  background: rgba(255,183,197,0.35); border: 1px solid rgba(255,183,197,0.6);
  border-radius: 10px; color: rgba(0,0,0,0.72); font-size: 12px; font-weight: 400;
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
  cursor: pointer; transition: background .2s; display: flex;
  align-items: center; justify-content: center; gap: 4px;
}
#genBtn:hover:not(:disabled) { background: rgba(255,183,197,0.55); }
#genBtn:disabled { opacity: 0.5; cursor: not-allowed; }

#genStatus {
  font-size: 11px; color: rgba(0,0,0,0.4); margin-top: 6px;
  min-height: 14px; text-align: center;
}
#genStatus.error { color: rgba(200,50,40,0.8); }

.spinner {
  width: 11px; height: 11px; border: 2px solid rgba(0,0,0,0.1);
  border-top-color: rgba(0,0,0,0.45); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

#genThumb {
  width: 100%; height: 56px; object-fit: cover; border-radius: 8px;
  margin-top: 7px; display: none; border: 1px solid rgba(255,255,255,0.6);
}

#muteBtn {
  width: 100%; margin-bottom: 10px; padding: 7px 0;
  background: rgba(255,255,255,0.45); border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px; color: rgba(0,0,0,0.6); font-size: 12px; cursor: pointer;
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
  transition: background .2s;
}
#muteBtn:hover { background: rgba(255,255,255,0.7); }

/* ——— Panel footer — upload + export ——— */
#panelFooter {
  display: flex; gap: 8px; padding: 8px 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.4); margin-top: 4px;
}
.footer-btn {
  flex: 1; padding: 7px 4px; border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px; background: rgba(255,255,255,0.45);
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', cursive;
  font-size: 12px; cursor: pointer; text-align: center;
  color: rgba(0,0,0,0.62); transition: background .2s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.footer-btn:hover { background: rgba(255,255,255,0.7); }
.footer-icon {
  width: 13px; height: 13px; flex-shrink: 0;
  color: rgba(0,0,0,0.4); stroke-width: 1.5;
  display: flex; align-items: center;
}
.footer-icon svg { width: 13px; height: 13px; }
#bgFile { display: none; }

/* ——— Export Modal ——— */
#exportOverlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 6, 18, 0.82);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}
#exportOverlay.open { display: flex; }

#exportBox {
  width: 340px; 
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6); 
  border-radius: 28px;
  padding: 26px 24px; color: rgba(0, 0, 0, 0.75);
  font-family: system-ui, -apple-system, sans-serif;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
}
#exportBox h2 { 
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: 20px; font-weight: 400; color: rgba(0,0,0,0.85); margin-bottom: 6px; 
}
#exportBox .sub { font-size: 12px; color: rgba(0,0,0,0.4); margin-bottom: 20px; }

.fmt-cards { display: flex; gap: 10px; margin-bottom: 22px; }
.fmt-card {
  flex: 1; padding: 14px 10px; border-radius: 18px; cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.4); text-align: center;
  transition: all .2s;
}
.fmt-card:hover { border-color: rgba(0,0,0,0.15); background: rgba(255,255,255,0.7); }
.fmt-card.selected { 
  border-color: #FFB7C5; background: rgba(255, 255, 255, 0.85); 
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.fmt-icon { font-size: 28px; margin-bottom: 8px; line-height: 1; opacity: 0.85; }
.fmt-name { 
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: 14px; color: rgba(0,0,0,0.75); margin-bottom: 3px; 
}
.fmt-dims { font-size: 11px; color: rgba(0,0,0,0.35); }

.export-actions { display: flex; gap: 9px; }
.btn-primary {
  flex: 1; padding: 12px 0; border-radius: 14px; border: none;
  background: #FFB7C5; color: #fff; font-size: 13px;
  font-family: 'ZCOOL KuaiLe', cursive;
  font-weight: 400; cursor: pointer; transition: background .2s;
  box-shadow: 0 4px 10px rgba(255, 183, 197, 0.4);
}
.btn-primary:hover:not(:disabled) { background: #ff8fab; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost {
  padding: 10px 16px; border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.4); color: rgba(0,0,0,0.5); font-size: 13px;
  font-family: 'ZCOOL KuaiLe', cursive;
  cursor: pointer; transition: all .2s;
}
.btn-ghost:hover { border-color: rgba(0,0,0,0.2); background: rgba(255,255,255,0.7); }

/* recording state */
#recProgress { display: none; margin-bottom: 20px; }
.rec-indicator { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #ff4040;
  animation: recPulse 1s ease-in-out infinite;
}
@keyframes recPulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.8)} }
.rec-label { font-size: 13px; color: #ffa0a0; font-weight: 600; letter-spacing: .04em; }
.rec-time  { margin-left: auto; font-size: 22px; font-weight: 700; color: #fff;
             font-variant-numeric: tabular-nums; }
.progress-track {
  height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg,#FFB7C5,#a060ff);
  border-radius: 2px; transition: width .5s linear;
}
.rec-note { font-size: 11px; color: rgba(150,190,255,0.45); margin-top: 10px; }

/* done state */
#recDone { display: none; text-align: center; padding: 8px 0 16px; }
#recDone .done-icon { font-size: 40px; margin-bottom: 10px; }
#recDone p { font-size: 13px; color: rgba(150,200,255,0.8); margin-bottom: 18px; line-height: 1.5; }

/* ——— Live Recording UI ——— */
#liveRecUI {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: 12px;
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(10px);
  padding: 8px 16px; border-radius: 40px; border: 1px solid rgba(255, 64, 64, 0.3);
  z-index: 200; pointer-events: auto;
}
.live-rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #ff4040;
  animation: recPulse 1s ease-in-out infinite;
}
.live-rec-time {
  color: #fff; font-family: monospace; font-size: 16px; font-weight: bold;
}
#stopRecBtn {
  background: #ff4040; color: #fff; border: none; padding: 4px 12px;
  border-radius: 20px; font-size: 12px; cursor: pointer; font-weight: bold;
}

/* ——— Safe Area Overlay ——— */
#safeArea {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  display: none; border: 2px dashed rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.4);
}
#safeArea.tiktok {
  aspect-ratio: 9/16; height: 100vh; width: auto; left: 50%; transform: translateX(-50%);
}
#safeArea.wide {
  aspect-ratio: 16/9; width: 100vw; height: auto; top: 50%; transform: translateY(-50%);
}
