/* 富贵笔记 — 由品牌图标提炼的 Apple 简约配色
   象牙白承载内容，墨黑负责阅读与结构，信号红只用于主操作和关键状态。 */

:root {
  color-scheme: light;

  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-2: #eee9df;
  --surface-3: #e3ddd2;
  --surface-hover: #dad3c7;
  --line: rgba(24, 24, 22, .09);
  --line-strong: rgba(24, 24, 22, .18);

  --text: #181816;
  --text-2: #625e57;
  --text-3: #8b867d;

  --accent: #f02b24;
  --accent-hover: #d8211b;
  --accent-dim: #b6201b;
  --accent-ink: #ffffff;
  --accent-wash: rgba(240, 43, 36, .09);

  --ink: #181816;
  --ink-2: #292825;
  --reader-text: #f7f2e8;
  --reader-muted: #c7c0b5;
  --sidebar-bg: #151513;

  /* 状态色（仅状态） */
  --ok: #2f8c58;
  --danger: #c93630;

  /* 间距刻度 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --r-card: 20px;
  --r-ctl: 12px;
  --r-sm: 9px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }

::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

svg { display: block; flex: none; }

/* ---------- 按钮层级 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 38px;
  padding: 0 var(--s4);
  border: 0;
  border-radius: var(--r-ctl);
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: background .12s ease, transform .08s ease;
}

.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(.97); }

.btn:disabled,
.btn[disabled] { cursor: default; opacity: .4; }
.btn:disabled:hover { background: var(--surface-3); }
.btn:disabled:active { transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent); transform: scale(.97); }
.btn-primary:disabled:hover { background: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { min-height: 32px; padding: 0 var(--s3); font-size: 13px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

/* 顶栏设置下拉菜单 */
.menu-wrap { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 180px;
  padding: 6px;
  background: var(--surface-2);
  border-radius: var(--r-ctl);
  box-shadow: 0 12px 40px rgba(34, 30, 24, .16);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover { background: var(--surface-3); color: var(--text); }

.chip {
  min-height: 30px;
  padding: 0 var(--s3);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.chip:hover { background: var(--surface-3); color: var(--text); }

/* ---------- 表单控件 ---------- */

input, textarea, select {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  padding: 9px 11px;
  min-height: 38px;
  outline: none;
  transition: border-color .12s ease, background .12s ease;
}

input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, textarea:hover, select:hover { background: var(--surface-3); }
input:focus, textarea:focus, select:focus { border-color: var(--accent-dim); background: var(--surface-2); }

select {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 16px, calc(100% - 9px) 16px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

input[type="file"] {
  padding: 6px 8px;
  color: var(--text-2);
  font-size: 13px;
  background: transparent;
  border: 1px dashed var(--line-strong);
}

input[type="file"]::file-selector-button {
  margin-right: var(--s3);
  padding: 5px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
}

input[type="checkbox"] {
  min-height: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

textarea {
  width: 100%;
  min-height: 400px;
  padding: var(--s4);
  resize: vertical;
  line-height: 1.7;
}

/* ---------- 侧栏 ---------- */

.sidebar {
  --surface: #20201e;
  --surface-2: #282825;
  --surface-3: #343430;
  --surface-hover: #3d3d38;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f7f2e8;
  --text-2: #bcb6ab;
  --text-3: #858078;
  --accent-wash: rgba(240, 43, 36, .15);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  background: var(--sidebar-bg);
  padding: var(--s4);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0 var(--s2); }

.brand-mark {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
}

.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 14px; font-weight: 600; }
.brand-text span { display: block; color: var(--text-3); font-size: 12px; }

.sidebar-search input { width: 100%; font-size: 13px; background: var(--surface); }

.sidebar-listhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--text-3);
  font-size: 11.5px;
  letter-spacing: 0;
  padding: 0 var(--s1);
}

.project-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 calc(-1 * var(--s2));
  padding: 0 var(--s2) var(--s2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-list::-webkit-scrollbar { width: 8px; }
.project-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.project-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-radius: var(--r-sm);
}

.project-item:hover { background: var(--surface); }

.project-item.active {
  background: var(--accent-wash);
}

.project-open {
  min-width: 0;
  padding: var(--s2) var(--s2) var(--s2) 10px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.project-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}

.project-item.active .project-name { color: #ff837d; }

.project-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.status-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
}

.status-dot.ready { background: var(--ok); }
.status-dot.running { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.status-dot.failed, .status-dot.interrupted, .status-dot.cancelled { background: var(--danger); }

@keyframes pulse { 50% { opacity: .3; } }

.project-menu {
  opacity: .4;
  margin-right: 6px;
  padding: 2px 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.project-item:hover .project-menu,
.project-menu:focus-visible { opacity: 1; }
.project-menu:hover { background: var(--surface-3); color: var(--text); opacity: 1; }

.project-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: var(--s2);
  padding: 0 10px var(--s2);
}

.project-actions button {
  flex: 1;
  min-height: 28px;
  padding: 0 var(--s2);
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}

.project-actions button:hover { color: var(--text); }
.project-actions .act-delete:hover { color: var(--danger); }

.sidebar-empty {
  padding: var(--s3) 10px;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- 主区域 ---------- */

.main {
  width: min(880px, 100%);
  justify-self: center;
  padding: var(--s5) var(--s5) var(--s7);
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s4);
}

h1 { margin: 0; font-size: 19px; line-height: 1.2; font-weight: 600; letter-spacing: 0; }
h2 { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 600; }

.topbar-title { display: flex; align-items: center; gap: 9px; }
.topbar-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--line-strong);
}
.topbar-actions { display: flex; align-items: center; gap: 2px; }

.btn-feedback {
  background: var(--accent-wash);
  color: var(--accent);
  font-weight: 600;
}

.btn-feedback:hover { background: rgba(240, 43, 36, .16); color: var(--accent-dim); }

.notification-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.account-wrap { position: relative; }

.account-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  max-width: 190px;
  padding: 3px 9px 3px 4px;
  border: 0;
  border-radius: var(--r-ctl);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.account-button:hover { background: var(--surface-2); }

.account-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

.account-button-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.account-button-copy strong,
.account-button-copy small {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-button-copy strong { font-size: 12.5px; font-weight: 600; }
.account-button-copy small { margin-top: 2px; color: var(--text-3); font-size: 10.5px; }

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  width: min(320px, calc(100vw - 24px));
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface-2);
  box-shadow: 0 18px 56px rgba(34, 30, 24, .17);
}

