:root {
  --bg: #050508;
  --bg-elevated: #0c0c10;
  --bg-card: #111116;
  --text: #f2f4f8;
  --muted: #8b93a7;
  --muted-dim: #5c6478;
  --accent: #3d9cf0;
  --accent-rgb: 61, 156, 240;
  --accent-dim: rgba(61, 156, 240, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --danger: #f87171;
  --radius: 14px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  vertical-align: middle;
  font-size: 20px;
  line-height: 1;
}

/* ── Login page background (black blueprint) ── */
.login-page { background: #000; }

.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.login-bg-blueprint {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #000 0%, #050505 45%, #000 100%);
}

.login-bg-blueprint::before,
.login-bg-blueprint::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.login-bg-blueprint::before {
  top: 48px;
  left: 48px;
  right: 48px;
  bottom: 48px;
}

.login-bg-blueprint::after {
  top: 64px;
  left: 64px;
  right: 64px;
  bottom: 64px;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.06);
}

.login-bg-grid-major {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, #000 15%, transparent 72%);
}

.login-bg-grid-minor {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 20px 20px;
  mask-image: radial-gradient(ellipse 88% 78% at 50% 45%, #000 10%, transparent 70%);
}

.login-bg-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 65% 50% at 50% 42%, rgba(255, 255, 255, 0.02), transparent 60%),
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 35%, rgba(0, 0, 0, 0.75) 100%);
}

/* ── Login layout ── */
.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 32px;
}

.login-layout {
  display: grid;
  grid-template-columns: 1fr min(420px, 100%);
  gap: 48px;
  width: min(1080px, 100%);
  align-items: center;
}

@media (max-width: 900px) {
  .login-layout {
    grid-template-columns: 1fr;
    max-width: 440px;
  }
  .login-hero { display: none; }
}

.login-hero-inner { max-width: 420px; }

.login-hero-logo {
  display: block;
  width: min(280px, 85%);
  height: auto;
  margin-bottom: 28px;
  opacity: 0.95;
}

.login-hero-tag {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.login-hero-title {
  margin: 0 0 16px;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.login-hero-desc {
  margin: 0 0 28px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 36ch;
}

.login-hero-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-hero-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.login-hero-features .material-symbols-outlined {
  font-size: 18px;
  color: var(--accent);
  opacity: 0.9;
}

/* ── Login card ── */
.login-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius) + 4px);
  padding: 32px 28px 28px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 24px 48px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.login-card-head {
  text-align: center;
  margin-bottom: 28px;
}

.login-card-logo {
  display: block;
  width: min(160px, 70%);
  height: auto;
  margin: 0 auto 16px;
}

.login-card-kicker {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.login-card-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.field-login {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-login span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field-login input,
.glass-input,
.glass-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-login input:focus,
.glass-input:focus,
.glass-select:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.glass-select { cursor: pointer; }

.form-err {
  display: block;
  font-size: 13px;
  color: var(--danger);
  min-height: 1.2em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(180deg, #4aabf5 0%, #2d8ee8 100%);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.35);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #5bb5f7 0%, #3d9cf0 100%);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
}

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.turnstile-wrap {
  min-height: 65px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--border);
}

.captcha-slot {
  width: 100%;
}

.captcha-slot--v3 {
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.captcha-v3-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.captcha-v3-status.is-loading {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.08);
}

.captcha-v3-icon {
  font-size: 22px;
  color: #6babf5;
  flex-shrink: 0;
  margin-top: 1px;
}

.captcha-v3-status.is-loading .captcha-v3-icon {
  color: var(--muted);
  animation: captchaPulse 1.2s ease-in-out infinite;
}

.captcha-v3-status.is-error {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.06);
}

.captcha-v3-status.is-error .captcha-v3-icon {
  color: #f87171;
}

@keyframes captchaPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.captcha-v3-copy {
  min-width: 0;
}

.captcha-v3-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.captcha-v3-legal {
  display: block;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted-dim);
}

.captcha-v3-legal a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.captcha-v3-legal a:hover {
  color: var(--accent);
}

/* v3 浮動徽章改由表單內合規文案呈現 */
.grecaptcha-badge {
  visibility: hidden !important;
}

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted-dim);
  line-height: 1.7;
}

