/* ============================================================
   V0.10 — Apple HIG 分层克制式界面
   功能层（标题栏/工具栏/录音按钮/抽屉/弹窗/toast/悬浮窗）= Liquid Glass
   内容层（结果卡片/列表）= 近实心高对比材质
   跟随系统亮暗（light-dark），保留原生标题栏
   ============================================================ */

/* ---- 随包内置字体：Inter（西文，视觉贴近 SF Pro）+ MiSans（中文，免费商用） ---- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/Inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/Inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/Inter-700.woff2") format("woff2");
}
@font-face {
  font-family: "MiSans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/MiSans-400.woff2") format("woff2");
}
@font-face {
  font-family: "MiSans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/MiSans-500.woff2") format("woff2");
}
@font-face {
  font-family: "MiSans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/MiSans-600.woff2") format("woff2");
}

* { box-sizing: border-box; }

:root {
  color-scheme: light dark;
  --font-ui: "Inter", "MiSans", -apple-system, "SF Pro Text", "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-cn: "MiSans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: light-dark(#f5f5f7, #000);
  --glass: light-dark(rgba(255,255,255,.72), rgba(30,30,32,.72));
  --glass-strong: light-dark(rgba(255,255,255,.86), rgba(40,40,42,.9));
  --content: light-dark(rgba(255,255,255,.94), rgba(42,42,45,.96));
  --content-soft: light-dark(rgba(246,247,249,.92), rgba(35,36,38,.94));
  --fill: light-dark(rgba(0,0,0,.045), rgba(255,255,255,.07));
  --label: light-dark(#1d1d1f, #f5f5f7);
  --secondary: light-dark(#6e6e73, #a1a1a6);
  --tertiary: light-dark(#86868b, #8e8e93);
  --separator: light-dark(rgba(0,0,0,.08), rgba(255,255,255,.12));
  --accent: light-dark(#0071e3, #0a84ff);
  --accent-strong: light-dark(#0077ed, #409cff);
  --accent-soft: light-dark(rgba(0,113,227,.1), rgba(10,132,255,.16));
  --danger: light-dark(#ff3b30, #ff453a);
  --danger-soft: light-dark(rgba(255,59,48,.1), rgba(255,69,58,.16));
  --ok: light-dark(#34c759, #30d158);
  --shadow-sm: light-dark(0 1px 3px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.5));
  --shadow: light-dark(0 8px 28px rgba(0,0,0,.12), 0 12px 36px rgba(0,0,0,.55));
  --blur: 28px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
}

html, body {
  margin: 0;
  background: var(--bg);
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--label);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; }

/* 统一图标：圆头线条风格（CSS 覆盖 SVG presentation attribute） */
.win svg, .indicator svg { stroke-linecap: round; stroke-linejoin: round; }
.win svg *, .indicator svg * { stroke-width: 1.8; }
.rec-btn svg * { stroke-width: 2; }

.icon { width: 16px; height: 16px; flex: none; }
.icon.sm { width: 14px; height: 14px; }
.icon.mic { width: 34px; height: 34px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

#app {
  max-width: 1060px;
  margin: 0 auto;
  padding: 14px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.win {
  background: var(--bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- 标题栏（功能层·玻璃） ---- */
.titlebar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px; height: 48px;
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border-bottom: 1px solid var(--separator);
  user-select: none;
}
.tb-left { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.tb-left > .icon { color: var(--accent); }
.ver {
  font-size: 11px; color: var(--secondary); font-weight: 500;
  padding: 2px 9px; border-radius: 999px;
  background: var(--fill); border: 1px solid var(--separator);
}
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--secondary);
  background: var(--glass-strong); border: 1px solid var(--separator);
  padding: 4px 12px; border-radius: 999px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status.rec .dot { background: var(--danger); animation: pulse 1s infinite; }
.status.busy .dot { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--secondary);
  cursor: pointer; transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--fill); color: var(--accent); }

/* ---- 工具栏（功能层·玻璃） ---- */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border-bottom: 1px solid var(--separator);
}
.preset { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--secondary); }
.preset-desc { font-size: 12px; color: var(--secondary); }

