/* ==========================================================================
   Typeset App · UI 样式
   ========================================================================== */

:root {
  --app-bg: #0b0e14;
  --app-panel: #12161f;
  --app-stage: #1a1f2b;
  --app-ink: #eaf0f6;
  --app-dim: #7d8590;
  --app-mute: #545c66;
  --gold: #ffcc4d;
  --teal: #4ecdc4;
  --coral: #ff6b6b;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--app-bg);
  color: var(--app-ink);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================================
   顶栏
   ========================================================================== */

/* ==========================================================================
   顶栏 · 支持自动隐藏(录屏视图 · 全屏时)
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--app-bg);
  flex-shrink: 0;
  transition: transform 0.3s, opacity 0.3s;
}

/* 顶栏自动隐藏(录屏视图默认隐藏 · 桌面版可以由用户切换) */
.topbar.autohide {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
}

/* 顶栏隐藏时 · 顶部保留一条 hover 敏感区,鼠标滑上去恢复 */
.topbar-hover-zone {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 12px;
  z-index: 9;
  background: transparent;
  display: none;
}
.view-record.autohide-topbar .topbar-hover-zone {
  display: block;
}
.topbar-hover-zone:hover + .topbar,
.view-record.autohide-topbar:not(.topbar-forced) .topbar-hover-zone:hover ~ .topbar {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand-mark {
  color: var(--gold);
  font-size: 1.4rem;
}
.brand-name {
  font-family: "Songti SC", serif;
  font-size: 1.35rem;
  color: var(--app-ink);
  letter-spacing: 0.05em;
}

/* ==========================================================================
   开屏动画 · 1.8 秒后自动淡出
   ========================================================================== */

.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--app-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splashFade 0.4s ease-out 1.6s forwards;
  overflow: hidden;
}
.splash::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(255,204,77,0.08) 0%, transparent 60%);
  pointer-events: none;
}
.splash-inner {
  text-align: center;
  position: relative;
  animation: splashRise 1.2s ease-out;
}
.splash-mark {
  color: var(--gold);
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 24px;
  opacity: 0;
  animation: splashMarkIn 0.6s ease-out 0.1s forwards;
}
.splash-name {
  font-family: "Songti SC", "Source Han Serif SC", serif;
  color: var(--app-ink);
  font-size: 2.2rem;
  letter-spacing: 0.15em;
  display: inline-block;
  opacity: 0;
  animation: splashTextIn 0.8s ease-out 0.4s forwards;
}
.splash-line {
  width: 60px;
  height: 1px;
  background: var(--gold);
  margin: 24px auto 20px;
  opacity: 0;
  animation: splashLineIn 0.6s ease-out 0.8s forwards;
}
.splash-tag {
  color: var(--app-mute);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  opacity: 0;
  animation: splashTextIn 0.6s ease-out 1s forwards;
}