.login-footer p { margin: 0; }

.login-footer a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

.login-footer a:hover { color: var(--accent); }

/* ── MFA verify ── */
.login-step { animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.verify-panel { text-align: center; }

.verify-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-dim);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  color: var(--accent);
}

.verify-icon .material-symbols-outlined { font-size: 28px; }

.verify-title {
  font-weight: 600;
  font-size: 17px;
  margin: 0 0 6px;
}

.verify-desc {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.mfa-send-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}

.mfa-cooldown-hint {
  margin: 0;
  font-size: 12px;
  color: #fbbf24;
}

.login-mfa-row { text-align: left; margin-bottom: 8px; }

.otp-wrap {
  position: relative;
  margin: 16px auto;
  max-width: 320px;
}

#otpInput {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: text;
  z-index: 2;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}

.otp-cells {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.otp-cell {
  height: 52px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  font-family: ui-monospace, Consolas, monospace;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
  cursor: text;
}

.otp-cell.filled {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text);
}

.otp-cell.active {
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

#stepVerify.is-loading {
  opacity: 0.72;
  pointer-events: none;
}

/* ── Modals ── */
.login-geo-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  padding: 16px;
}

.modal-card {
  width: min(440px, 100%);
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-card h3 { margin: 0 0 10px; font-size: 18px; }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.muted { color: var(--muted); }
.tiny { font-size: 12px; }

/* ── App shell (post-login) ── */
#app {
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(5, 5, 8, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.topbar-brand { display: flex; align-items: center; gap: 12px; }

.brand-icon {
  width: 40px;
  height: auto;
  object-fit: contain;
}

.topbar-brand strong { display: block; font-size: 15px; font-weight: 600; }
.topbar-brand small { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.main-area {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* Gmail-style contact shell (/contact, /contact/settings) */
body.contact-shell #app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

body.contact-shell .topbar {
  flex-shrink: 0;
  padding: 8px 16px;
}

body.contact-shell .topbar-nav-mail {
  display: none;
}

body.contact-shell .main-area {
  flex: 1;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

body.contact-shell .contact-gmail-layout {
  min-height: 100%;
  height: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
}

.glass,
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.page-intro { margin-bottom: 20px; }
.page-intro h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 600;
}

.form-grid { display: grid; gap: 12px 16px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid .span-2 { grid-column: 1 / -1; }

@media (max-width: 720px) {
  .form-grid.cols-2 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span, .field-label { font-size: 13px; color: var(--muted); }

.checkbox-row { flex-direction: row !important; align-items: center; gap: 10px; }

.ce-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1000px) {
  .ce-layout { grid-template-columns: 1fr; }
}

.ce-preview-card {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow: auto;
}

.ce-body-input {
  min-height: 280px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}

.ce-editor-block { margin-top: 12px; }

.md-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 8px;
  border-radius: 10px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.md-tab {
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.md-tab.active {
  background: var(--accent-dim);
  color: var(--text);
}

.ce-preview-panel {
  min-height: 280px;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  overflow: auto;
}

.ce-preview-frame-wrap {
  min-height: 360px;
  border-radius: 12px;
  overflow: hidden;
  background: #0a0a0e;
  border: 1px solid var(--border);
}

.ce-preview-iframe {
  width: 100%;
  min-height: 420px;
  border: 0;
  background: #fff;
}

.ce-preview-text {
  white-space: pre-wrap;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  min-height: 200px;
}

.ce-mode-segmented {
  display: inline-flex;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.ce-seg-btn {
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.ce-seg-btn.active {
  background: var(--accent-dim);
  color: var(--text);
}

.ce-status { margin-top: 10px; min-height: 1.2em; font-size: 13px; color: var(--muted); }

.denied-card { max-width: 480px; margin: 40px auto; text-align: center; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  z-index: 300;
  font-size: 14px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.md-body h1, .md-body h2, .md-body h3 { margin: 12px 0 8px; }
.md-body p { margin: 8px 0; line-height: 1.6; }
.md-body ul, .md-body ol { padding-left: 20px; }
.md-body blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.md-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 6px 8px; }

.form-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