.account-profile { display: flex; align-items: center; gap: var(--s3); padding: 4px; }
.account-avatar-lg { width: 40px; height: 40px; font-size: 15px; }
.account-profile span:last-child { min-width: 0; display: flex; flex-direction: column; }
.account-profile strong { font-size: 14px; }
.account-profile small { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.account-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: var(--s3);
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--line);
}

.account-stats span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  padding: 9px 4px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 10.5px;
}

.account-stats strong { color: var(--text); font-size: 15px; }
.account-privacy { margin: var(--s3) 4px; color: var(--text-3); font-size: 11.5px; }
.account-logout { border-top: 1px solid var(--line); border-radius: 0 0 var(--r-sm) var(--r-sm); }

/* ---------- 分享网址横条（管理员可见，显眼） ---------- */

.share-bar {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin-top: var(--s4);
  padding: var(--s3) var(--s4);
  background: var(--accent-wash);
  border-radius: var(--r-card);
}

.share-bar-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.share-bar-label { color: var(--accent); font-size: 11.5px; font-weight: 600; letter-spacing: 0; }

.power-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: var(--s2);
  color: var(--text-3);
  font-weight: 500;
}

.power-status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  content: "";
}

.power-status.active { color: var(--ok); }
.power-status.active::before { background: var(--ok); }

.share-bar-url {
  min-width: 0;
  font-size: 14px;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  overflow-wrap: anywhere;
}

.share-bar .btn { flex: none; }

/* ---------- 首屏 Hero：视频链接是全页面唯一焦点 ---------- */

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 320px;
  overflow: hidden;
  margin-top: var(--s7);
  padding: 52px var(--s4) 44px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  background: var(--bg);
}

.hero-flow {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero-content {
  width: 100%;
  position: relative;
}

.hero-title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
  text-shadow: none;
}

.hero-sub {
  margin: var(--s2) auto 0;
  max-width: 480px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
}

.hero-input {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 620px;
  margin: var(--s5) auto 0;
  padding: 6px 6px 6px 22px;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line), 0 18px 42px rgba(34, 30, 24, .10);
  transition: box-shadow .15s ease;
}

.hero-input:focus-within {
  box-shadow: 0 0 0 2px var(--accent), 0 18px 42px rgba(34, 30, 24, .14);
}