@keyframes splashFade {
  to { opacity: 0; visibility: hidden; }
}
@keyframes splashRise {
  from { transform: translateY(10px); }
  to { transform: translateY(0); }
}
@keyframes splashMarkIn {
  from { opacity: 0; transform: scale(0.6) rotate(-30deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes splashTextIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes splashLineIn {
  from { opacity: 0; width: 0; }
  to { opacity: 0.5; width: 60px; }
}

.splash.done {
  display: none;
}

/* ==========================================================================
   底部 Slogan · 简约单行 · 自动淡入淡出轮播
   ========================================================================== */

.slogan-mini {
  margin: 50px auto 10px;
  padding: 24px 20px 0;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--app-dim);
  font-family: "Songti SC", "Source Han Serif SC", serif;
  font-size: 0.95rem;
  line-height: 1.7;
  letter-spacing: 0.04em;
  min-height: 4em;
}
.slogan-mini-text {
  display: inline-block;
  transition: opacity 0.5s ease;
  color: var(--app-ink);
}
.slogan-mini-text.fade-out { opacity: 0; }
.slogan-mini-text em {
  color: var(--gold);
  font-style: normal;
  background: linear-gradient(180deg, transparent 65%, rgba(255,204,77,0.2) 65%);
  padding: 0 2px;
}
.slogan-mini-sign {
  display: block;
  margin-top: 10px;
  color: var(--app-mute);
  font-family: "Georgia", "Songti SC", serif;
  font-size: 0.78rem;
  font-style: italic;
  letter-spacing: 0.1em;
}
.slogan-mini-sign b {
  color: var(--gold);
  font-weight: 400;
  font-style: normal;
}

@media (max-width: 720px) {
  .slogan-mini { font-size: 0.88rem; padding-top: 20px; margin-top: 30px; }
  .slogan-mini-sign { font-size: 0.72rem; }
  .splash-name { font-size: 1.6rem; }
  .splash-mark { font-size: 3rem; }
}

/* ==========================================================================
   Toast 消息 · 页面内嵌 · 自动淡入淡出
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 90vw;
}

.toast {
  background: rgba(18, 22, 31, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 12px 18px;
  color: var(--app-ink);
  font-size: 0.88rem;
  line-height: 1.5;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  pointer-events: auto;
  min-width: 240px;
  max-width: 480px;
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toast.leaving {
  animation: toastOut 0.3s ease-out forwards;
}
.toast .toast-icon {
  color: var(--gold);
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1.5;
}
.toast .toast-body {
  flex: 1;
}
.toast .toast-title {
  font-weight: 500;
  color: var(--app-ink);
}
.toast .toast-desc {
  color: var(--app-dim);
  font-size: 0.8rem;
  margin-top: 3px;
  line-height: 1.5;
}
.toast.error {
  border-left-color: var(--coral);
}
.toast.error .toast-icon { color: var(--coral); }
.toast.success {
  border-left-color: var(--teal);
}
.toast.success .toast-icon { color: var(--teal); }

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-16px) scale(0.98);
  }
}

.topbar-actions {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  color: var(--app-dim);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.05em;
}
.tab-btn:hover {
  color: var(--app-ink);
  background: rgba(255, 255, 255, 0.03);
}
.tab-btn.active {
  color: var(--gold);
  background: rgba(255, 204, 77, 0.08);
  border-color: rgba(255, 204, 77, 0.3);
}

/* ==========================================================================
   视图切换
   ========================================================================== */

.view {
  flex: 1;
  overflow: hidden;
  display: none;
  position: relative;
}
.view.active {
  display: flex;
  flex-direction: column;
}
.view-input.active, .view-preview.active {
  overflow: auto;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px;
  width: 100%;
}

.view-title {
  font-family: "Songti SC", serif;
  font-size: 2.4rem;
  font-weight: 400;
  margin-bottom: 12px;
  line-height: 1.2;
}
.view-title .accent { color: var(--gold); }
.view-sub {
  color: var(--app-dim);
  margin-bottom: 40px;
}
.view-sub b {
  color: var(--app-ink);
  font-weight: 500;
}

.section-title {
  color: var(--app-mute);
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 12px;
  font-family: "JetBrains Mono", monospace;
}

/* ==========================================================================
   视图 1 · 输入
   ========================================================================== */

.dropzone {
  display: block;
  border: 2px dashed var(--line-strong);
  border-radius: 14px;
  padding: 60px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 40px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--gold);
  background: rgba(255, 204, 77, 0.03);
}
.dropzone-icon {
  font-size: 3rem;
  color: var(--gold);
  margin-bottom: 12px;
}
.dropzone-text {
  font-size: 1.1rem;
  color: var(--app-ink);
  margin-bottom: 6px;
}
.dropzone-text b { color: var(--gold); font-weight: 500; }
.dropzone-text .link { color: var(--teal); text-decoration: underline; }
.dropzone-hint {
  color: var(--app-mute);
  font-size: 0.85rem;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.1em;
}

.paste-area { margin-bottom: 30px; }
.paste-area textarea {
  width: 100%;
  min-height: 140px;
  background: var(--app-panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--app-ink);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  margin-bottom: 10px;
}
.paste-area textarea:focus {
  outline: none;
  border-color: var(--gold);
}

/* ==========================================================================
   通用按钮
   ========================================================================== */

.btn {
  background: transparent;
  color: var(--app-dim);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  color: var(--app-ink);
  border-color: var(--gold);
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--gold);
  color: var(--app-bg);
  border-color: var(--gold);
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255,204,77,0.15);
}
.btn.ghost { border-color: var(--line); }

