/* 托管页：角色与兑换记录共用卡片层次，颜色跟随站点主题。 */
body[data-page="giftcode"] {
  background: color-mix(in srgb, var(--bg) 94%, var(--brand) 6%);
}

.gift-page {
  max-width: 1180px;
  padding-top: 24px;
  gap: 20px;
  --gift-line: color-mix(in srgb, var(--brand) 20%, var(--surface));
  --gift-danger: #fca5a5;
  --gift-success: #6ee7b7;
  --gift-warning: #fcd34d;
}

:root[data-theme="light"] .gift-page {
  --gift-danger: #b42332;
  --gift-success: #187344;
  --gift-warning: #895000;
}

.gift-page .gift-page-heading { position: relative; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--gift-line); }
.gift-page-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-width: 0; }
.gift-page .account-page__heading h1 { font-size: clamp(23px, 3vw, 28px); letter-spacing: -.03em; }
.gift-page-title > .muted { font-size: 13px; }
.gift-help { flex: 0 0 auto; }
.gift-help > summary { display: flex; align-items: center; min-height: 44px; color: var(--text-secondary); font-size: 13px; cursor: pointer; list-style: none; gap: 8px; }
.gift-help > summary::-webkit-details-marker,
.gift-code-module > summary::-webkit-details-marker { display: none; }
.gift-help > summary::after { content: "⌄"; color: var(--brand); }
.gift-help[open] > summary::after { content: "⌃"; }
.gift-help-content { position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: min(440px, 100%); padding: 20px; border: 1px solid var(--gift-line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg); color: var(--text-secondary); font-size: 13px; line-height: 1.8; }
.gift-help-content ul { margin: 10px 0 0; padding-left: 18px; }
.gift-help-content li + li { margin-top: 6px; }
.gift-page .account-service-band { padding: 0; margin-bottom: 0; border: 0; background: transparent; }
.gift-page #giftAccessNotice { margin: 0; padding: 18px; border: 1px solid var(--gift-line); border-radius: 12px; background: var(--surface); }
.gift-page .gift-workspace { grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 0; }
.gift-page .gift-module,
.gift-page .gift-redemptions { padding: 0; border: 0; background: transparent; }
.gift-page .gift-module h2,
.gift-page .gift-redemptions h2 { margin: 0; font-size: 17px; }
.gift-page .account-card__title { margin-bottom: 12px; }
.gift-section-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.gift-page .status { color: var(--text-soft); font-size: 13px; }
.gift-page .status::before { display: none; }
.gift-page .muted { font-style: normal; }
.gift-page .button { min-height: 44px; }
.gift-page :is(button, summary, select, input):focus-visible,
.gift-page #giftRecordsTitle:focus { outline: 2px solid var(--brand); outline-offset: 4px; }
.gift-page #giftRecordsTitle { scroll-margin-top: 110px; }