.hero-input input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 15px;
}

.hero-input input:focus,
.hero-input input:focus-visible {
  border: 0;
  outline: none;
}

.hero-generate {
  flex: none;
  height: 44px;
  padding: 0 var(--s5);
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, transform .08s ease;
}

.hero-generate:hover { background: var(--accent-hover); }
.hero-generate:active { transform: scale(.97); }
.hero-generate:disabled { opacity: .5; cursor: default; }
.hero-generate:disabled:active { transform: none; }

.hero-foot { margin-top: var(--s4); }

.link-toggle {
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 8px;
}

.link-toggle:hover { color: var(--text-2); text-decoration: underline; }

.hint {
  margin: var(--s3) 0 0;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.6;
}

.callout {
  margin: var(--s3) auto 0;
  max-width: 620px;
  padding: 10px var(--s3);
  border-radius: var(--r-ctl);
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}

.callout-warn {
  background: var(--accent-wash);
  color: var(--accent-dim);
}

.upload-row {
  display: flex;
  gap: var(--s2);
  max-width: 620px;
  margin: var(--s3) auto 0;
}

.upload-row input[type="file"] { flex: 1; min-width: 0; }

.disclosure { margin: var(--s4) auto 0; max-width: 620px; text-align: left; }

.disclosure summary {
  width: fit-content;
  color: var(--text-3);
  font-size: 12.5px;
  cursor: pointer;
  list-style: none;
}

.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::before { content: "▸ "; }
.disclosure[open] summary::before { content: "▾ "; }
.disclosure summary:hover { color: var(--text-2); }
.disclosure[open] summary { margin-bottom: var(--s3); }
.disclosure-tight { margin-top: var(--s3); }

.options {
  display: flex;
  gap: var(--s5);
  align-items: center;
  flex-wrap: wrap;
  color: var(--text-2);
  font-size: 13px;
}

.check, .field { display: flex; align-items: center; gap: var(--s2); }
.field select { font-size: 13px; }

/* ---------- 进度 ---------- */

.progress-panel {
  max-width: 620px;
  margin: var(--s5) auto 0;
  padding: var(--s4);
  background: var(--surface);
  border-radius: var(--r-card);
  text-align: left;
}

.progress-panel.is-idle { display: none; }

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s3);
  margin-bottom: var(--s2);
}

.progress-head strong { font-size: 13.5px; font-weight: 600; }

#progressPercent {
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 4px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width .35s ease;
}

.progress-detail {
  margin-top: var(--s2);
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.6;
}

.progress-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s3);
}

.progress-panel.done .progress-fill { background: var(--ok); }
.progress-panel.done #progressPercent { color: var(--ok); }
.progress-panel.failed .progress-fill { background: var(--danger); }
.progress-panel.failed #progressPercent { color: var(--danger); }
.progress-panel.failed .progress-detail { color: var(--danger); }

.log-box {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  background: var(--bg);
  border-radius: var(--r-ctl);
  padding: var(--s3);
  white-space: pre-wrap;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-3);
}

/* ---------- 卡片（工作区） ---------- */

.card {
  margin-top: var(--s6);
  padding: var(--s5);
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8), 0 10px 32px rgba(34, 30, 24, .05);
}

/* ---------- 工作区 ---------- */

.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s4);
}

.workspace-title { min-width: 0; }

#projectMeta {
  margin: var(--s1) 0 0;
  color: var(--text-3);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.workspace-actions {
  display: flex;
  gap: var(--s2);
  flex: none;
}

.workspace-actions select { min-width: 100px; }

.tabs {
  display: flex;
  gap: 2px;
  margin: var(--s4) 0 0;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--r-ctl);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  padding: 8px 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}

.tabs button:hover { color: var(--text-2); }

.tabs .active {
  color: var(--text);
  background: var(--surface-3);
  font-weight: 600;
}

.tab-panel { display: none; padding-top: var(--s5); }
.tab-panel.active { display: block; }

.toolbar {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--s3);
}

.toolbar-split { justify-content: space-between; align-items: flex-end; }
.toolbar-bottom { margin: var(--s3) 0 0; }
.toolbar-end { margin-left: auto; }
.toolbar input { flex: 1; min-width: 180px; }

.engine-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 11.5px;
}

.engine-badge.is-ai {
  background: var(--accent-wash);
  color: var(--accent-dim);
}