/* 录制按钮 · 特殊样式 */
.btn.record-btn {
  border-color: var(--coral);
  color: var(--coral);
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}
.btn.record-btn:hover:not(:disabled) {
  background: rgba(255,107,107,0.1);
  color: var(--coral);
  border-color: var(--coral);
}
.btn.record-btn.recording {
  background: var(--coral);
  color: var(--app-bg);
  animation: recPulse 1.4s ease-in-out infinite;
}
.rec-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.btn.record-btn.recording .rec-dot {
  animation: recDotBlink 0.8s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,107,0.5); }
  50% { box-shadow: 0 0 0 8px rgba(255,107,107,0); }
}
@keyframes recDotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ==========================================================================
   视图 2 · 预览
   ========================================================================== */

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--app-panel);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.preview-tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}
.tool-label {
  color: var(--app-dim);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-label input[type="checkbox"] {
  accent-color: var(--gold);
}
.tool-select {
  background: var(--app-bg);
  color: var(--app-ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 10px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.tool-select:focus {
  outline: none;
  border-color: var(--gold);
}
.preview-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.preview-frame-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#previewFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--app-bg);
}

/* ==========================================================================
   视图 3 · 录屏 · 全屏舞台 + 右上角浮动面板
   ========================================================================== */

.view-record.active {
  position: relative;
  overflow: hidden;
}

.record-stage-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
#recordFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--app-bg);
  display: block;
}

/* ==========================================================================
   控制台面板 · 右侧停靠 · 收起时只是一个金色圆点 · 展开显示完整
   ========================================================================== */

/* 完整面板 */
.record-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 20;
  width: 300px;
  background: rgba(18, 22, 31, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  color: var(--app-ink);
  font-size: 0.82rem;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
/* 收起状态 · 完全滑出画外 · 让位给圆点 */
.record-panel.hidden {
  opacity: 0;
  transform: translateX(340px);
  pointer-events: none;
}

.record-panel-title {
  color: var(--gold);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.25em;
  font-size: 0.72rem;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* 面板右上角的关闭小 × */
.record-panel-close {
  background: transparent;
  border: none;
  color: var(--app-mute);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.record-panel-close:hover { color: var(--gold); }

/* 收起后的圆点 · 右上角停靠 · 半透明金色 */
.record-panel-restore {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 15;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0.35;
  box-shadow: 0 0 12px rgba(255,204,77,0.35);
  transition: all 0.2s;
  font-size: 0;
  overflow: hidden;
}
.record-panel-restore:hover,
.record-panel-restore:focus {
  opacity: 0.95;
  width: 18px;
  height: 18px;
  box-shadow: 0 0 20px rgba(255,204,77,0.6);
}
/* 播放/录制中 · 圆点更亮更活跃 · 提示有事在进行 */
.view-record.recording .record-panel-restore,
.record-panel-restore.playing {
  opacity: 0.65;
  animation: dotBreathe 2.2s ease-in-out infinite;
}
@keyframes dotBreathe {
  0%, 100% {
    box-shadow: 0 0 12px rgba(255,204,77,0.4);
    opacity: 0.55;
  }
  50% {
    box-shadow: 0 0 18px rgba(255,204,77,0.75);
    opacity: 0.9;
  }
}

/* 录制中 · 舞台边框微微发红 */
.view-record.recording .record-stage-wrap {
  box-shadow: inset 0 0 0 3px var(--coral);
  animation: stageRecBorder 2s ease-in-out infinite;
}
@keyframes stageRecBorder {
  0%, 100% { box-shadow: inset 0 0 0 3px rgba(255,107,107,0.6); }
  50% { box-shadow: inset 0 0 0 3px rgba(255,107,107,0.3); }
}

.record-row {
  margin-bottom: 12px;
}
.record-row-label {
  display: block;
  color: var(--app-mute);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-family: "JetBrains Mono", monospace;
  margin-bottom: 6px;
}

/* mini tabs · 版式选择 / 模式选择 */
.mini-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--app-bg);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.mini-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--app-dim);
  padding: 6px 8px;
  border-radius: 4px;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.mini-tab:hover { color: var(--app-ink); }
.mini-tab.active {
  background: rgba(255,204,77,0.15);
  color: var(--gold);
}

/* 模式参数 */
.mode-params { margin-bottom: 12px; }
.mode-params.hidden { display: none; }

.ctrl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 10px;
  min-height: 26px;
}
.ctrl-row label {
  flex: 1;
  color: var(--app-dim);
  font-size: 0.75rem;
  line-height: 1.4;
}
.ctrl-row input[type="number"] {
  width: 55px;
  background: var(--app-bg);
  color: var(--app-ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 0.78rem;
  text-align: right;
}
.ctrl-row input[type="range"] {
  flex: 2;
  accent-color: var(--gold);
  height: 4px;
}
.ctrl-row input:focus { outline: none; border-color: var(--gold); }
.ctrl-row .val {
  color: var(--gold);
}

.ctrl-btns {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.ctrl-btns .btn {
  flex: 1;
  padding: 7px 10px;
  font-size: 0.75rem;
}

.ctrl-progress {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--app-mute);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
}
.progress-bar {
  flex: 1;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gold);
  transition: width 0.2s;
}
.pct { color: var(--gold); }

.ctrl-hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--app-mute);
  font-size: 0.66rem;
  line-height: 1.6;
  letter-spacing: 0.02em;
}
.ctrl-hint kbd {
  background: var(--app-bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--app-ink);
  font-size: 0.66rem;
  margin: 0 1px;
}