.gift-add-role { margin: 0 0 12px; border: 1px dashed var(--gift-line); border-radius: 12px; background: var(--surface); }
.gift-add-role > summary { color: var(--brand); padding: 10px 16px; min-height: 44px; cursor: pointer; font-size: 13px; font-weight: 600; }
.gift-add-role .gift-role-form { margin: 0; padding: 4px 18px 18px; }
.gift-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.gift-role-card,
.gift-redemption-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--gift-line);
  border-radius: 14px;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--brand) 3%, transparent);
  overflow: hidden;
}
.gift-role-card__body { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 12px; padding: 16px; }
.gift-role-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--brand-soft), var(--surface-secondary));
  border: 1px solid var(--gift-line);
  color: var(--brand);
  font-size: 23px;
  font-weight: 600;
}
.gift-role-identity { min-width: 0; }
.gift-role-name { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 4px; }
.gift-role-identity h4 { font-size: 16px; line-height: 1.5; margin: 0; overflow-wrap: anywhere; }
.gift-role-meta { display: flex; flex-wrap: wrap; gap: 3px 12px; color: var(--text-soft); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.gift-role-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.gift-archive-toggle { margin: 0; }
.gift-role-notice { margin: 0 16px 14px; padding: 10px 12px; border-radius: 8px; background: var(--surface-secondary); font-size: 13px; color: var(--text-secondary); overflow-wrap: anywhere; }
.gift-role-notice p { margin: 0 0 4px; line-height: 1.6; }
.gift-role-notice small { color: var(--text-soft); }
.gift-recover-confirm { white-space: normal; align-items: flex-start; line-height: 1.6; }
.gift-recover-confirm input { flex: 0 0 auto; margin-top: 4px; }
.gift-recover-confirm span { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.gift-role-actions .button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text-secondary); box-shadow: none; font-size: 13px; white-space: nowrap; }
.gift-role-actions .button:hover { background: var(--surface-secondary); transform: none; }
.gift-role-actions .gift-role-recover { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.gift-role-actions .gift-role-delete { color: var(--gift-danger); border: 1px solid color-mix(in srgb, var(--gift-danger) 22%, var(--surface)); background: var(--danger-soft); }
.gift-role-actions .gift-role-delete:hover { background: color-mix(in srgb, var(--gift-danger) 15%, var(--surface)); }
.gift-page .gift-role-records {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-top: 1px solid var(--gift-line);
  border-radius: 0;
  background: color-mix(in srgb, var(--surface) 96%, var(--brand) 4%);
  color: var(--brand);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}
.gift-page .gift-role-records:hover { background: var(--brand-soft); transform: none; color: var(--brand-hover); }
.gift-page .gift-code-module { padding: 10px 16px; background: var(--surface); border: 1px solid var(--gift-line); border-radius: 12px; }
.gift-code-module > summary { min-height: 44px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.gift-code-module > summary::after { content: "展开"; color: var(--brand); font-size: 13px; }
.gift-code-module[open] > summary::after { content: "收起"; }
.gift-page .gift-code-module > summary { margin: 0; }
.gift-code-module > summary h2 { flex: 1; }
.gift-code-hint { margin-top: 12px; }
.gift-page .gift-redemptions { margin-top: 24px; }
.gift-page #giftQueueStatus { padding: 10px 14px; margin: 12px 0; border-radius: 10px; background: var(--brand-soft); color: var(--text-secondary); line-height: 1.7; }
.gift-record-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0; font-size: 13px; }
.gift-record-toolbar label { color: var(--text-secondary); }
.gift-record-toolbar select { width: min(210px, 100%); min-width: 0; min-height: 44px; border-radius: 8px; }
.gift-record-toolbar #giftStatusFilter { width: 160px; }
.gift-record-toolbar .muted { margin-left: auto; font-size: 12px; }
.gift-redemption-card { padding: 16px; display: flex; flex-direction: column; }
.gift-redemption-card__heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.gift-redemption-card__heading > div { min-width: 0; }
.gift-card-label { font-size: 11px; color: var(--text-soft); }
.gift-redemption-card h4 { font-size: 16px; margin: 2px 0 0; line-height: 1.5; overflow-wrap: anywhere; font-family: var(--font-mono); }
.gift-redemption-card .pill { flex-shrink: 0; }
.gift-record-identity { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 10px 0 12px; font-size: 12px; color: var(--text-soft); overflow-wrap: anywhere; }
.gift-record-identity strong { font-weight: 500; color: var(--text-secondary); }
.gift-result-message { padding: 10px 12px; border-radius: 8px; background: var(--surface-secondary); margin-bottom: 12px; }
.gift-result-message > span { font-size: 11px; font-weight: 600; }
.gift-result-message p { font-size: 13px; line-height: 1.7; margin: 3px 0 0; overflow-wrap: anywhere; }
.gift-redemption-card--failed .gift-result-message { background: var(--danger-soft); color: var(--gift-danger); }
.gift-estimate { color: var(--brand); background: var(--brand-soft); padding: 10px 12px; font-size: 13px; line-height: 1.7; border-radius: 8px; margin: 0 0 12px; overflow-wrap: anywhere; }
.gift-redemption-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; }
.gift-redemption-card__footer > span { color: var(--text-soft); font-size: 11px; line-height: 1.8; }
.gift-redemption-card__footer time { font-size: 12px; color: var(--text-secondary); }
.gift-redemption-card__footer .button { border-radius: 10px; }
.gift-page .pill { color: var(--gift-success); background: var(--success-soft); border-color: transparent; font-size: 11px; }
.gift-page .pill.danger { color: var(--gift-danger); background: var(--danger-soft); }
.gift-page .pill.warning { color: var(--gift-warning); background: var(--warning-soft); }
.gift-page #giftAccessPill { color: var(--brand); background: var(--brand-soft); }
.gift-page #giftAccessPill.disabled { color: var(--gift-warning); background: var(--warning-soft); }
.gift-page .empty-state { padding: 28px 20px; border: 1px dashed var(--gift-line); border-radius: 16px; background: var(--surface); }
.gift-page .gift-record-hint { margin-top: 12px; line-height: 1.7; font-size: 12px; color: var(--text-soft); }

