:root {
  --reward-navy: oklch(0.27 0.075 258);
  --reward-navy-deep: oklch(0.205 0.055 258);
  --reward-action: oklch(0.31 0.1 258);
  --reward-action-hover: oklch(0.235 0.075 258);
  --reward-gold: oklch(0.71 0.13 78);
  --reward-gold-strong: oklch(0.58 0.135 72);
  --reward-gold-soft: oklch(0.955 0.042 86);
  --reward-ivory: oklch(0.985 0.012 88);
  --reward-positive: oklch(0.52 0.115 151);
  --reward-danger: oklch(0.53 0.17 28);
}

html[data-theme="dark"] {
  --reward-navy: oklch(0.76 0.065 252);
  --reward-navy-deep: oklch(0.17 0.035 258);
  --reward-action: oklch(0.46 0.115 258);
  --reward-action-hover: oklch(0.4 0.105 258);
  --reward-gold: oklch(0.78 0.12 82);
  --reward-gold-strong: oklch(0.83 0.115 84);
  --reward-gold-soft: oklch(0.28 0.045 78);
  --reward-ivory: oklch(0.235 0.022 79);
  --reward-positive: oklch(0.74 0.1 151);
  --reward-danger: oklch(0.74 0.14 28);
}

.honor-score {
  padding: 0;
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
}

.honor-score:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -8px;
}

.reward-score-flyout {
  position: fixed;
  inset: auto;
  margin: 0;
  z-index: 60;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 18px;
  border: 1px solid color-mix(in oklch, var(--reward-gold) 64%, var(--line));
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 5px 8px oklch(0.15 0.03 258 / 0.22);
  color: var(--ink);
}

.reward-score-flyout[hidden] {
  display: none;
}

.reward-score-flyout__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.reward-score-flyout__header h2 {
  margin: 0;
  color: var(--reward-navy);
  font-size: 1.05rem;
  letter-spacing: -0.015em;
  line-height: 1.25;
  text-wrap: balance;
}

.reward-score-flyout__header span {
  color: var(--reward-gold-strong);
  font-size: 0.78rem;
  font-weight: 750;
}

.reward-score-flyout__totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 4px 0 14px;
}

.reward-score-flyout__total {
  min-width: 0;
  padding: 11px 8px 9px 0;
  border-bottom: 1px solid var(--line);
}

