:root {
  color-scheme: light;
  --weight-strong: 700;
  --weight-heavy: 700;
  --bg: #f5f2eb;
  --panel-bg: #fffdfa;
  --panel-bg-strong: #fffdfa;
  --panel-border: #e4ddd0;
  --panel-border-hover: #cdbb9e;
  --surface-soft: #f8f5ee;
  --surface-hover: #f1e9db;
  --field-bg: #fdfbf7;
  --text: #3e3b35;
  --muted: #6b665d;
  --primary: #d9b46e;
  --primary-hover: #cfa354;
  --accent: #82591f;
  --logo: #b58b40;
  --number: #3f403e;
  --accent-line: #dec89f;
  --primary-soft: #f7edda;
  --primary-text: #3f2d18;
  --switch-knob: #b8bab5;
  --danger: #a75546;
  --success: #3e7755;
  --success-soft: #e9f1e7;
  --success-line: #c6d8c7;
  --focus-ring: rgba(183, 132, 52, 0.22);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(81, 59, 29, 0.06);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --weight-strong: 800;
  --weight-heavy: 900;
  --bg: #191919;
  --panel-bg: #232323;
  --panel-bg-strong: #232323;
  --panel-border: #3b3b3b;
  --panel-border-hover: #545454;
  --surface-soft: #292929;
  --surface-hover: #333333;
  --field-bg: #292929;
  --text: #e9e9e9;
  --muted: #ababab;
  --primary: #d7b35b;
  --logo: var(--primary);
  --accent: #e4bf70;
  --number: var(--accent);
  --primary-hover: #e5be76;
  --accent-line: #665635;
  --primary-soft: #303030;
  --primary-text: #41330b;
  --switch-knob: #969892;
  --danger: #ed9a87;
  --success: #98d7b9;
  --success-soft: #254036;
  --success-line: #3f6152;
  --focus-ring: rgba(228, 191, 112, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  position: relative;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel-bg);
}

.topbar-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(760px, calc(100% - 40px));
  min-height: 68px;
  margin: 0 auto;
  padding: 0 20px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 44px;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 158px;
  max-width: 44vw;
  background: var(--logo);
  -webkit-mask: url('/account/logo.png?v=1') center / 100% 100% no-repeat;
  mask: url('/account/logo.png?v=1') center / 100% 100% no-repeat;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: auto;
  visibility: hidden;
}

.account-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.theme-picker { position: relative; flex: none; z-index: 2; margin-right: 8px; }
.theme-toggle { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--panel-border); border-radius: 9px; background: var(--panel-bg); color: var(--muted); cursor: pointer; }
.theme-toggle:hover, .theme-toggle[aria-expanded="true"] { border-color: var(--accent-line); background: var(--primary-soft); color: var(--accent); }
.theme-icon { display: none; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme-preference="system"] .theme-icon-system,
:root[data-theme-preference="light"] .theme-icon-light,
:root[data-theme-preference="dark"] .theme-icon-dark { display: block; }
.theme-menu { position: absolute; top: calc(100% + 10px); right: 0; width: 148px; padding: 5px; border: 1px solid var(--panel-border); border-radius: 10px; background: var(--panel-bg); box-shadow: var(--shadow); }
.theme-menu[hidden] { display: none; }
.theme-menu button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); text-align: left; font-size: 13px; cursor: pointer; }
.theme-menu button:hover, .theme-menu button:focus-visible { background: var(--surface-soft); color: var(--text); }
.theme-menu button[aria-checked="true"] { background: var(--primary-soft); color: var(--accent); }
.theme-menu button span { visibility: hidden; }
.theme-menu button[aria-checked="true"] span { visibility: visible; }

.login-button,
.btn-primary,
.btn-copy,
.icon-button,
.avatar-button,
.dropdown-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: var(--weight-strong);
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s, background 0.2s, border-color 0.2s;
}

.login-button,
.btn-primary {
  border: none;
  color: var(--primary-text);
  background: var(--primary);
}

.login-button {
  min-height: 40px;
  padding: 9px 16px;
}

.btn-primary {
  width: 100%;
  min-height: 48px;
  padding: 13px 20px;
}

.login-button:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--primary-hover);
}

.login-button:disabled,
.btn-primary:disabled,
.btn-copy:disabled,
.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.avatar-button,
.icon-button,
.btn-copy,
.dropdown-action {
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--panel-border);
}

.avatar-button {
  width: 40px;
  height: 40px;
  padding: 0;
  margin-top: 2px;
  background: transparent;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--accent);
  font-size: 1rem;
  font-weight: var(--weight-heavy);
  line-height: 1;
}

