:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #7a8494;
  --line: #e4e7ec;
  --accent: #7b5cf0;
  --note-bg: #f3f0ff;
  --danger: #d6455d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --card: #1a2133;
    --text: #e8ebf2;
    --muted: #8f9ab0;
    --line: #2a3349;
    --accent: #a08cff;
    --note-bg: #252044;
    --danger: #ff7d92;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 18px; }

main { padding: 12px 12px calc(env(safe-area-inset-bottom) + 76px); max-width: 640px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; }
.card p { margin: 0 0 10px; }

.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; padding: 8px 0; }
.center:empty { display: none; }

/* 一筆翻譯紀錄 */
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.msg { padding: 8px 0; border-top: 1px solid var(--line); }
.msg:first-of-type { border-top: 0; }
.msg > div { white-space: pre-wrap; overflow-wrap: anywhere; }
.ko { color: var(--muted); font-size: 14px; }
.zh { font-size: 16px; }
.note { margin-top: 4px; padding: 6px 8px; border-radius: 8px; background: var(--note-bg); font-size: 13px; }
body.hide-ko .ko { display: none; }

button, .file-btn {
  font: inherit; color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
button:disabled { opacity: .5; }
.wide { display: block; width: 100%; text-align: center; margin-top: 8px; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.ghost { border: 0; background: none; color: var(--accent); padding: 4px 0; font-size: 14px; }
.ghost.danger { color: var(--danger); font-size: 13px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label.row { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text); margin: 0; }
label.file-btn { font-size: 16px; color: #fff; margin: 0; }
input[type="url"], input[type="password"], textarea {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
textarea { resize: vertical; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; border: 0; border-radius: 0; background: none; padding: 14px 0; color: var(--muted); }
.tabbar button.active { color: var(--accent); font-weight: 600; }