select, input[type="text"], input[type="password"], input[type="number"] {
  font-family: inherit; font-size: 13px; color: var(--label);
  background: var(--content); border: 1px solid var(--separator);
  border-radius: var(--radius-sm); padding: 6px 10px; outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.spacer { flex: 1; }

.vbtn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 13px; cursor: pointer;
  border-radius: var(--radius-sm); padding: 6px 12px;
  border: 1px solid var(--separator); background: var(--content); color: var(--label);
  transition: transform .12s ease, border-color .12s ease, color .12s ease, background .12s ease;
}
.vbtn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.vbtn:active { transform: translateY(0); }
.vbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.vbtn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.vbtn.block { width: 100%; padding: 9px; justify-content: center; }
.vbtn.small { padding: 4px 10px; font-size: 12px; }
.vbtn.ghost { background: transparent; border-color: transparent; color: var(--secondary); }
.vbtn.ghost:hover { background: var(--fill); color: var(--accent); border-color: transparent; transform: none; }

/* ---- 主区域 ---- */
.main {
  display: grid; grid-template-columns: 200px 1fr; gap: 14px; padding: 16px;
  flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr);
}
.record-col { display: flex; }
.rec-area {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--content-soft); border: 1px solid var(--separator); border-radius: 16px;
  padding: 26px 12px; text-align: center;
}
.rec-btn {
  width: 104px; height: 104px; border-radius: 50%; cursor: pointer; touch-action: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 26px light-dark(rgba(0,113,227,.32), rgba(10,132,255,.38));
  transition: transform .15s ease, box-shadow .2s ease;
}
.rec-btn:hover { transform: scale(1.045); }
.rec-btn:active { transform: scale(.98); }
.rec-btn.recording {
  background: linear-gradient(145deg, var(--danger), #d70015);
  animation: rec-glow 1.2s ease-in-out infinite;
}
@keyframes rec-glow {
  0%, 100% { box-shadow: 0 0 0 0 light-dark(rgba(255,59,48,.4), rgba(255,69,58,.45)); }
  50% { box-shadow: 0 0 0 18px light-dark(rgba(255,59,48,0), rgba(255,69,58,0)); }
}
.rec-label { font-size: 14px; font-weight: 600; }
.rec-timer { font-size: 13px; color: var(--secondary); font-variant-numeric: tabular-nums; letter-spacing: .05em; }
.rec-hint { font-size: 11.5px; color: var(--secondary); line-height: 1.6; }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-height: 0; grid-template-rows: minmax(0, 1fr); }
.right-stack { display: grid; gap: 14px; min-height: 0; }
.panel {
  display: flex; flex-direction: column;
  background: var(--content); border: 1px solid var(--separator); border-radius: 16px;
  overflow: hidden; box-shadow: var(--shadow-sm);
  animation: fade-up .25s ease both;
  min-height: 0;
}
.panel[hidden] { display: none; }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
.panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--separator); background: transparent;
}
.panel-title { font-size: 13px; font-weight: 600; }
.panel-sub { font-size: 12px; color: var(--secondary); margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head .vbtn { margin-left: auto; }
.badge {
  font-size: 11.5px; color: var(--accent); background: var(--accent-soft);
  padding: 2px 10px; border-radius: 999px; flex: none; font-weight: 500;
}
.panel-body {
  flex: 1; min-height: 90px; padding: 13px 16px; font-size: 14px;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  overflow-y: auto; max-height: none; line-height: 1.6;
}
.placeholder { color: var(--tertiary); font-size: 13px; }
.caret {
  display: inline-block; width: 2px; height: 1em; background: var(--accent);
  vertical-align: -2px; margin-left: 1px; animation: blink .8s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---- 历史（内容层·近实心） ---- */
.history { border-top: 1px solid var(--separator); padding: 12px 16px 16px; }
.hist-head { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.hist-tools { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.hist-tools[hidden] { display: none; }
.hist-head .muted { font-size: 12px; font-weight: 400; color: var(--secondary); }
.hist-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--label);
  background: transparent; border: none; cursor: pointer; padding: 4px 7px; border-radius: 8px;
}
.hist-toggle:hover { background: var(--fill); color: var(--accent); }
.hist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; max-height: 320px; overflow-y: auto; }
.hist-list[hidden] { display: none; }
.hist-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--separator); border-radius: 12px; background: var(--content-soft);
  transition: border-color .12s ease;
}
.hist-item:hover { border-color: var(--accent); }
.hist-main {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  font-family: inherit; font-size: inherit; color: inherit; text-align: left;
  background: transparent; border: none; cursor: pointer; padding: 9px 12px;
}
.hist-time { font-size: 11.5px; color: var(--secondary); flex: none; width: 92px; font-variant-numeric: tabular-nums; }
.hist-snippet { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.hist-actions { display: none; gap: 2px; flex: none; padding-right: 6px; }
.hist-item:hover .hist-actions { display: inline-flex; }
.hist-actions button {
  width: 28px; height: 28px; border: none; background: transparent; border-radius: 7px; cursor: pointer;
  color: var(--secondary); display: inline-flex; align-items: center; justify-content: center;
}
.hist-actions button:hover { background: var(--fill); color: var(--accent); }
.hist-empty {
  padding: 16px; text-align: center; color: var(--secondary); font-size: 13px;
  border: 1px dashed var(--separator); border-radius: 12px;
}

/* ---- 设置页（全屏独立界面） ---- */
.settings {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg);
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .18s ease;
}
.settings.show { opacity: 1; visibility: visible; pointer-events: auto; }
.set-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 20px; flex: none;
  border-bottom: 1px solid var(--separator); font-weight: 600; font-size: 15px;
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
}
.set-body { flex: 1; overflow-y: auto; padding: 22px 22px 34px; }
.set-grid {
  max-width: 880px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 20px;
  align-content: start;
}
.set-grid .full { grid-column: 1 / -1; }
.set-body label { display: grid; gap: 5px; font-size: 13px; color: var(--secondary); }
.set-body .note { margin: 0; font-size: 12px; color: var(--secondary); }
.set-grid .vbtn:not(.block) { justify-self: start; }
.mic-row { display: flex; align-items: center; gap: 10px; }
.mic-row .mic-test { margin: 0; }
.set-divider {
  font-size: 12px; font-weight: 600; color: var(--secondary);
  border-top: 1px solid var(--separator); padding-top: 10px; margin-top: 2px;
}
.check { display: flex !important; align-items: center; gap: 8px; color: var(--label) !important; font-size: 13px !important; cursor: pointer; }
.check input, .radio input { accent-color: var(--accent); }
.saved { font-size: 12px; color: var(--ok); text-align: center; }
.mic-test { font-size: 12px; color: var(--secondary); }