/* ==========================================================================
   全屏模式 · 让 view-record 铺满 · 控制台仍在视觉内
   ========================================================================== */

.view-record:fullscreen,
.view-record:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: var(--app-bg);
}
.view-record:fullscreen .record-stage-wrap,
.view-record:-webkit-full-screen .record-stage-wrap {
  position: absolute;
  inset: 0;
}
.view-record:fullscreen .record-panel,
.view-record:-webkit-full-screen .record-panel,
.view-record:fullscreen .record-panel-restore,
.view-record:-webkit-full-screen .record-panel-restore {
  position: fixed;
  z-index: 999;
}
.view-record:fullscreen .record-panel,
.view-record:-webkit-full-screen .record-panel {
  top: 16px;
  right: 16px;
}
.view-record:fullscreen .record-panel-restore,
.view-record:-webkit-full-screen .record-panel-restore {
  top: 18px;
  right: 18px;
  transform: none;
}

/* ==========================================================================
   移动端
   ========================================================================== */

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; }
  .brand-name { font-size: 1.1rem; }
  .tab-btn { padding: 6px 10px; font-size: 0.78rem; }
  .wrap { padding: 24px 16px; }
  .view-title { font-size: 1.8rem; }
  .dropzone { padding: 40px 16px; }
  .dropzone-icon { font-size: 2.4rem; }
  .preview-toolbar {
    padding: 10px 12px;
    gap: 10px;
    flex-direction: column;
    align-items: stretch;
  }
  .preview-tool-group {
    width: 100%;
    justify-content: space-between;
  }
  .tool-select {
    flex: 1;
    min-width: 0;
  }
  .preview-actions {
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
    justify-content: space-between;
  }
  .preview-actions .btn { flex: 1; }
  .record-panel {
    width: calc(100vw - 32px);
    max-width: 340px;
    right: 16px;
    top: 16px;
  }
}