.chip-row {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-bottom: var(--s3);
}

/* ---------- 转录 ---------- */

.transcript-heading strong { display: block; font-size: 15px; }

.transcript-heading span {
  display: block;
  margin-top: 2px;
  color: var(--text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.transcript-actions { display: flex; align-items: center; gap: var(--s2); }

.segmented {
  display: flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--r-ctl);
}

.segmented button {
  min-height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
}

.segmented button:hover { color: var(--text-2); }

.segmented button.active {
  background: var(--surface-3);
  color: var(--accent);
}

.transcript-status {
  padding: var(--s3) 0;
  color: var(--text-3);
  font-size: 12.5px;
}

.transcript-reader,
.transcript-raw {
  width: 100%;
  min-height: 400px;
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  background: var(--ink);
  color: var(--reader-text);
  border-radius: var(--r-card);
  padding: var(--s6) clamp(20px, 5vw, 56px);
}

.transcript-reader {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 16.5px;
  line-height: 1.95;
}

.transcript-reader p {
  max-width: 780px;
  margin: 0 auto 1.3em;
  text-indent: 2em;
  overflow-wrap: anywhere;
}

.transcript-reader p:last-child { margin-bottom: 0; }

.summary-reader h3,
.summary-reader p,
.summary-reader ol,
.summary-reader ul {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}

.summary-reader h3 {
  margin-top: 2em;
  margin-bottom: .75em;
  color: var(--reader-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: 0;
}

.summary-reader h3:first-child { margin-top: 0; }

.summary-reader p {
  margin-bottom: 1.15em;
  color: var(--reader-text);
  text-indent: 0;
}

.summary-reader ol,
.summary-reader ul {
  margin-top: 0;
  margin-bottom: 1.45em;
  padding-left: 1.6em;
}

.summary-reader li {
  margin-bottom: .7em;
  padding-left: .35em;
  color: var(--reader-text);
  overflow-wrap: anywhere;
}

.summary-reader li::marker {
  color: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  font-weight: 600;
}

.transcript-raw {
  color: var(--reader-muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.transcript-empty {
  color: var(--reader-muted);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 13px;
  text-align: center;
  padding-top: 120px;
}

/* ---------- 设置弹窗（AI / 发信） ---------- */

body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--s4);
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
}

.settings-dialog {
  width: min(640px, 100%);
  max-height: min(820px, calc(100vh - 32px));
  overflow: auto;
  padding: var(--s5);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: 0 24px 72px rgba(0, 0, 0, .22);
}

.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s4);
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
}

.settings-head p {
  margin: var(--s1) 0 0;
  color: var(--text-3);
  font-size: 12.5px;
}

.modal-close {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover { background: var(--surface-3); color: var(--text); }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin-top: var(--s4);
}

.settings-dialog .field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  color: var(--text-2);
  font-size: 12.5px;
}

.settings-dialog .field-wide { grid-column: 1 / -1; }
.settings-dialog .field-help { color: var(--text-3); font-size: 11.5px; line-height: 1.55; }

.settings-toggles {
  display: flex;
  gap: var(--s5);
  flex-wrap: wrap;
  margin: var(--s4) 0;
  padding: var(--s3) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.settings-dialog .glossary-field textarea {
  min-height: 150px;
  max-height: 260px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.65;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  margin-top: var(--s4);
}

.settings-intro {
  margin: var(--s4) 0 0;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.7;
}

.feedback-dialog { width: min(640px, 100%); }
.feedback-grid {
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr;
  gap: var(--s3);
  margin-top: var(--s4);
}
.feedback-grid .field-wide { grid-column: 1 / -1; }
.feedback-grid textarea { resize: vertical; min-height: 180px; line-height: 1.7; }
.feedback-context {
  margin: var(--s3) 0 0;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.customer-ticket-section {
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}

.customer-ticket-section > header,
.support-inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.customer-ticket-section h3,
.support-conversation-head h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0;
}

.customer-ticket-section > header span,
.support-inbox-head span {
  color: var(--text-3);
  font-size: 11.5px;
}

.customer-ticket-list {
  display: grid;
  gap: 1px;
  margin-top: var(--s3);
  overflow: hidden;
  border-radius: var(--r-ctl);
  background: var(--line);
}

.customer-ticket-item,
.support-ticket-item {
  width: 100%;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.customer-ticket-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px var(--s3);
  padding: 11px var(--s3);
}

.customer-ticket-item:hover,
.support-ticket-item:hover,
.support-ticket-item.active { background: var(--surface-3); }

.customer-ticket-item strong,
.support-ticket-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
}