/* ---- 弹窗（功能层·玻璃） ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 380px; max-width: 100%;
  background: var(--glass-strong); border: 1px solid var(--separator); border-radius: var(--radius-lg);
  box-shadow: 0 18px 60px rgba(0,0,0,.26); overflow: hidden;
  backdrop-filter: blur(32px) saturate(150%); -webkit-backdrop-filter: blur(32px) saturate(150%);
  animation: modal-in .18s ease both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--separator); font-weight: 600;
}
.modal-body { padding: 16px; display: grid; gap: 14px; }
.modal-body fieldset { border: 1px solid var(--separator); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 8px; }
.modal-body legend { font-size: 12px; color: var(--secondary); padding: 0 4px; }
.radio { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--separator);
}

/* ---- 词典弹窗 ---- */
.modal-lg { width: 640px; }
.dict-body { display: grid; gap: 10px; }
.dict-tabs {
  display: inline-flex; gap: 3px;
  background: var(--fill); border: 1px solid var(--separator); border-radius: var(--radius-sm); padding: 3px;
  width: fit-content;
}
.dict-tab {
  border: none; background: transparent; color: var(--secondary);
  font-family: inherit; font-size: 13px; padding: 6px 16px; border-radius: 8px; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.dict-tab.active { background: var(--glass-strong); color: var(--label); font-weight: 500; box-shadow: var(--shadow-sm); }
.dict-desc { margin: 0; font-size: 12px; color: var(--secondary); line-height: 1.6; }
.dict-view { display: grid; gap: 10px; }
.dict-view[hidden] { display: none; }
.dict-toolbar { display: flex; align-items: center; gap: 8px; }
.dict-toolbar .muted { font-size: 12px; }
.dict-io { padding: 12px 16px 0; }
.dict-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; max-height: 280px; overflow-y: auto; }
.dict-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--separator); border-radius: 12px; padding: 9px 12px;
  background: var(--content-soft);
  transition: border-color .12s ease;
}
.dict-item:hover { border-color: var(--accent); }
.dict-item.off { opacity: .55; }
.dict-item-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.dict-item-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dict-item-sub { font-size: 11.5px; color: var(--secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dict-badge {
  font-size: 11px; color: var(--accent); background: var(--accent-soft);
  padding: 1px 8px; border-radius: 999px; flex: none;
}
.dict-toggle { accent-color: var(--accent); flex: none; }
.dict-item-actions { display: inline-flex; gap: 4px; flex: none; }
.dict-item-actions button {
  width: 28px; height: 28px; border: none; background: transparent; border-radius: 7px; cursor: pointer;
  color: var(--secondary); display: inline-flex; align-items: center; justify-content: center;
}
.dict-item-actions button:hover { background: var(--fill); color: var(--accent); }
.dict-form {
  border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px;
  background: var(--accent-soft); display: grid; gap: 8px;
}
.dict-form[hidden] { display: none; }
.dict-form label { display: grid; gap: 4px; font-size: 12px; color: var(--secondary); }
.dict-form input[type="text"] { width: 100%; }
.dict-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dict-opts { display: flex; gap: 14px; flex-wrap: wrap; }
.dict-form-actions { display: flex; align-items: center; gap: 8px; }
.dict-tip { font-size: 12px; color: var(--ok); }
.dict-empty {
  padding: 18px; text-align: center; color: var(--secondary); font-size: 13px;
  border: 1px dashed var(--separator); border-radius: 12px;
}
.import-body { gap: 12px; }
.import-summary {
  font-size: 12px; color: var(--label); background: var(--accent-soft);
  border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 9px 12px; line-height: 1.55;
}
.import-summary .ok { color: var(--ok); font-weight: 500; }
.import-summary .warn { color: var(--danger); }
.import-section { margin-top: 12px; }
.import-section h4 { margin: 0 0 6px; font-size: 13px; color: var(--secondary); }
.import-preview { max-height: 260px; }
.import-preview .dict-item {
  display: grid; grid-template-columns: 20px 1fr 1fr 28px; gap: 8px;
  align-items: center;
}
.import-preview input[type="text"] {
  width: 100%; font-size: 13px; padding: 6px 9px;
  border: 1px solid var(--separator); border-radius: 8px; background: var(--content);
  color: var(--label);
}
.import-preview .dict-item.off { opacity: .45; }
.import-select-all { font-size: 13px; color: var(--secondary); margin: 2px 0 -4px; }

/* ---- 提示（toast） ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  max-width: 80vw; padding: 10px 18px; border-radius: 999px;
  background: var(--glass-strong); color: var(--label); border: 1px solid var(--separator);
  box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 13px; z-index: 60;
  backdrop-filter: blur(24px) saturate(150%); -webkit-backdrop-filter: blur(24px) saturate(150%);
}
.toast.error { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.toast.ok { border-color: var(--ok); }

.banner {
  margin: 0 0 10px; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--label); font-size: 13px;
}

/* ---- 关闭提示弹窗（复用 .modal） ---- */

/* ---- 减少动效 ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 800px) {
  .main { grid-template-columns: 1fr; }
  .panels { grid-template-columns: 1fr; }
  .record-col { order: -1; }
  #app { padding: 8px; }
  .win { border-radius: var(--radius); }
}

/* ---- 网页模式：隐藏桌面专属项 ---- */
.web-mode .desktop-only,
.web-mode .desktop-only.full {
  display: none !important;
}
.web-only {
  display: none;
}
.web-mode .web-only {
  display: block;
}
.web-mode .web-only.note {
  color: var(--secondary);
  line-height: 1.7;
}
