:root {
  color-scheme: light;
  --ink: #302922;
  --muted: #7b7065;
  --accent: #b65b3d;
  --accent-hover: #9d482d;
  --line: #ded8cf;
  --text: var(--ink);
  --accent-deep: var(--accent-hover);
  --surface: #fffefa;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Zen Hei", sans-serif;
  color: var(--ink);
  background: #f7f5f0;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: radial-gradient(ellipse at 20% 15%, #f4e9df88, transparent 55%);
}
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 32px 24px;
  background: #fffefa;
  border: 1px solid #e9e3da;
  border-radius: 18px;
  box-shadow: 0 12px 40px #49351d08;
}
.brand { text-align: center; margin-bottom: 22px; }
.brand h1 { margin: 0; font-size: 29px; font-weight: 750; letter-spacing: -1px; line-height: 1.2; }
.brand h1 span { color: var(--accent); }
.brand p { margin: 9px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.method-header { position: relative; min-height: 64px; padding-top: 9px; }
.method-header h2 { margin: 0; font-size: 14px; font-weight: 600; line-height: 22px; }
.switch-hint {
  position: absolute;
  top: 7px;
  right: 72px;
  padding: 4px 8px;
  border: 1px solid #e6d6c6;
  border-radius: 5px;
  background: #faf5ec;
  color: #94603d;
  font-size: 11px;
  line-height: 16px;
  pointer-events: none;
}
.switch-hint::after { content: ""; position: absolute; right: -4px; top: 9px; width: 6px; height: 6px; border-top: 1px solid #e6d6c6; border-right: 1px solid #e6d6c6; background: #faf5ec; transform: rotate(45deg); }
.mode-switch {
  position: absolute;
  top: -5px;
  right: -2px;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #7c6a58;
}
.corner-art {
  position: relative;
  display: block;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-top-right-radius: 7px;
  background: #f0e9de;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  transition: background .18s, color .18s;
}
.corner-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent 48.5%, #fffefa 49%, #fffefa 52%, transparent 52.5%);
  pointer-events: none;
}
.corner-art svg { display: block; width: 64px; height: 64px; }
.mode-switch:hover .corner-art { background: #eadecc; color: var(--accent-hover); }
.login-stage { display: grid; }
.login-panel { grid-area: 1 / 1; min-width: 0; margin: 0; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(6px); transition: opacity .18s ease, transform .18s ease, visibility .18s; }
.login-panel.is-active { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
.field + .field { margin-top: 15px; }
.field label { display: block; margin-bottom: 6px; font-size: 12px; line-height: 18px; font-weight: 550; }
.field input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffefa;
  color: var(--ink);
  font-size: 16px;
  line-height: normal;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: #9a9187; font-size: 13px; opacity: 1; }
.field input:hover { border-color: #bdb0a2; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #b65b3d12; }
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8a7e72;
}
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle:hover { color: var(--accent-hover); background: #f3eee6; }
.login-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 10px; font-size: 12px; }
.remember { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; color: #6e6358; cursor: pointer; }
.remember input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
.login-options a { display: inline-flex; align-items: center; min-height: 40px; white-space: nowrap; }
.submit {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
  transition: background .15s;
}
.submit:hover { background: var(--accent-hover); }
.submit:active { background: #8f4029; }
.password-hint { margin: 11px 0 0; font-size: 11px; line-height: 18px; color: var(--muted); text-align: center; }
.login-footer { margin-top: 18px; text-align: center; }
.login-footer p { margin: 0; font-size: 12px; color: var(--muted); line-height: 24px; }
.login-footer p a { display: inline-flex; align-items: center; margin-left: 5px; min-height: 32px; }
.guide { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; margin-top: 4px; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; }
.guide svg { width: 15px; height: 15px; }
.guide:hover { color: var(--accent-hover); }
.qr-panel { text-align: center; padding-top: 1px; }
.password-return { display: inline-flex; align-items: center; min-height: 40px; margin-top: 5px; padding: 5px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--accent-hover); font-size: 12px; }
.password-return:hover { text-decoration: underline; }
button:focus-visible, a:focus-visible, .remember input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 600px) {
  :root { background: #faf8f4; }
  body {
    align-items: stretch;
    padding: 0;
    background: none;
  }
  .login-card {
    display: grid;
    grid-template-rows: auto 1fr auto;
    align-items: start;
    max-width: 440px;
    min-height: 100vh;
    min-height: 100svh;
    padding: max(28px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .brand { margin: 0; padding: 0 4px; text-align: left; }
  .brand h1 { font-size: 27px; }
  .brand p { margin-top: 7px; font-size: 12px; }
  .login-content {
    align-self: center;
    min-width: 0;
    margin: 28px 0 36px;
    padding: 24px 22px;
    background: var(--surface);
    border: 1px solid #e9e3da;
    border-radius: 20px;
    box-shadow: 0 8px 28px #49351d06;
  }
  .method-header { min-height: 60px; padding-top: 5px; }
  .method-header h2 { font-size: 19px; font-weight: 650; line-height: 28px; }
  .switch-hint { top: 7px; right: 66px; padding: 3px 6px; font-size: 10px; }
  .mode-switch { top: -5px; right: -2px; }
  .login-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 12px 4px 0;
    border-top: 1px solid #e7e1d8;
    text-align: left;
  }
  .login-footer p { white-space: nowrap; }
  .login-footer p a { min-height: 44px; margin-left: 3px; }
  .guide { min-height: 44px; margin: 0 0 0 auto; padding: 8px 0 8px 4px; white-space: nowrap; }
}
@media (max-height: 700px) and (max-width: 600px) {
  .login-card { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .brand h1 { font-size: 25px; }
  .brand p { margin-top: 5px; }
  .login-content { margin: 20px 0; padding: 18px; border-radius: 16px; }
  .method-header { min-height: 54px; }
  .login-footer { padding-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
.password-only { min-height: 44px; }
.qr-image-slot { position: relative; display: flex; align-items: center; justify-content: center; width: 198px; height: 198px; max-width: 100%; margin: 0 auto; padding: 8px; border: 1px solid #e9e3da; border-radius: 12px; background: #fff; }
.qr-image-slot img { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.qr-placeholder { padding: 12px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.qr-status { min-height: 40px; margin: 12px 0 0; color: var(--ink); font-size: 12px; line-height: 20px; overflow-wrap: anywhere; }
.qr-refresh { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; border: 0; border-radius: 11px; background: rgba(255, 254, 250, .96); color: var(--ink); font-size: 13px; font-weight: 600; }
.qr-refresh svg { width: 36px; height: 36px; color: var(--accent-hover); }
.qr-refresh:disabled { cursor: wait; }
.error{color:#b42318;text-align:center;margin-bottom:16px;font-size:13px;background:rgba(180,35,24,0.06);padding:10px;border-radius:8px;}
.pending{margin-bottom:18px;padding:18px 16px;border-radius:12px;background:linear-gradient(135deg,rgba(255,196,97,0.18),rgba(201,100,66,0.12));border:1px solid rgba(201,100,66,0.25);}
.pending-head{display:flex;align-items:center;gap:8px;margin-bottom:10px;}
.pending-icon{width:28px;height:28px;border-radius:50%;background:var(--accent);color:#fff;font-size:16px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;}
.pending-title{font-size:15px;font-weight:700;color:var(--text);}
.pending-body{font-size:13px;line-height:1.65;color:var(--text);}
.pending-body b{color:var(--accent-deep);}
.pending-name-row{margin-top:12px;display:flex;align-items:center;gap:8px;background:#fffaf2;border:1px dashed rgba(201,100,66,0.4);border-radius:10px;padding:9px 12px;}
.pending-name-label{font-size:11px;color:var(--muted);font-weight:600;flex-shrink:0;}
.pending-name{flex:1;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:14px;font-weight:600;color:var(--text);word-break:break-all;}
.pending-copy{flex-shrink:0;padding:6px 12px;background:var(--accent);color:#fff;border:none;border-radius:7px;font-size:12px;font-weight:600;cursor:pointer;transition:background .15s;}
.pending-copy:hover{background:var(--accent-deep);}
.pending-copy.ok{background:#1a7f47;}
.disabled-banner{margin-bottom:16px;padding:14px 16px;border-radius:10px;background:rgba(123,106,91,0.1);border:1px solid rgba(56,43,31,0.18);color:var(--text);}
.disabled-banner .dh{font-size:14px;font-weight:700;margin-bottom:4px;}
.disabled-banner .db{font-size:12.5px;color:var(--muted);line-height:1.55;}
.pending-name-row { flex-wrap: wrap; }
.pending-name { min-width: 0; }