.reward-score-flyout__total:nth-child(even) {
  padding-right: 0;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.reward-score-flyout__total:first-child {
  grid-column: 1 / -1;
  padding-block: 13px;
  padding-left: 0;
  border-left: 0;
}

.reward-score-flyout__total dt {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.reward-score-flyout__total dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  line-height: 1.2;
}

.reward-score-flyout__total:first-child dd {
  color: var(--reward-navy);
  font-size: 1.55rem;
}

.reward-score-flyout__exchange {
  width: 100%;
  min-height: 44px;
  padding-inline: 18px;
  border-color: var(--reward-action);
  background: var(--reward-action);
  color: oklch(0.98 0.008 88);
}

.reward-score-flyout__exchange:not(:disabled):hover {
  border-color: var(--reward-action-hover);
  background: var(--reward-action-hover);
}

dialog.reward-board,
dialog.reward-confirm,
dialog.reward-coupon {
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

dialog.reward-board::backdrop,
dialog.reward-confirm::backdrop,
dialog.reward-coupon::backdrop {
  background: oklch(0.12 0.035 258 / 0.72);
  backdrop-filter: blur(2px);
}

.reward-board__surface {
  width: min(1120px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 8px oklch(0.12 0.03 258 / 0.28);
}

.reward-board__header {
  min-height: 76px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 20px 15px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.reward-board__heading {
  min-width: 0;
}

.reward-board__heading h2 {
  margin: 0;
  color: var(--reward-navy);
  font-size: 1.42rem;
  letter-spacing: -0.025em;
  line-height: 1.2;
  text-wrap: balance;
}

.reward-board__heading p {
  max-width: 66ch;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  text-wrap: pretty;
}

.reward-board__close {
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  padding: 0;
  border-color: transparent;
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.reward-board__switcher {
  display: none;
}

.reward-board__switch {
  min-height: 44px;
  flex: 1 1 0;
  padding-inline: 14px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.reward-board__switch[aria-selected="true"] {
  border-color: var(--reward-action);
  background: var(--reward-action);
  color: oklch(0.98 0.008 88);
}

.reward-board__body {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
  overflow: hidden;
  overscroll-behavior: contain;
}

.reward-catalog {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 24px 24px;
  scrollbar-gutter: stable;
}

.reward-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.reward-section-heading h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.reward-section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.reward-gift-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

[data-gift-code] {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

[data-gift-code] h3 {
  margin: 0;
  color: var(--reward-navy);
  font-size: 0.98rem;
  line-height: 1.3;
  text-wrap: balance;
}

[data-gift-code] p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  text-wrap: pretty;
}

[data-gift-code] p:first-of-type {
  color: var(--reward-gold-strong);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

[data-gift-code][data-shortage] {
  background: color-mix(in oklch, var(--surface) 88%, var(--reward-gold-soft));
}

[data-gift-code][data-shortage] p:nth-last-of-type(1) {
  color: var(--reward-danger);
  font-weight: 700;
}

[data-redeem-gift] {
  min-height: 42px;
  margin-top: auto;
  padding: 9px 12px;
  border-color: color-mix(in oklch, var(--reward-navy) 62%, var(--line));
  color: var(--reward-navy);
}

[data-redeem-gift]:not(:disabled):hover {
  border-color: var(--reward-action);
  background: var(--reward-action);
  color: oklch(0.98 0.008 88);
}

[data-redeem-gift]:disabled,
[data-shortage] [data-redeem-gift] {
  border-color: var(--line);
  background: var(--surface-subtle);
  color: var(--muted);
}

.reward-gift-box-panel {
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 22px 20px 20px;
  background: var(--reward-navy-deep);
  color: oklch(0.97 0.01 88);
}

.reward-gift-box-panel .reward-section-heading {
  margin-bottom: 13px;
}

.reward-gift-box-panel .reward-section-heading h3 {
  color: oklch(0.98 0.01 88);
}

.reward-gift-box-panel .reward-section-heading p {
  color: oklch(0.81 0.025 250);
}

.reward-gift-box {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  padding: 1px 3px 1px 1px;
  scrollbar-gutter: stable;
}

.reward-gift-box:empty::before {
  content: "还没有礼物券";
  display: block;
  padding: 24px 16px 4px;
  color: oklch(0.96 0.015 88);
  font-weight: 760;
  text-align: center;
}

.reward-gift-box:empty::after {
  content: "完成学习并兑换礼物后，礼物券会按最新时间出现在这里。";
  display: block;
  max-width: 28ch;
  margin: 0 auto;
  padding: 0 12px 24px;
  color: oklch(0.78 0.025 250);
  font-size: 0.83rem;
  line-height: 1.55;
  text-align: center;
  text-wrap: pretty;
}

[data-coupon-id] {
  width: 100%;
  min-height: 58px;
  padding: 11px 12px;
  border: 1px solid oklch(0.62 0.055 258);
  border-radius: 10px;
  background: oklch(0.31 0.062 258);
  color: oklch(0.98 0.01 88);
  line-height: 1.35;
  text-align: left;
}

[data-coupon-id]:not(:disabled):hover {
  border-color: var(--reward-gold);
  background: oklch(0.355 0.068 258);
}

[data-coupon-id][aria-label*="已使用"] {
  opacity: 0.58;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.reward-load-more {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border-color: oklch(0.65 0.055 258);
  background: transparent;
  color: oklch(0.94 0.02 88);
}

.reward-load-more:not(:disabled):hover {
  border-color: var(--reward-gold);
  background: oklch(0.34 0.06 258);
}

.reward-board__status {
  min-height: 42px;
  flex: 0 0 auto;
  margin: 0;
  padding: 11px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.reward-board__status:empty::before {
  content: "选择一份礼物开始兑换。";
}

.reward-confirm__surface {
  width: min(460px, calc(100vw - 32px));
  padding: 24px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 8px 8px oklch(0.12 0.03 258 / 0.28);
}

.reward-confirm__surface h2 {
  margin: 0;
  color: var(--reward-navy);
  font-size: 1.24rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
  text-wrap: balance;
}

.reward-confirm__surface p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
  text-wrap: pretty;
}

.reward-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.reward-dialog-actions button {
  min-height: 44px;
  padding-inline: 18px;
}

.reward-dialog-actions__primary {
  border-color: var(--reward-action);
  background: var(--reward-action);
  color: oklch(0.98 0.008 88);
}

.reward-dialog-actions__primary:not(:disabled):hover {
  border-color: var(--reward-action-hover);
  background: var(--reward-action-hover);
}

.reward-coupon__surface {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 20px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 8px oklch(0.12 0.03 258 / 0.28);
}

.reward-coupon__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.reward-coupon__header h2 {
  margin: 0;
  color: var(--reward-navy);
  font-size: 1.24rem;
  letter-spacing: -0.02em;
}

.reward-coupon-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1866 / 843;
  overflow: hidden;
  isolation: isolate;
}

.reward-coupon-stage__base {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.reward-coupon-stage__overlay {
  position: absolute;
  z-index: 1;
  inset: 13% 18% 12% 22%;
  color: var(--reward-navy-deep);
  pointer-events: none;
}

.reward-coupon-ticket {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  text-align: center;
}

.reward-coupon-ticket__brand,
.reward-coupon-ticket__gift,
.reward-coupon-ticket__description,
.reward-coupon-ticket__details {
  margin: 0;
}

.reward-coupon-ticket__brand {
  color: oklch(0.43 0.105 78);
  font-size: clamp(0.38rem, 1.35vw, 1rem);
  font-weight: 850;
  letter-spacing: 0.12em;
}

.reward-coupon-ticket__gift {
  margin-top: 1.2%;
  color: var(--reward-navy-deep);
  font-size: clamp(0.7rem, 2.9vw, 2.15rem);
  line-height: 1.08;
  text-wrap: balance;
}

.reward-coupon-ticket__description {
  max-width: 46ch;
  margin-top: 1.1%;
  color: oklch(0.36 0.04 78);
  font-size: clamp(0.36rem, 1.25vw, 0.88rem);
  line-height: 1.35;
  text-wrap: pretty;
}

.reward-coupon-ticket__details {
  width: min(94%, 650px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4% 8%;
  margin-top: 2.4%;
}

.reward-coupon-ticket__detail {
  min-width: 0;
}

.reward-coupon-ticket__label {
  color: oklch(0.43 0.08 78);
  font-size: clamp(0.3rem, 0.92vw, 0.67rem);
  font-weight: 780;
  letter-spacing: 0.06em;
}

.reward-coupon-ticket__value {
  overflow-wrap: anywhere;
  margin: 0.1em 0 0;
  color: var(--reward-navy-deep);
  font-size: clamp(0.38rem, 1.28vw, 0.94rem);
  font-weight: 760;
  line-height: 1.2;
}

.reward-coupon-ticket__use-area {
  margin-top: 2.5%;
  padding: 0.42em 1.7em;
  border: 2px solid var(--reward-gold);
  color: oklch(0.42 0.11 73);
  font-size: clamp(0.36rem, 1.15vw, 0.82rem);
  font-weight: 850;
  letter-spacing: 0.08em;
}

.reward-coupon-ticket__stamp {
  position: absolute;
  right: 3%;
  bottom: 4%;
  padding: 0.08em 0.25em;
  border: 3px solid oklch(0.49 0.19 28);
  color: oklch(0.49 0.19 28);
  font-size: clamp(0.75rem, 3.8vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  transform: rotate(-10deg);
}

.reward-coupon-ticket__unverified {
  margin: 1.5% 0 0;
  color: oklch(0.46 0.16 35);
  font-size: clamp(0.34rem, 1vw, 0.72rem);
  font-weight: 850;
  letter-spacing: 0.05em;
}

.reward-coupon__actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.reward-coupon__actions button {
  min-width: 126px;
  min-height: 44px;
  padding-inline: 18px;
}

.reward-coupon__actions #reward-coupon-use {
  border-color: var(--reward-action);
  background: var(--reward-action);
  color: oklch(0.98 0.008 88);
}

.reward-coupon__actions button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.reward-coupon__status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
}

dialog[open] > .reward-board__surface,
dialog[open] > .reward-confirm__surface,
dialog[open] > .reward-coupon__surface {
  animation: reward-dialog-enter 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes reward-dialog-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) and (min-width: 761px) {
  .reward-gift-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .reward-score-flyout {
    padding: 16px;
  }

  dialog.reward-board {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
  }

  .reward-board__surface {
    width: 100vw;
    max-width: 100vw;
    max-height: calc(100dvh - max(8px, env(safe-area-inset-top)));
    border-radius: 16px 16px 0 0;
  }

  .reward-board__header {
    min-height: 68px;
    padding: 12px 12px 12px 16px;
  }

  .reward-board__heading p {
    display: none;
  }

  .reward-board__switcher {
    position: sticky;
    z-index: 1;
    top: 0;
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }

  .reward-board__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .reward-board[data-mobile-panel="catalog"] .reward-gift-box-panel,
  .reward-board[data-mobile-panel="box"] .reward-catalog {
    display: none;
  }

  .reward-catalog {
    padding: 18px 14px 20px;
  }

  .reward-gift-list {
    grid-template-columns: minmax(0, 1fr);
  }

  [data-gift-code] {
    padding: 14px;
  }

  [data-redeem-gift],
  [data-coupon-id],
  .reward-load-more,
  .reward-board__close,
  .reward-dialog-actions button,
  .reward-coupon__actions button {
    min-height: 44px;
  }

  .reward-gift-box-panel {
    padding: 20px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .reward-board__status {
    padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  }

  .reward-confirm__surface,
  .reward-coupon__surface {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    padding: 16px;
  }

  .reward-coupon__actions button {
    min-width: min(132px, 100%);
    flex: 1 1 120px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .honor-score {
    min-height: 44px;
  }

  .reward-score-flyout__exchange,
  [data-redeem-gift],
  [data-coupon-id],
  .reward-load-more,
  .reward-dialog-actions button,
  .reward-coupon__actions button {
    min-height: 44px;
  }
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .reward-score-flyout,
  html:not([data-theme]) .reward-board__surface,
  html:not([data-theme]) .reward-confirm__surface,
  html:not([data-theme]) .reward-coupon__surface {
    color-scheme: dark;
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog[open] > .reward-board__surface,
  dialog[open] > .reward-confirm__surface,
  dialog[open] > .reward-coupon__surface {
    animation: none;
  }
}