.customer-ticket-item small,
.support-ticket-item small {
  color: var(--text-3);
  font-size: 11px;
}

.ticket-unread {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 700;
}

.customer-thread-dialog { width: min(720px, 100%); }

.support-messages {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-height: 240px;
  max-height: min(480px, 52vh);
  margin-top: var(--s4);
  padding: var(--s3);
  overflow-y: auto;
  border-radius: var(--r-ctl);
  background: var(--surface-2);
}

.support-message {
  align-self: flex-start;
  width: min(82%, 640px);
}

.support-message.is-mine { align-self: flex-end; }

.support-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin: 0 4px 4px;
  color: var(--text-3);
  font-size: 10.5px;
}

.support-message-body {
  padding: 10px var(--s3);
  border-radius: var(--r-ctl);
  background: var(--surface-3);
  color: var(--text);
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.support-message.is-support .support-message-body {
  background: var(--accent-wash);
  color: var(--accent-dim);
}

.support-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s3);
  margin-top: var(--s4);
}

.support-composer textarea {
  min-height: 96px;
  max-height: 240px;
  resize: vertical;
  line-height: 1.65;
}

.support-composer .btn { min-height: 42px; }

.support-center-dialog {
  width: min(1120px, 100%);
  height: min(780px, calc(100vh - 32px));
  overflow: hidden;
}

.support-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: calc(100% - 72px);
  min-height: 0;
  margin-top: var(--s4);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
}

.support-inbox {
  min-width: 0;
  padding: var(--s3);
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}

.support-ticket-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: calc(100% - 34px);
  margin-top: var(--s2);
  overflow-y: auto;
}

.support-ticket-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px var(--s2);
  padding: 10px;
  border-radius: var(--r-sm);
}

.support-ticket-item .ticket-preview {
  grid-column: 1 / -1;
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.support-conversation {
  min-width: 0;
  min-height: 0;
  padding: var(--s4);
  overflow: hidden;
}

.support-empty {
  display: grid;
  place-items: center;
  align-content: center;
  height: 100%;
  color: var(--text-3);
  text-align: center;
}

.support-empty strong { color: var(--text-2); font-size: 14px; }
.support-empty span { margin-top: var(--s1); font-size: 12px; }

#supportConversationBody {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
}

.support-conversation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
}

.support-conversation-head p,
.support-project-context {
  margin: 3px 0 0;
  color: var(--text-3);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.support-ticket-actions { display: flex; align-items: center; gap: var(--s2); }

.priority-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  white-space: nowrap;
}

.priority-pill.high { background: rgba(201, 54, 48, .12); color: var(--danger); }
.priority-pill.medium { background: var(--accent-wash); color: var(--accent-dim); }
.priority-pill.low { background: rgba(47, 140, 88, .11); color: var(--ok); }

.support-project-context {
  margin-top: var(--s2);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--line);
}

.support-admin-messages {
  min-height: 0;
  max-height: none;
  margin-top: var(--s2);
}

.support-admin-composer { margin-top: var(--s2); }

/* ---------- 账号登录 ---------- */

.login-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: var(--s4);
  background: rgba(0, 0, 0, .92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.login-card {
  width: min(400px, 100%);
  padding: var(--s6) var(--s5) var(--s5);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: 0 24px 72px rgba(0, 0, 0, .22);
  text-align: center;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  margin-bottom: var(--s5);
  color: var(--text);
  font-size: 15px;
}

.login-card h2 { font-size: 20px; margin-bottom: 6px; letter-spacing: 0; }

.login-sub {
  margin: 0 0 var(--s5);
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.6;
}

.login-step { text-align: left; }
.login-step .field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: var(--s3);
  color: var(--text-2);
  font-size: 12.5px;
}
.login-step .btn { margin-top: var(--s2); }

#loginEmail, #loginCode { width: 100%; min-height: 44px; }
#loginCode { letter-spacing: 0; text-align: center; font-size: 18px; }

.login-note {
  margin: var(--s3) 0 0;
  padding: 10px var(--s3);
  border-radius: var(--r-ctl);
  background: rgba(201, 54, 48, .11);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.55;
}