/* 宽屏记录按行排列，让结果、状态和重试入口可以一起扫读。 */
@media (min-width: 961px) {
  #giftRedemptionRows { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .gift-redemption-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(160px, .65fr); gap: 6px 20px; }
  .gift-redemption-card__heading { grid-column: 1; grid-row: 1; }
  .gift-record-identity { grid-column: 1; grid-row: 2; margin: 0; }
  .gift-result-message { grid-column: 2; grid-row: 1; margin: 0; }
  .gift-estimate { grid-column: 2; grid-row: 2; margin: 0; }
  .gift-redemption-card__footer { grid-column: 3; grid-row: 1 / span 2; margin: 0; padding: 0 0 0 16px; border-top: 0; border-left: 1px solid var(--line); flex-wrap: wrap; }
}

@media (max-width: 960px) {
  .gift-card-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .gift-page { padding: 16px 14px 40px; gap: 16px; }
  .gift-page .gift-page-heading { padding-bottom: 12px; align-items: flex-start; }
  .gift-page-title { gap: 4px 8px; }
  .gift-page-title > .muted { display: none; }
  .gift-page .gift-section-heading { align-items: center; flex-wrap: wrap; gap: 4px 10px; }
  .gift-section-title { gap: 4px 8px; }
  .gift-page #giftRoleStatus { font-size: 12px; }
  .gift-card-grid { gap: 12px; }
  .gift-role-actions .button { padding-inline: 10px; font-size: 12px; }
  .gift-page .gift-code-module { padding: 8px 14px; }
  .gift-code-module > summary { gap: 6px 10px; }
  .gift-page #giftCodeStatus { font-size: 12px; }
  .gift-redemption-card { padding: 14px; }
  .gift-record-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .gift-record-toolbar select,
  .gift-record-toolbar #giftStatusFilter { width: 100%; }
  .gift-record-toolbar .muted { grid-column: 1 / -1; }
  .gift-record-toolbar .muted { width: 100%; margin: 0; }
  .gift-add-role .gift-role-form { flex-direction: column; align-items: stretch; }
  .gift-add-role .gift-role-form .field { flex: auto; }
  .gift-page .gift-code-form { flex-direction: column; align-items: stretch; }
  .gift-page .gift-code-form .field { flex: auto; min-width: 0; }
  .gift-page .gift-code-form input { min-width: 0; }
  .gift-page .account-login-gate { padding: 28px 18px; }
}

@media (max-width: 360px) {
  .gift-role-actions { gap: 6px; }
  .gift-role-actions .button { padding-inline: 8px; }
  .gift-redemption-card__heading { gap: 8px; }
}
