.mobile-admin-select[hidden] {
  display: none;
}
:root {
  color-scheme: dark;
  --bg: #0c0d10;
  --panel: #17191e;
  --line: #383b43;
  --muted: #b8b4ac;
  --text: #f4f0e8;
  --pink: #d6bd83;
  --accent: #e7d4aa;
  --tint: #22252c;
  --header: #0c0d10f2;
  --on-accent: #18140b;
  --danger: #ff9b9b;
  --focus: #f1d99f;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    "Noto Sans TC",
    sans-serif;
}
:root[data-portal="admin"] {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #fff;
  --line: #cbd3df;
  --muted: #536174;
  --text: #172235;
  --pink: #18375e;
  --accent: #244b7c;
  --tint: #e9eef5;
  --header: #fffffff2;
  --on-accent: #fff;
  --danger: #b42332;
  --focus: #215eba;
}
header {
  background: var(--header);
  gap: 20px;
}
.brand,
.nav a:hover {
  color: var(--text);
}
button,
a.btn {
  background: var(--panel);
  color: var(--text);
}
.primary,
a.btn.primary {
  background: var(--pink);
  color: var(--on-accent);
  border-color: var(--pink);
}
input,
select,
textarea {
  background: var(--bg);
  border-color: var(--line);
  color: var(--text);
}
.sample {
  background: var(--tint);
  color: var(--pink);
}
.announcement {
  background: var(--tint);
}
.hero {
  background: var(--tint);
}
.hero:after {
  background: linear-gradient(90deg, var(--tint) 22%, transparent);
}
.hero p {
  color: var(--muted);
}
.hero img {
  opacity: 0.5;
}
.warning {
  color: var(--muted);
  background: var(--bg);
  border-color: var(--line);
}
.admin-nav .selected {
  background: var(--tint);
  color: var(--pink);
  border-color: var(--accent);
}
.error {
  color: var(--danger);
}
.chip {
  background: var(--tint);
}
#toast {
  background: var(--tint);
  color: var(--text);
  border: 1px solid var(--line);
}
.icon-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 14px;
  color: var(--pink);
  text-decoration: none;
}
.icon-button:hover {
  background: var(--tint);
}
.icon-button svg {
  width: 23px;
  height: 23px;
}
.unread-badge {
  position: absolute;
  top: 0;
  right: -2px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  background: #d83850;
  color: #fff;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  border: 2px solid var(--panel);
  box-sizing: content-box;
}
.unread-badge[hidden] {
  display: none;
}
.profile-summary {
  display: flex;
  align-items: center;
  gap: 18px;
}
.profile-summary h2,
.profile-summary p {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.avatar {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: 22px;
  background: var(--tint);
  color: var(--pink);
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
}
.balance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 14px;
}
.balance-grid strong {
  display: block;
  font-size: 30px;
  color: var(--pink);
  font-variant-numeric: tabular-nums;
}
.balance-grid small {
  display: block;
}
.account-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.account-actions > * {
  flex: 1;
  text-align: center;
}
.menu-list {
  padding-block: 4px;
}
.entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 17px 0;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.entry-row:last-child {
  border-bottom: 0;
}
.entry-row small {
  display: block;
  margin-top: 3px;
}
.entry-row > span:last-child {
  color: var(--muted);
}
.entry-row:hover {
  color: var(--pink);
}
.preserve-lines {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.message-item:last-child {
  border: 0;
}
.message-item.is-unread h3::before {
  content: "●";
  color: var(--pink);
  font-size: 11px;
  margin-right: 8px;
}
.message-item h3 {
  margin: 8px 0;
}
.bank-summary {
  background: var(--bg);
  padding: 18px;
  border-radius: 16px;
  margin-bottom: 20px;
  overflow-wrap: anywhere;
}
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 12px;
  text-decoration: none;
}
.page-bottom-space {
  height: 30px;
}
main[data-page="account"],
main[data-page="bank"],
main[data-page="password"],
main[data-page="profile"],
main[data-page="topup"],
main[data-page="withdraw"],
main[data-page="messages"],
main[data-page="membership"] {
  max-width: 850px;
}
@media (width < 1024px) {
  .mobile-admin-select[hidden] {
    display: grid;
  }
  header {
    padding: 12px 18px;
  }
  .icon-actions {
    gap: 4px;
  }
  .brand {
    font-size: 22px;
  }
  .mobile-bottom-nav[hidden] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--header);
  }
  .entry-row {
    display: flex !important;
    padding: 17px 0 !important;
  }
  .menu-list {
    padding-block: 4px;
  }
  .balance-grid {
    gap: 12px;
  }
  .balance-grid strong {
    font-size: clamp(20px, 6vw, 30px);
    overflow-wrap: anywhere;
  }
  .balance-grid span,
  .balance-grid small {
    font-size: 13px;
  }
  .account-actions {
    gap: 8px;
  }
  .account-actions > * {
    padding: 12px 8px;
    min-width: 0;
  }
  .page-bottom-space {
    height: calc(90px + env(safe-area-inset-bottom, 0px));
  }
  body:has(main[data-page="singer"]) .page-bottom-space {
    height: calc(155px + env(safe-area-inset-bottom, 0px));
  }
  :root[data-portal="admin"] .page-bottom-space {
    height: 20px;
  }
  :root[data-portal="admin"] #toast {
    bottom: 25px;
  }
  .hero:after {
    background: linear-gradient(90deg, var(--tint), transparent);
  }
  .profile-summary {
    gap: 12px;
  }
  .profile-summary h2 {
    font-size: 21px;
  }
  .profile-summary p {
    font-size: 13px;
  }
  .profile-summary > div {
    min-width: 0;
  }
}