.login-foot {
  margin: var(--s5) 0 0;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.6;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 10px);
  background: var(--ink);
  color: var(--reader-text);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(34, 30, 24, .18);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Mobile installation and connection recovery. */
.connection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  color: var(--danger);
  border-bottom: 1px solid var(--line);
}
.connection-banner .btn { flex: none; }
.install-dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
}
.install-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.install-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.install-heading img { border-radius: 10px; flex: none; }
.install-heading h2 { font-size: 19px; line-height: 1.4; margin: 0; }
.install-address { color: var(--accent-dim); overflow-wrap: anywhere; }
.install-steps { padding-left: 22px; line-height: 1.9; }
.install-note { font-size: 12px; color: var(--text-2); margin: 20px 0 0; }

/* ---------- 响应式 ---------- */

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sidebar {
    position: static;
    height: auto;
    padding: var(--s3);
  }

  .brand, .sidebar-listhead { display: none; }

  .project-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .project-list::-webkit-scrollbar { display: none; }

  .project-item {
    flex: 0 0 min(230px, 74vw);
    background: var(--surface);
    scroll-snap-align: start;
  }

  .project-menu { opacity: 1; }
  .main { padding: var(--s4) var(--s3) var(--s5); }
  .workspace-head { flex-direction: column; align-items: stretch; }
  .upload-row { flex-direction: column; }
  .hero { margin-top: var(--s6); }
  .share-row { grid-template-columns: 1fr auto; }
  .share-label { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  h1 { font-size: 17px; }

  .card { padding: var(--s4); }
  .workspace-actions { flex-wrap: wrap; }
  .workspace-actions > * { flex: 1; }

  .hero-input {
    flex-wrap: wrap;
    border-radius: var(--r-card);
    padding: var(--s3);
  }
  .hero {
    min-height: 360px;
    padding: 46px var(--s2) 38px;
  }
  .hero-input input { width: 100%; height: 46px; padding: 0 var(--s2); }
  .hero-generate { width: 100%; }
  .progress-actions > .btn { flex: 1 1 auto; }

  .tabs {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 5;
  }

  textarea, .transcript-reader, .transcript-raw { min-height: 52vh; }
  .transcript-reader, .transcript-raw { max-height: none; padding: var(--s4) var(--s3); }
  .toolbar-split { flex-direction: column; align-items: stretch; }
  .transcript-actions { flex-direction: column; align-items: stretch; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .toolbar .btn { flex: 1; }
  .toolbar-end { margin-left: 0; }

  .modal-backdrop { place-items: end stretch; padding: 0; }
  .settings-dialog {
    width: 100%;
    max-height: 92dvh;
    padding: var(--s4);
    padding-bottom: max(var(--s4), env(safe-area-inset-bottom, 0px));
    border-radius: var(--r-card) var(--r-card) 0 0;
  }
  .settings-grid { grid-template-columns: 1fr; }
  .feedback-grid { grid-template-columns: 1fr; }
  .feedback-grid .field-wide { grid-column: auto; }
  .feedback-grid textarea { min-height: 190px; }
  .settings-dialog .field-wide { grid-column: auto; }
  .settings-toggles { flex-direction: column; gap: var(--s2); }
  .settings-actions .btn { flex: 1; }
  .customer-thread-dialog { height: 92dvh; overflow: hidden; }
  .customer-thread-dialog .support-messages { min-height: 0; max-height: none; height: calc(100% - 270px); }
  .support-composer { grid-template-columns: 1fr; }
  .support-composer textarea { min-height: 92px; }
  .support-composer .btn { width: 100%; }
  .support-center-dialog { height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .support-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 32%) minmax(0, 1fr);
  }
  .support-inbox { border-right: 0; border-bottom: 1px solid var(--line); }
  .support-conversation { padding: var(--s3); }
  .support-conversation-head { flex-direction: column; gap: var(--s2); }
  .support-ticket-actions { width: 100%; justify-content: space-between; }
  .support-admin-composer textarea { min-height: 74px; max-height: 120px; }
  .support-message { width: 92%; }
  .login-card { width: 100%; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 28px; }
  .account-button-copy { display: none; }
  .account-button { padding-right: 4px; }
  .topbar-actions { gap: 0; }
  #installAppBtn, #openFeedbackBtn { padding-left: 8px; padding-right: 8px; }
  input, textarea, select { font-size: 16px; }
}
