:root {
  --bg: #0b0f17;
  --panel: #151b27;
  --panel-2: #1b2333;
  --border: #283143;
  --accent: #4f8cff;
  --accent-2: #2563eb;
  --accent-grad: linear-gradient(135deg, #5b94ff, #2563eb);
  --stop: #ff5468;
  --text: #eef2f8;
  --muted: #8b95a6;
}

* { box-sizing: border-box; }

/* 確保 hidden 屬性永遠生效（否則 display:flex 會蓋掉它）*/
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(1100px 480px at 50% -8%, rgba(79,140,255,.14), transparent 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
}

main {
  width: 100%;
  max-width: 520px;
  padding: 8px 18px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- 品牌標頭 ---- */
.brand {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  margin-top: 8px;
}
.brand-logo { width: 38px; height: 38px; border-radius: 10px; display: block; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: .01em; }
.sub { margin: 0; text-align: center; color: var(--muted); font-size: .9rem; }

/* ---- 語言大按鈕 ---- */
.lang-row { display: flex; gap: 10px; }
.lang-btn {
  flex: 1;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 16px 6px;
  color: var(--text);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .05s;
}
.lang-btn:active { transform: scale(.97); }
.lang-btn .flag { font-size: 2rem; line-height: 1; }
.lang-btn .name { font-size: 1rem; font-weight: 600; }
.lang-btn.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(79,140,255,.18), rgba(79,140,255,.06));
  box-shadow: 0 0 0 3px rgba(79,140,255,.12);
}

/* ---- 方向切換 ---- */
.direction {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 15px;
  color: var(--text);
  cursor: pointer;
  transition: transform .05s, border-color .15s;
}
.direction:active { transform: scale(.98); }
.direction:hover { border-color: #33405a; }
.dir-lang { font-size: 1.15rem; font-weight: 700; }
.direction .arrow { font-size: 1.45rem; color: var(--accent); }
.dir-hint { margin: -6px 0 0; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---- 開始 / 停止 ---- */
.mic {
  border: none;
  border-radius: 16px;
  padding: 20px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: white;
  background: var(--accent-grad);
  box-shadow: 0 10px 26px rgba(37,99,235,.38);
  cursor: pointer;
  transition: transform .05s ease, box-shadow .2s ease, filter .15s;
}
.mic:hover { filter: brightness(1.05); }
.mic:active { transform: scale(.98); }
.mic.recording {
  background: linear-gradient(135deg, #ff6b78, #e23744);
  box-shadow: 0 10px 26px rgba(226,55,68,.4);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 8px 22px rgba(226,55,68,.4), 0 0 0 0 rgba(255,84,104,.5); }
  70%  { box-shadow: 0 8px 22px rgba(226,55,68,.4), 0 0 0 16px rgba(255,84,104,0); }
  100% { box-shadow: 0 8px 22px rgba(226,55,68,.4), 0 0 0 0 rgba(255,84,104,0); }
}

.status { text-align: center; color: var(--muted); font-size: .9rem; min-height: 1.2em; }
.status.err { color: var(--stop); }

/* ---- 字幕 ---- */
.caption { display: flex; flex-direction: column; gap: 12px; }
.cap-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.cap-block h2 { margin: 0 0 6px; font-size: .8rem; color: var(--muted); font-weight: 600; letter-spacing: .03em; }
.cap { margin: 0; font-size: 1.1rem; line-height: 1.5; min-height: 1.5em; word-break: break-word; }
/* 譯文是重點 → 醒目藍字 + 左側色條 */
.cap-block:last-child { border-left: 3px solid var(--accent); }
#outputText { color: #7fb0ff; font-weight: 600; }
/* 原文是附帶辨識，較粗糙 → 淡化 */
#inputText { color: var(--muted); }
.rough { font-weight: 400; opacity: .75; }

/* ---- 登入牆 ---- */
.login-overlay {
  position: fixed; inset: 0;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(79,140,255,.16), transparent 60%),
    var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 100;
}
.login-card {
  background: linear-gradient(180deg, #171f2e, #121823);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 30px 34px;
  text-align: center;
  max-width: 360px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
}
.login-logo-img {
  width: 84px; height: 84px; border-radius: 21px;
  box-shadow: 0 10px 34px rgba(79,140,255,.38);
}
.login-card h1 { font-size: 1.4rem; margin: 4px 0 0; }
.login-sub { margin: 0 0 8px; color: var(--muted); font-size: .95rem; }
#gbtn { min-height: 44px; display: flex; justify-content: center; }
.login-msg { margin: 4px 0 0; color: var(--stop); font-size: .85rem; min-height: 1em; }

/* ---- 已登入列 ---- */
.userbar {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  max-width: 520px; margin: 0 auto; padding: 14px 18px 0; width: 100%;
  color: var(--muted); font-size: .9rem;
}
.signout {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 5px 14px; cursor: pointer; font-size: .85rem;
  transition: border-color .15s, color .15s;
}
.signout:hover { border-color: #3a455c; color: var(--text); }
.signout:active { transform: scale(.97); }