.avatar-button:hover {
  background: transparent;
  border-color: transparent;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logout-action {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 110px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.dropdown-action {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
}

.avatar-button:hover,
.icon-button:hover:not(:disabled),
.btn-copy:hover:not(:disabled),
.dropdown-action:hover {
  background: var(--surface-hover);
  border-color: var(--panel-border-hover);
}

.icon-button:active:not(:disabled) {
  transform: scale(0.96);
}

#refresh-button svg {
  transform-origin: 50% 50%;
}

#refresh-button.is-refreshing {
  opacity: 0.86;
  cursor: progress;
}

#refresh-button.is-refreshing svg {
  animation: refresh-spin 0.72s linear infinite;
}

@keyframes refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-progress {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.container {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 20px 64px;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  border-color: var(--panel-border-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.card.dashboard {
  padding: 22px;
}

.card.dashboard .section-title {
  margin-bottom: 18px;
}

.card.dashboard .score-grid {
  gap: 10px;
  margin-bottom: 16px;
}

.card.dashboard .score-tile {
  min-height: 96px;
  padding: 14px 12px;
}

.card.dashboard .redeem-panel {
  margin-bottom: 24px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.section-title h1,
.section-title h2,
.success-box h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.18rem;
  font-weight: var(--weight-strong);
  letter-spacing: 0;
}

.section-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.icon-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
}

.hidden {
  display: none !important;
}

.auth-error,
.error {
  min-height: 1.35em;
  margin: 0 0 14px;
  color: var(--danger);
  font-size: 0.875rem;
}

.error {
  margin: 12px 0 0;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.score-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 112px;
  padding: 18px 16px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.score-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: var(--weight-strong);
}

.score-tile strong {
  display: block;
  color: var(--text);
  font-size: 2rem;
  font-weight: var(--weight-heavy);
  line-height: 1;
}

.score-tile.highlight {
  background: var(--primary-soft);
  border-color: var(--accent-line);
}

.score-tile.highlight strong {
  color: var(--number);
}

.redeem-panel {
  margin-bottom: 20px;
}

.redeem-control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 14px;
}

.redeem-label-row {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.redeem-label-row label {
  margin-bottom: 0;
}

.redeem-cost {
  color: var(--number);
  font-size: 0.82rem;
  font-weight: 700;
}

.redeem-cost:empty {
  display: none;
}

.redeem-input-row {
  display: contents;
}

.stepper {
  grid-column: 1;
  display: grid;
  grid-template-columns: 40px minmax(60px, 1fr) 40px;
  gap: 10px;
  min-width: 160px;
}

input[type="number"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: var(--field-bg);
  font-weight: var(--weight-heavy);
  text-align: center;
}

input[type="number"]:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="text"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: var(--field-bg);
  font-weight: var(--weight-strong);
}

input[type="text"]:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.redeem-limit {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.redeem-limit strong {
  color: var(--number);
  font-size: 1.1rem;
  font-weight: var(--weight-heavy);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: var(--weight-strong);
}

.actions {
  display: block;
}

.redeem-rule {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

#redeem-error:empty {
  display: none;
}

.redeem-gate {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  color: var(--accent);
  background: var(--primary-soft);
  font-size: 0.86rem;
  font-weight: var(--weight-strong);
}

.dashboard.binding-required .redeem-panel,
.dashboard.binding-required .actions {
  opacity: 0.5;
}

.binding-card {
  padding: 22px;
}

.binding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
}

.binding-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 22px;
  border-left: 1px solid var(--panel-border);
}

.binding-block:first-child {
  padding-left: 0;
  border-left: none;
}

.binding-block:last-child {
  padding-right: 0;
}

.binding-block-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin-bottom: 18px;
  margin-top: 6px;
}

.binding-block-title h2 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: var(--weight-heavy);
  line-height: 1.2;
}

.binding-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  min-height: 100px;
  margin-top: auto;
}

.binding-state {
  flex: 0 0 auto;
  max-width: 54%;
  overflow: hidden;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: var(--weight-heavy);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.binding-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.binding-save {
  min-width: 60px;
}

.link-action {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0;
  border: none;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: var(--weight-strong);
}

.link-action:hover:not(:disabled) {
  color: var(--accent);
}

.link-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.binding-feedback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
}

.binding-feedback .link-action,
.binding-feedback .binding-error,
.binding-feedback .vip-remaining {
  margin: 0;
}

.binding-feedback .binding-error {
  flex: 1 1 auto;
  min-height: 1.3em;
}

