*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #eef2f7;
  --bg2: #e4eaf2;
  --card: #ffffff;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --error: #dc2626;
  --text: #1e293b;
  --muted: #64748b;
  --input-border: #cbd5e1;
  --soft: #f8fafc;
}
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, var(--bg), var(--bg2));
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  -webkit-font-smoothing: antialiased;
}
.view { width: 100%; max-width: 420px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  padding: 32px;
}
.brand { text-align: center; margin-bottom: 26px; }
.logo-badge {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.logo-badge svg { width: 24px; height: 24px; }
.brand h1 { font-size: 22px; font-weight: 700; }
.brand p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .lead-icon { position: absolute; left: 12px; color: var(--muted); display: inline-flex; }
.input-wrap .lead-icon svg { width: 18px; height: 18px; }
.input-wrap input {
  width: 100%;
  padding: 10px 40px 10px 38px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.toggle {
  position: absolute; right: 6px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--muted); cursor: pointer; border-radius: 6px;
}
.toggle:hover { color: var(--primary); }
.toggle svg { width: 18px; height: 18px; }
.btn-primary {
  width: 100%; padding: 11px;
  border: none; border-radius: 8px;
  background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.error { color: var(--error); font-size: 13px; margin: 4px 0 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 14px; text-align: center; }
.muted { color: var(--muted); font-size: 13px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.dash-head h2 { font-size: 18px; font-weight: 700; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--muted); font-size: 13px; cursor: pointer;
  transition: color .15s, border-color .15s; white-space: nowrap;
}
.btn-ghost:hover { color: var(--error); border-color: var(--error); }
.btn-ghost svg { width: 16px; height: 16px; }
.key-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--soft); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
.key-row code {
  flex: 1; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px; word-break: break-all;
}
.icon-btn {
  width: 32px; height: 32px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn svg { width: 16px; height: 16px; }
.success { color: var(--success); font-size: 12px; margin-top: 8px; }
@media (max-width: 480px) { .card { padding: 24px; } }
.asr-row { display: flex; gap: 8px; align-items: center; }
.asr-row input[type=file] { flex: 1; font-size: 13px; }
.asr-row .btn-primary { width: auto; padding: 9px 16px; }

/* ---- dashboard topbar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.account { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
.account-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.account-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-sub { font-size: 12px; }

/* ---- sections ---- */
.sect { padding-top: 20px; border-top: 1px solid var(--border); }
.sect:first-of-type { border-top: none; padding-top: 0; }
.sect-label {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted);
  text-transform: uppercase; margin-bottom: 12px;
}

/* ---- dropzone ---- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
  border: 1.5px dashed var(--input-border);
  border-radius: 8px;
  background: var(--soft);
  padding: 22px 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: #eef4ff; outline: none; }
.dropzone.drag { border-color: var(--primary); background: #e6efff; }
.dropzone.has-file { border-color: var(--success); background: #ecfdf5; }
.dropzone.has-file .dropzone-icon { color: var(--success); }
.dropzone-icon { color: var(--muted); display: inline-flex; transition: color .15s; }
.dropzone-icon svg { width: 26px; height: 26px; }
.dropzone-text { font-size: 13px; font-weight: 600; color: var(--text); word-break: break-all; }
.dropzone-sub { font-size: 11px; }

/* ---- asr button ---- */
.asr-btn { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; }
.asr-btn .btn-icon { display: inline-flex; }
.asr-btn .btn-icon svg { width: 18px; height: 18px; }
.spin { animation: spin .7s linear infinite; }

/* ---- result panel ---- */
.result-panel {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px 14px;
}
.result-panel.is-error { border-left-color: var(--error); }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.result-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.result-meta { font-size: 11px; }
.result-text { font-size: 14px; line-height: 1.6; word-break: break-word; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- file manager ---- */
.sect-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sect-head .sect-label { margin-bottom: 0; }
.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-row { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: #fff; }
.file-main { display: flex; align-items: center; gap: 12px; }
.file-icon { color: var(--primary); display: inline-flex; flex: 0 0 auto; }
.file-icon svg { width: 22px; height: 22px; }
.play-btn {
  width: 36px; height: 36px; flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: #eef4ff; color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.play-btn:hover { background: #dbeafe; }
.play-btn.playing { background: var(--primary); color: #fff; }
.play-btn svg { width: 16px; height: 16px; }
.file-dur { font-variant-numeric: tabular-nums; }
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.modal-mask[hidden] { display: none; }
.modal-input { width: 100%; min-height: 72px; margin-bottom: 16px; padding: 8px 10px; border: 1px solid var(--input-border); border-radius: 8px; font-size: 13px; font-family: inherit; resize: vertical; outline: none; }
.modal-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.file-summary { border-left-color: #7c3aed; }
.file-summary.is-error { border-left-color: var(--error); }
.modal { background: #fff; border-radius: 8px; box-shadow: 0 12px 32px rgba(15,23,42,.2); padding: 22px; width: 100%; max-width: 360px; }
.modal-msg { font-size: 14px; line-height: 1.6; color: var(--text); margin-bottom: 18px; word-break: break-word; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .btn-primary.sm { min-width: 64px; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; margin-top: 2px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto; display: inline-flex; align-items: center; }
.badge-pending { background: #f1f5f9; color: var(--muted); }
.badge-converting { background: #e0eaff; color: var(--primary); }
.badge-done { background: #d1fae5; color: var(--success); }
.badge-failed { background: #fee2e2; color: var(--error); }
.badge-spin { display: inline-flex; animation: spin .7s linear infinite; margin-right: 4px; }
.badge-spin svg { width: 12px; height: 12px; }
.file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn-ghost.sm, .btn-primary.sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-primary.sm { width: auto; }
.btn-ghost.sm svg { width: 14px; height: 14px; }
.file-text { margin-top: 10px; border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 8px; background: var(--soft); padding: 10px 12px; }
.file-text.is-error { border-left-color: var(--error); }
.file-text-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.file-text .result-text { font-size: 13px; line-height: 1.6; word-break: break-word; white-space: pre-wrap; }
.empty { text-align: center; padding: 24px 0; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 50; }

/* ---- detail pages (chat / play) ---- */
.detail-view { max-width: 720px; height: calc(100vh - 48px); }
.detail-card { display: flex; flex-direction: column; height: 100%; padding: 0; overflow: hidden; }
.detail-topbar { padding: 14px 18px; border-bottom: 1px solid var(--border); margin-bottom: 0; flex: 0 0 auto; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 8px; color: var(--muted); text-decoration: none;
  transition: background .15s, color .15s;
}
.back-btn:hover { background: var(--soft); color: var(--primary); }
.back-btn svg { width: 18px; height: 18px; }
.file-sub { font-size: 12px; }

/* ---- chat page ---- */
.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-empty { text-align: center; padding: 40px 0; font-size: 13px; }
.msg { display: flex; gap: 8px; max-width: 86%; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-ai { align-self: flex-start; }
.msg-avatar {
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 50%; background: #7c3aed; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.msg-avatar svg { width: 16px; height: 16px; }
.msg-bubble {
  padding: 10px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.65; word-break: break-word; white-space: pre-wrap;
}
.msg-user .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-ai .msg-bubble { background: var(--soft); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-context { max-width: 100%; align-self: stretch; }
.msg-context .msg-bubble { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 12px; }
.msg-avatar-file { background: var(--primary); }
.msg-context-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--primary); margin-bottom: 4px; }
.msg-ai .msg-bubble.msg-error { background: #fef2f2; border-color: #fecaca; color: var(--error); }
.msg-loading { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.msg-loading .badge-spin { display: inline-flex; }
.msg-loading .badge-spin svg { width: 14px; height: 14px; }
.msg-copy {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; margin-left: 6px; vertical-align: middle;
  border: none; border-radius: 4px; background: transparent;
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.msg-copy:hover { background: rgba(0,0,0,.06); color: var(--text); }
.msg-copy svg { width: 14px; height: 14px; }
.chat-input-bar {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 18px 16px; border-top: 1px solid var(--border); flex: 0 0 auto; background: #fff;
}
.chat-input {
  flex: 1; resize: none; border: 1px solid var(--input-border);
  border-radius: 8px; padding: 9px 12px; font-size: 14px; font-family: inherit;
  outline: none; line-height: 1.5; max-height: 140px; transition: border-color .15s, box-shadow .15s;
}
.chat-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.chat-input:disabled { background: var(--soft); cursor: not-allowed; }
.chat-send {
  width: 40px; height: 40px; flex: 0 0 auto; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.chat-send svg { width: 18px; height: 18px; }
.chat-send:disabled { opacity: .6; cursor: not-allowed; }

/* ---- play page ---- */
.play-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; min-height: 0; }
.play-disc {
  width: 140px; height: 140px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 36px rgba(37,99,235,.3);
  transition: transform .2s;
}
.play-disc.playing { transform: scale(1.04); }
.play-circle {
  width: 56px; height: 56px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s; backdrop-filter: blur(4px);
}
.play-circle:hover { background: rgba(255,255,255,.3); }
.play-circle svg { width: 28px; height: 28px; }
.play-controls { padding: 16px 22px 22px; border-top: 1px solid var(--border); flex: 0 0 auto; background: #fff; }
.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.play-time { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 38px; text-align: center; }
.progress-bar {
  flex: 1; height: 22px; position: relative; cursor: pointer;
  display: flex; align-items: center;
}
.progress-track { width: 100%; height: 4px; border-radius: 2px; background: var(--border); }
.progress-filled { position: absolute; height: 4px; border-radius: 2px; background: var(--primary); width: 0%; pointer-events: none; }
.progress-thumb {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary); left: 0%;
  transform: translateX(-50%); pointer-events: none; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.play-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.speed-control { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.speed-control button {
  padding: 6px 12px; border: none; background: #fff; color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
  border-right: 1px solid var(--border);
}
.speed-control button:last-child { border-right: none; }
.speed-control button:hover { background: var(--soft); color: var(--text); }
.speed-control button.active { background: var(--primary); color: #fff; }
@media (max-width: 480px) {
  .detail-view { max-width: 100%; height: calc(100vh - 32px); }
  .play-disc { width: 110px; height: 110px; }
  .play-circle { width: 46px; height: 46px; }
  .play-circle svg { width: 22px; height: 22px; }
  .speed-control button { padding: 5px 8px; font-size: 11px; }
}
