.auth-corner {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1300;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: .35rem .65rem;
  border: 1px solid var(--line, #d9cfbe);
  border-radius: 2px;
  background: var(--paper, #f6f1e7);
  color: var(--muted, #6b6157);
  font: inherit;
  font-size: .75rem;
  line-height: 1.7;
  letter-spacing: .06em;
  cursor: pointer;
  transition: border-color .18s ease, color .18s ease;
}
.auth-corner--home { right: 6rem; }
.auth-corner:hover { border-color: var(--rubric, #8c2b1f); color: var(--rubric, #8c2b1f); }
.auth-corner:focus-visible, .auth-dialog :focus-visible, .auth-gate-notice :focus-visible { outline: 2px solid var(--rubric, #8c2b1f); outline-offset: 3px; }

/* Europa uses its own scoped palette; its fixed account control should sit on
   the dark page chrome without introducing a light paper-colored tile. */
.auth-corner--module {
  border-color: rgba(223, 201, 149, .28);
  background: transparent;
  color: #e8dfd0;
}
.auth-corner--module:hover {
  border-color: rgba(223, 201, 149, .62);
  background: rgba(223, 201, 149, .06);
  color: #fff3d7;
}
.auth-corner--module:focus-visible { outline-color: rgba(223, 201, 149, .78); }

.auth-dialog {
  --af-paper: var(--paper, #f6f1e7);
  --af-card: var(--card, #fbf8f1);
  --af-ink: var(--ink, #201c17);
  --af-muted: var(--muted, #6b6157);
  --af-line: var(--line, #d9cfbe);
  --af-accent: var(--rubric, #8c2b1f);
  box-sizing: border-box;
  width: min(440px, calc(100vw - 2rem));
  max-width: 440px;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 1px solid var(--af-line);
  border-radius: 3px;
  background: var(--af-paper);
  color: var(--af-ink);
  font-family: Georgia, "Songti SC", "STSong", "SimSun", serif;
  font-size: 15px;
  line-height: 1.7;
  box-shadow: 0 18px 70px rgba(35, 23, 12, .2);
  overflow: auto;
}
.auth-dialog::backdrop { background: rgba(24, 18, 12, .42); backdrop-filter: blur(3px); }
.auth-dialog [hidden] { display: none !important; }
.auth-dialog-body { position: relative; padding: 2rem; }
.auth-wordmark { margin: 0 2rem 1.5rem 0; color: var(--af-accent); font-size: .72rem; letter-spacing: .18em; }
.auth-close { position: absolute; top: .75rem; right: .75rem; width: 36px; height: 36px; border: 0; background: transparent; color: var(--af-muted); font: inherit; font-size: 24px; line-height: 1; cursor: pointer; }
.auth-dialog h2 { margin: 0 0 .5rem; font-size: 1.7rem; font-weight: 500; letter-spacing: .04em; }
.auth-tabs { display: flex; gap: 1.4rem; margin: 0 0 1.3rem; border-bottom: 1px solid var(--af-line); }
.auth-tabs button { padding: 0 .1rem .7rem; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--af-muted); font: inherit; font-size: 1.35rem; cursor: pointer; }
.auth-tabs button[aria-selected="true"] { border-bottom-color: var(--af-accent); color: var(--af-ink); }
.auth-intro { margin: 0 0 1.3rem; color: var(--af-muted); font-size: .85rem; }
.auth-dialog label { display: block; margin: 1rem 0 .4rem; color: var(--af-ink); font-size: .8rem; letter-spacing: .04em; }
.auth-dialog input { box-sizing: border-box; display: block; width: 100%; min-height: 44px; padding: .65rem .75rem; border: 1px solid var(--af-line); border-radius: 2px; background: var(--af-card); color: var(--af-ink); font: 16px/1.3 Arial, "Microsoft YaHei", sans-serif; }
.auth-dialog input[name="code"] { font-size: 1.4rem; letter-spacing: .25em; }
.auth-primary { display: block; width: 100%; min-height: 44px; margin-top: 1.3rem; padding: .6rem 1rem; border: 1px solid var(--af-accent); border-radius: 2px; background: var(--af-accent); color: var(--af-paper); font: inherit; font-size: .9rem; letter-spacing: .08em; cursor: pointer; }
.auth-primary:hover { opacity: .88; }
.auth-dialog button:disabled { opacity: .5; cursor: wait; }
.auth-links { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .8rem; }
.auth-link { padding: .25rem 0; border: 0; background: transparent; color: var(--af-muted); font: inherit; font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.auth-link:hover { color: var(--af-accent); }
.auth-status { min-height: 1.6em; margin: 1rem 0 0; color: var(--af-muted); font-size: .82rem; overflow-wrap: anywhere; }
.auth-status[data-error="true"] { color: var(--af-accent); }
.auth-account-email { margin: 1rem 0 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--af-line); font: 16px/1.7 Arial, sans-serif; overflow-wrap: anywhere; }
.auth-gate-notice { position: fixed; inset: 0; display: grid; place-content: center; padding: 2rem; background: #f6f1e7; color: #201c17; text-align: center; font-family: Georgia, "Songti SC", serif; }
.auth-gate-notice[hidden] { display: none; }
.auth-gate-notice h1 { margin: 0; font-size: clamp(1.7rem, 5vw, 2.5rem); font-weight: 500; }
.auth-gate-notice p { color: #6b6157; }
.auth-gate-notice button, .auth-gate-notice a { padding: .55rem 1rem; border: 1px solid #d9cfbe; border-radius: 2px; background: transparent; color: #8c2b1f; font: inherit; text-decoration: none; cursor: pointer; }
.auth-gate-actions { display: flex; justify-content: center; gap: .7rem; flex-wrap: wrap; }
html.auth-required #europa-opening, html.auth-pending #europa-opening { display: none; }
@media (prefers-color-scheme: dark) {
  .auth-dialog { --af-paper: var(--paper, #16130f); --af-card: var(--card, #1d1913); --af-ink: var(--ink, #e9e2d4); --af-muted: var(--muted, #a79c8b); --af-line: var(--line, #332c22); --af-accent: var(--rubric, #d8695a); }
}
@media (max-width: 520px) {
  .auth-corner { font-size: .7rem; padding: .35rem .5rem; }
  .auth-dialog-body { padding: 1.7rem 1.35rem 1.3rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .auth-dialog[open] .auth-dialog-body { animation: auth-appear .18s ease-out; }
  @keyframes auth-appear { from { opacity: .5; transform: translateY(5px); } }
}
