:root {
  --bg: #0b0f17;
  --panel: #141a26;
  --text: #e8edf5;
  --dim: #8a94a6;
  --accent: #4f8cff;
  --green: #34c77b;
  --red: #e5534b;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
}
#app { display: flex; flex-direction: column; height: 100dvh; }

header {
  padding: calc(env(safe-area-inset-top) + 10px) 12px 8px;
  border-bottom: 1px solid #1e2635;
}
h1 { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
select {
  background: var(--panel); color: var(--text); border: 1px solid #2a3345;
  border-radius: 8px; padding: 6px 8px; font-size: 14px;
}
.icon-btn {
  background: var(--panel); border: 1px solid #2a3345; color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 15px;
}
.icon-btn.on { border-color: var(--accent); color: var(--accent); }

#flipPanel {
  background: var(--accent); color: #fff;
  transform: rotate(180deg);
  padding: 18px 16px; text-align: center;
  font-size: 30px; font-weight: 600; line-height: 1.35;
  border-bottom: 2px solid #000;
}
#flipPanel.hidden { display: none; }
#flipText:empty::before { content: '翻译会显示给对方看'; opacity: .55; font-size: 20px; }

#subtitles {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  -webkit-overflow-scrolling: touch;
}
.line { margin-bottom: 14px; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
.line .src { color: var(--dim); font-size: 14px; margin-bottom: 2px; }
.line .dst { font-size: 19px; line-height: 1.45; }
.line .dst.err { color: var(--red); font-size: 14px; }

#partial {
  padding: 6px 14px; min-height: 26px; color: var(--dim);
  font-size: 14px; font-style: italic;
}

footer {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 12px);
  border-top: 1px solid #1e2635;
}
#status { flex: 1; font-size: 12px; color: var(--dim); }
#status.ok { color: var(--green); }
#status.err { color: var(--red); }
#micBtn {
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  font-size: 17px; font-weight: 600; padding: 14px 28px;
}
#micBtn.recording { background: var(--red); animation: pulse 1.6s infinite; }
#micBtn.paused { background: #e6a23c; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,83,75,.5); } 50% { box-shadow: 0 0 0 10px rgba(229,83,75,0); } }
#endBtn {
  background: var(--panel); color: var(--text); border: 1px solid #2a3345;
  border-radius: 999px; font-size: 14px; font-weight: 600; padding: 12px 16px;
}
#endBtn.hidden { display: none; }

/* 存档面板 */
#archivePanel {
  position: fixed; inset: 0; background: rgba(4,7,12,.96); z-index: 9;
  display: flex; flex-direction: column;
}
#archivePanel.hidden { display: none; }
.archive-box { display: flex; flex-direction: column; height: 100%; }
.archive-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 10px;
  border-bottom: 1px solid #1e2635;
}
.archive-head h2 { flex: 1; font-size: 16px; font-weight: 600; text-align: center; }
.archive-head button {
  background: var(--panel); border: 1px solid #2a3345; color: var(--text);
  border-radius: 8px; padding: 6px 12px; font-size: 14px;
}
#archiveBack.hidden { visibility: hidden; }
#archiveList, #archiveDetail { flex: 1; overflow-y: auto; padding: 12px 14px; }
#archiveDetail.hidden, #archiveList.hidden { display: none; }
.arc-item {
  background: var(--panel); border: 1px solid #222b3c; border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 10px;
}
.arc-item .meta { flex: 1; min-width: 0; }
.arc-item .name { font-size: 16px; font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arc-item .time { font-size: 12px; color: var(--dim); }
.arc-item .del {
  background: none; border: none; color: var(--dim); font-size: 16px; padding: 6px;
}
.arc-empty { color: var(--dim); text-align: center; margin-top: 40px; font-size: 14px; }
#archiveDetail .arc-head { margin-bottom: 14px; }
#archiveDetail .arc-head .name { font-size: 18px; font-weight: 600; }
#archiveDetail .arc-head .time { font-size: 12px; color: var(--dim); margin-top: 4px; }

#passGate {
  position: fixed; inset: 0; background: var(--bg); z-index: 10;
  display: flex; align-items: center; justify-content: center;
}
#passGate.hidden { display: none; }
.gate-box { text-align: center; width: 78%; max-width: 320px; }
.gate-box h2 { font-size: 18px; margin-bottom: 16px; font-weight: 600; }
.gate-box input {
  width: 100%; padding: 12px; font-size: 16px; border-radius: 10px;
  border: 1px solid #2a3345; background: var(--panel); color: var(--text);
  margin-bottom: 12px; text-align: center;
}
.gate-box button {
  width: 100%; padding: 12px; font-size: 16px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600;
}
#passErr { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
