* { box-sizing: border-box; }

body.credits-page {
  --ink: #18392f;
  --muted: #51665d;
  --line: #ced8ce;
  --forest: #21513e;
  margin: 0;
  color: var(--ink);
  background: #f7f8f3;
  font: 16px/1.55 system-ui, sans-serif;
}
.credits-page main { max-width: 1192px; margin: auto; padding: 26px clamp(16px, 4vw, 52px) 32px; }
.credits-page main a { color: var(--forest); text-underline-offset: 3px; }
.credits-breadcrumb ol, .credits-footer nav { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.credits-breadcrumb ol { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.credits-breadcrumb li + li::before { content: "/"; margin-right: 12px; color: #94a29a; }
.credits-intro { margin: 26px 0 30px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.credits-intro h1 { margin: 0; font-size: clamp(34px, 4.2vw, 54px); line-height: 1.15; letter-spacing: -.045em; }
.credits-intro p { margin: 13px 0 0; max-width: 66ch; color: var(--muted); font-size: 15px; }
.credits-intro a, .credit-help a { text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  grid-template-areas: "options checkout" "guide checkout";
  gap: 28px clamp(24px, 4vw, 52px);
  grid-template-rows: auto 1fr;
  align-items: start;
}
.credits-options { grid-area: options; }
.layout fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.credits-options legend, .layout h2 { margin: 0 0 15px; padding: 0; font-size: 20px; font-weight: 720; line-height: 1.4; }
.layout input { accent-color: var(--forest); }
.tier {
  display: flex; align-items: center; gap: 15px;
  min-height: 86px; margin-bottom: 10px; padding: 16px clamp(15px, 2vw, 24px);
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  color: var(--ink); cursor: pointer; transition: border-color .15s, background .15s;
}
.tier:hover { border-color: #799387; }
.tier:has(:checked) { border-color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); background: #e9f0e6; }
.tier input { width: 17px; height: 17px; flex-shrink: 0; }
.tier > span { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font: 13px ui-monospace, monospace; }
.tier b { color: var(--ink); font-size: clamp(26px, 3vw, 36px); font-weight: 600; letter-spacing: -.065em; }
.tier > .tier-price { display: grid; justify-items: end; gap: 2px; margin-left: auto; color: var(--ink); font: inherit; }
.tier-price strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.tier-price small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tier:has(:checked) .tier-price small { color: var(--forest); }
.credits-options aside, .credits-footer { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.credits-options aside { padding: 8px 2px 0; font-size: 14px; }
#credits-contact { padding: 4px 0; color: var(--forest); text-decoration: underline; text-underline-offset: 3px; }
#credits-contact-dialog { position: fixed; inset: 0; margin: auto; border: 0; width: min(92vw, 420px); max-height: 92dvh; overflow: auto; }

.confirmation {
  grid-area: checkout; min-width: 0; padding: clamp(19px, 2.6vw, 30px);
  border: 1px solid var(--line); border-radius: 18px; background: white;
  box-shadow: 0 8px 30px #203d3209;
}
.credits-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; padding: 16px; border-radius: 10px; background: #f2f5ef; }
.credits-total h3 { margin: 0; font-size: 20px; }
.total { display: grid; margin: 0; text-align: right; font-size: 12px; color: var(--muted); }
.total strong { font-size: 27px; font-weight: 700; line-height: 1.25; letter-spacing: -.04em; color: var(--ink); font-variant-numeric: tabular-nums; }
.confirmation textarea {
  width: 100%; margin-top: 6px; resize: vertical;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.confirmation .recharge-help-link { border-color: #b9cdbf; background: #eef4ec; color: var(--forest); }
.confirmation #account { margin: 8px 0 6px; padding-left: 2px; }
.confirmation #account[data-state="auto"] { color: var(--forest); font-weight: 600; }
.confirmation #account[data-state="error"] { color: #b42318; }
.credits-steps { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 16px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--ink); }
.credits-steps li { display: flex; align-items: center; gap: 8px; }
.credits-steps b {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--forest); color: white; font-size: 12px;
}
.confirmation p:not(.total) { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.ai-pay-methods legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 650; }
.ai-pay-methods label { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 12px; margin-right: 6px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.ai-pay-methods label:has(:checked) { border-color: var(--forest); background: #f2f5ef; }
#ai-checkout-status { margin: 12px 0 8px; }
.confirmation button:not(.recharge-help-link) { width: 100%; padding: 13px; border-radius: 10px; color: white; background: var(--forest); font: inherit; font-weight: 650; cursor: pointer; }
.confirmation button:disabled:not(.recharge-help-link) { background: #e6eadf; color: #617058; cursor: default; }
.credit-help { grid-area: guide; padding-top: 20px; border-top: 1px solid var(--line); }
.credit-help h2 { margin-bottom: 5px; }
.credit-help details { border-bottom: 1px solid var(--line); }
.credit-help summary { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; cursor: pointer; font-weight: 600; list-style: none; }
.credit-help summary::-webkit-details-marker { display: none; }
.credit-help summary::after { content: "+"; color: var(--muted); font: 20px ui-monospace, monospace; }
.credit-help details[open] summary::after { content: "−"; }
.credit-help p { margin: 0 0 12px; font-size: 14px; line-height: 1.75; color: var(--muted); }
.credits-footer { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.layout :focus-visible { outline: 2px solid var(--forest); outline-offset: 3px; }
dialog::backdrop { background: #13251db3; }
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "options" "checkout" "guide"; grid-template-rows: auto; gap: 23px; }
  .credits-page main { padding-top: 17px; }
  .credits-intro { margin: 18px 0 22px; padding-bottom: 18px; }
  .tier { min-height: 68px; gap: 10px; }
  /* iOS zooms into inputs smaller than 16px. */
  .confirmation textarea { font-size: 16px; }
  .ai-pay-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ai-pay-methods legend { grid-column: 1 / -1; }
  .ai-pay-methods label { justify-content: center; margin: 0; }
}

.credit-guide { margin: auto; }

.confirmation .credit-purchase-warning:not(.total) {
  margin: 16px 0 8px;
  padding: 10px 12px;
  border: 1px solid #fbb16c;
  border-radius: 8px;
  background: #fff7ed;
  color: #913b16;
  line-height: 1.6;
}
.credit-guide:not([open]), .credit-guide [hidden] { display: none; }
.credit-guide[open] { max-height: 94dvh; overflow: auto; }
.credit-guide .session-guide__carousel { flex: none; }
dialog.credits-pay { position: fixed; inset: 0; margin: auto; border: 0; color: #0f172a; overflow: auto; }
.credits-pay [hidden] { display: none !important; }
.credits-pay .recharge-pay-open-btn { display: grid; place-items: center; text-decoration: none; }
.credits-pay .credits-order-link { justify-self: center; font-size: 13px; color: #475569; text-decoration: underline; }
.credits-pay[data-stage="processing"] .recharge-pay-progress-fill { width: 50%; }
.credits-pay[data-stage="completed"] .recharge-pay-progress-fill { width: 100%; }
.credits-pay #ai-expiry-reminder:empty { display: none; }

@media (min-width: 761px) and (max-height: 980px) {
  .credits-page main {
    --section-gap: clamp(9px, calc(5vh - 27px), 20px);
    padding-top: calc(var(--section-gap) + 4px);
  }
  .credits-intro { margin: var(--section-gap) 0 calc(var(--section-gap) + 6px); padding-bottom: calc(var(--section-gap) + 4px); }
  .credits-intro h1 { font-size: clamp(36px, 5.2vh, 50px); }
  .credits-intro p { margin-top: 7px; max-width: none; }
  .confirmation { padding: calc(var(--section-gap) + 10px) clamp(20px, 2vw, 28px); }
  .confirmation h2 { margin-bottom: var(--section-gap); }
  .credits-total { margin-bottom: calc(var(--section-gap) + 4px); padding: var(--section-gap) 14px; }
  .total strong { font-size: 24px; }
  .confirmation .recharge-label { margin-bottom: 5px; }
  .confirmation #account { margin: 6px 0; }
  .confirmation .credit-purchase-warning:not(.total) { margin: var(--section-gap) 0; padding: 8px 12px; line-height: 1.55; }
  .ai-pay-methods legend { margin-bottom: 5px; }
  #ai-checkout-status { margin: var(--section-gap) 0 6px; }
  .confirmation #ai-pay-button { padding: 11px; }
  .confirmation textarea { display: block; min-height: 54px; height: clamp(54px, 9vh, 92px); margin-top: 0; }
  .credits-steps { margin-top: var(--section-gap); }
}