/* Handoff A: keep native HTML/JS and original financial behavior. */
body {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    "Noto Sans TC",
    sans-serif;
}
header {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.panel,
.card {
  border-radius: 16px;
}
button,
a.btn,
input,
select,
textarea {
  border-radius: 10px;
}
.primary:hover,
a.btn.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}
button:focus-visible,
a:focus-visible,
input:focus,
select:focus,
textarea:focus {
  outline-color: var(--focus);
}
.brand {
  letter-spacing: 3px;
}
.brand small {
  font-size: 9px;
}
.hero {
  border: 1px solid var(--line);
  border-radius: 20px;
  min-height: 360px;
}
.hero:after {
  background: linear-gradient(90deg, var(--bg) 12%, transparent);
}
.hero img {
  opacity: 0.7;
}
.hero p {
  color: var(--muted);
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 3px;
}
.category-tabs {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  gap: 8px;
}
.category-tabs button {
  flex: 1;
  min-width: 0;
  padding-inline: 8px;
  font-size: 14px;
}
.gift-entry {
  border-color: var(--pink);
}
.gift-entry h2 {
  font-size: 26px;
}
.gift-entry .primary {
  width: 100%;
}
.gift-total {
  background: var(--tint);
  padding: 16px;
  border-radius: 12px;
  color: var(--pink);
  font-size: 20px;
  font-weight: 700;
}
.gift-drawer {
  position: fixed;
  inset: auto 0 0;
  margin: 0 auto;
  width: min(640px, 100%);
  height: 55dvh;
  max-height: 55dvh;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.gift-drawer::backdrop {
  background: #0009;
}
.drawer-handle {
  width: 38px;
  height: 4px;
  background: var(--line);
  margin: 0 auto 18px;
  border-radius: 8px;
}
.gift-drawer h2 {
  margin-bottom: 8px;
}
.gift-drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.gift-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  min-width: 0;
  min-height: 120px;
  background: var(--tint);
  border-radius: 14px;
}
.gift-choice strong {
  font-size: 14px;
}
.gift-choice > span:last-child {
  font-size: 13px;
  color: var(--pink);
}
.gift-icon {
  font-size: 30px;
}
.category-checks {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.category-checks label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
}
.category-checks input {
  width: 24px;
  height: 24px;
}
.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  min-height: 20px;
  border-radius: 20px;
  background: #c72840;
  color: #fff;
  padding: 0 6px;
  margin-left: 8px;
  font-size: 12px;
  line-height: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.admin-badge[hidden] {
  display: none;
}
.alert-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 20px;
}
.alert-strip button {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
}
.admin-nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
:root[data-portal="admin"] table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
:root[data-portal="admin"] th {
  background: var(--tint);
  font-weight: 600;
}
:root[data-portal="admin"] main {
  max-width: 1440px;
}
.stat strong,
.balance-grid strong,
table {
  font-variant-numeric: tabular-nums;
}
.entry-row {
  transition: background 160ms ease;
  color: var(--text);
}
.entry-row:hover {
  background: var(--tint);
}
.mobile-bottom-nav[hidden] {
  background: var(--header);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
@media (width<1024px) {
  main {
    padding-inline: 16px;
  }
  .category-tabs {
    flex-wrap: nowrap;
  }
  .category-tabs button {
    font-size: 13px;
    padding-inline: 4px;
    min-height: 46px;
  }
  .hero {
    min-height: 325px;
    padding: 26px 22px;
  }
  .hero h1 {
    font-size: 35px;
    line-height: 1.25;
    max-width: 285px;
  }
  .hero:after {
    background: linear-gradient(90deg, var(--bg), transparent);
  }
  .panel,
  .card {
    border-radius: 16px;
  }
  .card article {
    padding: 20px;
  }
  .gift-drawer {
    border-radius: 24px 24px 0 0;
  }
  .admin-nav button {
    display: none;
  }
  .mobile-admin-select[hidden] {
    display: grid;
  }
  :root[data-portal="admin"] .table-wrap td {
    padding: 10px 14px;
  }
  :root[data-portal="admin"] .table-wrap tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
  }
}
@media (prefers-reduced-motion: reduce) {
  .entry-row {
    transition: none;
  }
}