.binding-feedback .binding-error:empty {
  display: none;
}

.binding-feedback .vip-remaining {
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: var(--weight-strong);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.binding-feedback .vip-remaining:empty,
.binding-feedback .link-action.hidden,
.binding-feedback .vip-remaining.hidden {
  display: none;
}

.auto-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
  min-height: 100px;
  margin-top: auto;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
}

.auto-summary strong {
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: var(--weight-heavy);
}

.auto-summary span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: var(--weight-strong);
  overflow-wrap: anywhere;
}

.auto-summary span.error-text {
  color: var(--danger);
}

.switch {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 28px;
  margin: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--surface-soft);
  transition: background 0.2s, border-color 0.2s;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--switch-knob);
  transition: transform 0.2s, background 0.2s;
}

.switch input:checked + span {
  border-color: var(--accent-line);
  background: var(--primary-soft);
}

.switch input:checked + span::after {
  transform: translateX(20px);
  background: var(--primary);
}

:root:not([data-theme="dark"]) .switch input:checked + span {
  border-color: var(--primary);
  background: var(--primary);
}

:root:not([data-theme="dark"]) .switch input:checked + span::after {
  background: var(--panel-bg);
}

.switch input:disabled + span {
  opacity: 0.45;
  cursor: not-allowed;
}

.logged-out .score-tile,
.logged-out .redeem-panel {
  opacity: 0.54;
}

.btn-copy {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.78rem;
}

.success-box {
  text-align: center;
  padding: 8px 0 4px;
}

.success-box h2 {
  margin-bottom: 8px;
}

.success-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

#success-card {
  scroll-margin-top: 80px;
}


.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border: 1px solid var(--success-line);
  border-radius: 50%;
  background: var(--success-soft);
}

.success-icon::after {
  content: "";
  width: 14px;
  height: 24px;
  border: solid var(--success);
  border-width: 0 4px 4px 0;
  transform: rotate(45deg) translate(-2px, -2px);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 2000;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  background: var(--panel-bg-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: var(--weight-strong);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 浅色与深色的结构、字重完全一致，仅允许色彩不同。 */
:root:not([data-theme="dark"]) .card:hover {
  border-color: var(--panel-border);
}

:root:not([data-theme="dark"]) .score-tile:not(.highlight) strong {
  color: #6d706d;
}

:root:not([data-theme="dark"]) .auto-summary {
  background: var(--surface-soft);
}

:root:not([data-theme="dark"]) .auto-summary strong {
  color: var(--text);
}

:root:not([data-theme="dark"]) .theme-toggle:hover,
:root:not([data-theme="dark"]) .theme-toggle[aria-expanded="true"] {
  border-color: var(--panel-border-hover);
  background: var(--surface-soft);
  color: var(--text);
}

:root:not([data-theme="dark"]) .avatar {
  background: var(--surface-soft);
}

:root:not([data-theme="dark"]) .redeem-gate {
  background: var(--surface-soft);
  border-color: var(--panel-border);
}

@media (max-width: 680px) {
  .topbar-inner,
  .container {
    width: auto;
  }

  .topbar-inner {
    min-height: 60px;
    padding: 0 14px;
  }

  .brand-logo {
    width: 132px;
    max-width: 40vw;
  }

  .login-button {
    min-height: 38px;
    padding: 8px 12px;
  }

  .container {
    padding: 22px 14px 44px;
  }

  .card {
    padding: 20px;
  }

  .card.dashboard {
    padding: 18px;
  }

  .card.dashboard .score-tile {
    min-height: 84px;
  }

  .section-title {
    align-items: flex-start;
  }

  .score-grid,
  .redeem-panel,
  .binding-grid {
    grid-template-columns: 1fr;
  }

  .binding-block {
    padding: 18px 0;
    border-left: none;
    border-top: 1px solid var(--panel-border);
  }

  .binding-block:first-child {
    padding-top: 0;
    border-top: none;
  }

  .binding-block:last-child {
    padding-bottom: 0;
  }

  .score-tile {
    min-height: 94px;
  }

  .score-tile strong {
    font-size: 1.72rem;
  }
}

@media (max-width: 420px) {
  .login-button svg {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #refresh-button.is-refreshing svg {
    animation-duration: 1.4s;
  }
}

#bound-account-input { min-width: 0; width: 100%; padding: 10px 12px; border: 1px solid var(--panel-border); border-radius: var(--radius-sm); background: var(--field-bg); color: var(--text); font: inherit; }
#bound-account-input:focus { outline: none; border-color: var(--accent-line); }
