:root {
  --night: #080e1b;
  --surface: #101a2b;
  --surface-raised: #152238;
  --line: #293750;
  --text: #f5f8ff;
  --muted: #93a1b8;
  --blue: #4d8dff;
  --blue-soft: #172d50;
  --green: #38d39f;
  --green-soft: #12372f;
  --amber: #f2b84b;
  --amber-soft: #3a2c16;
  --red: #ff746a;
  --red-soft: #3a2025;
  --font: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--night); color: var(--text); font: 14px var(--font); }
body { min-height: 100vh; margin: 0; letter-spacing: 0; }
button, input { border-radius: 6px; font: 600 14px var(--font); letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .46; }
[hidden] { display: none !important; }

.sms-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(760px, calc(100% - 32px));
  height: 68px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}
.sms-brand { display: flex; align-items: baseline; gap: 9px; color: var(--text); text-decoration: none; }
.sms-brand strong { font-size: 14px; }
.sms-brand small { color: var(--muted); font-size: 11px; font-weight: 700; }
.sms-secure { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.sms-top-actions { display: flex; align-items: center; gap: 18px; }
.sms-top-actions > a, .sms-footer a { color: var(--blue); font-size: 11px; font-weight: 700; text-decoration: none; }
.sms-secure i, .claim-listening i, .live-chip i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px #38d39f1c; }
.new-redeem { color: var(--blue); font-size: 12px; font-weight: 700; text-decoration: none; }
.claim-topbar { width: min(1080px, calc(100% - 32px)); }

.redeem-shell { display: grid; align-content: center; width: min(680px, calc(100% - 32px)); min-height: calc(100vh - 136px); margin: 0 auto; padding: 44px 0; }
.redeem-intro { margin-bottom: 26px; }
.sms-kicker { color: var(--green); font-size: 11px; font-weight: 800; }
.redeem-intro h1, .claim-intro h1 { margin: 8px 0 0; font-size: 30px; line-height: 1.25; }
.redeem-intro p, .claim-intro p { margin: 9px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.redeem-panel, .claim-panel, .replace-panel { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 16px 45px #0307114d; }
.redeem-panel { padding: 22px; }
.panel-heading span, .claim-panel-head > div > span, .replace-panel > div > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.panel-heading h2, .claim-panel-head h2, .replace-panel h2 { margin: 4px 0 0; font-size: 17px; }
.redeem-panel form { margin-top: 18px; }
.redeem-panel label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.redeem-control { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.redeem-control input { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); outline: none; background: #0b1322; color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.redeem-control input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #4d8dff24; }
.redeem-control input::placeholder { color: #65738a; }
.redeem-control button, .sms-button { min-height: 44px; padding: 0 20px; border: 1px solid var(--blue); background: var(--blue); color: #fff; font-weight: 800; }
.redeem-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 17px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.redeem-meta span { position: relative; }
.redeem-meta span + span::before { position: absolute; left: -10px; color: var(--line); content: "/"; }
.sms-footer { display: flex; justify-content: space-between; width: min(760px, calc(100% - 32px)); min-height: 68px; margin: 0 auto; padding: 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.claim-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "intro intro"
    "listening listening"
    "number code"
    "replace code"
    "failure failure"
    "footer footer";
  gap: 12px;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 56px;
}
.claim-intro { grid-area: intro; margin: 0 0 10px; }
.claim-listening { display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin-bottom: 12px; padding: 0 16px; border: 1px solid #256d59; border-radius: 6px; background: var(--green-soft); }
.claim-shell > .claim-listening { grid-area: listening; margin: 0; }
.claim-listening > span { display: flex; align-items: center; gap: 9px; }
.claim-listening strong { color: var(--green); font-size: 13px; }
.claim-listening small { color: #8fb9ab; font-size: 11px; }
.claim-listening.success { border-color: #2c8068; }
.claim-listening.timeout, .claim-listening.no_numbers { border-color: #7c6028; background: var(--amber-soft); }
.claim-listening.timeout i, .claim-listening.no_numbers i { background: var(--amber); box-shadow: 0 0 0 4px #f2b84b1c; }
.claim-listening.timeout strong, .claim-listening.no_numbers strong { color: var(--amber); }
.claim-listening.failed, .claim-listening.cancelled { border-color: #784047; background: var(--red-soft); }
.claim-listening.failed i, .claim-listening.cancelled i { background: var(--red); box-shadow: 0 0 0 4px #ff746a1c; }
.claim-listening.failed strong, .claim-listening.cancelled strong { color: var(--red); }
.claim-listening.ready { border-color: #385783; background: var(--blue-soft); }
.claim-listening.ready i { background: var(--blue); box-shadow: 0 0 0 4px #4d8dff1c; }
.claim-listening.ready strong { color: #82afff; }
.claim-listening.waiting i, .live-chip.waiting i { animation: listening-pulse 1.5s ease-out infinite; }

.claim-panel { margin-top: 12px; overflow: hidden; }
.claim-shell > .number-panel { grid-area: number; margin: 0; }
.claim-shell > .code-panel { grid-area: code; display: flex; flex-direction: column; margin: 0; }
.claim-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.country-chip, .live-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 27px; padding: 0 9px; border-radius: 999px; background: var(--blue-soft); color: #82afff; font-size: 11px; font-weight: 800; }
.live-chip { background: var(--green-soft); color: var(--green); }
.live-chip.success { background: var(--green-soft); color: var(--green); }
.live-chip.timeout, .live-chip.no_numbers { background: var(--amber-soft); color: var(--amber); }
.live-chip.failed, .live-chip.cancelled { background: var(--red-soft); color: var(--red); }
.live-chip.timeout i, .live-chip.no_numbers i { background: var(--amber); box-shadow: none; }
.live-chip.failed i, .live-chip.cancelled i { background: var(--red); box-shadow: none; }
.number-value { min-height: 78px; padding: 24px 20px 8px; overflow-wrap: anywhere; color: var(--text); font: 800 34px ui-monospace, SFMono-Regular, Menlo, monospace; }
.number-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 7px 20px 21px; color: var(--muted); font-size: 12px; }
.number-meta span + span { position: relative; }
.number-meta span + span::before { position: absolute; left: -11px; color: var(--line); content: "·"; }
.sms-button { display: inline-grid; place-items: center; min-height: 44px; border-radius: 6px; font-size: 13px; text-align: center; text-decoration: none; }
.sms-button.is-busy, .redeem-control button.is-busy { position: relative; color: transparent !important; pointer-events: none; opacity: .82; }
.sms-button.is-busy::after, .redeem-control button.is-busy::after { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text); content: attr(data-busy-label); animation: busy-pulse 1s ease-in-out infinite; }
.sms-button.primary.is-busy::after { color: #fff; }
.redeem-control button.is-busy::after { color: #fff; }
.sms-button.block { width: calc(100% - 40px); margin: 0 20px 20px; }
.sms-button.secondary { border-color: var(--line); background: var(--surface-raised); color: var(--text); }
.sms-button.success { border-color: #27745f; background: var(--green-soft); color: var(--green); }

.code-screen { display: grid; flex: 1; place-items: center; min-height: 230px; padding: 25px 20px; text-align: center; }
.code-screen strong { color: #b8c4d8; font: 800 38px ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-screen span { margin-top: 12px; color: var(--muted); font-size: 12px; }
.code-panel.success { border-color: #27745f; }
.code-panel.success .code-screen { background: #0d241f; }
.code-panel.success .code-screen strong { color: var(--green); }

.replace-panel { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; margin-top: 12px; padding: 19px 20px; }
.claim-shell > .replace-panel { grid-area: replace; grid-template-columns: 1fr; align-content: center; margin: 0; }
.claim-shell > .replace-panel .sms-button { width: 100%; }
.replace-panel p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.action-panel { gap: 14px; }
.action-buttons { display: grid; gap: 9px; }
.action-usage { padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sms-button.outline { border-color: var(--line); background: transparent; color: var(--text); }
.failure { margin: 12px 0 0; padding: 12px 14px; border: 1px solid #784047; border-radius: 6px; background: var(--red-soft); color: #ffaaa4; font-size: 12px; }
.claim-shell > .failure { grid-area: failure; margin: 0; }
.failure:empty { display: none; }
.claim-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.claim-shell > .claim-footer { grid-area: footer; margin-top: 6px; }

@keyframes listening-pulse {
  0% { box-shadow: 0 0 0 0 #38d39f66; }
  70%, 100% { box-shadow: 0 0 0 7px #38d39f00; }
}
@keyframes busy-pulse { 50% { opacity: .55; } }

#toast { position: fixed; top: 18px; left: 50%; z-index: 20; max-width: calc(100% - 32px); padding: 11px 15px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-raised); color: var(--text); font-size: 12px; opacity: 0; transform: translate(-50%, -10px); transition: .18s; pointer-events: none; }
#toast[data-tone="success"] { border-color: #27745f; color: var(--green); }
#toast[data-tone="danger"] { border-color: #784047; color: var(--red); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .claim-topbar { width: min(760px, calc(100% - 32px)); }
  .claim-shell { display: block; width: min(760px, calc(100% - 32px)); }
  .claim-intro { margin-bottom: 22px; }
  .claim-shell > .claim-listening { margin-bottom: 12px; }
  .claim-shell > .claim-panel { margin-top: 12px; }
  .claim-shell > .code-panel { display: block; }
  .claim-shell > .replace-panel { grid-template-columns: 1fr auto; margin-top: 12px; }
  .claim-shell > .replace-panel .sms-button { width: auto; }
  .claim-shell > .failure { margin-top: 12px; }
  .claim-shell > .claim-footer { margin-top: 18px; }
  .code-screen { min-height: 144px; }
}

@media (max-width: 600px) {
  .sms-topbar { width: calc(100% - 24px); height: 60px; }
  .sms-brand { gap: 7px; }
  .sms-secure { font-size: 11px; }
  .sms-top-actions { gap: 10px; }
  .redeem-shell { width: calc(100% - 24px); min-height: calc(100vh - 120px); padding: 30px 0; }
  .redeem-intro h1, .claim-intro h1 { font-size: 25px; }
  .redeem-panel { padding: 16px; }
  .redeem-control { grid-template-columns: 1fr; }
  .redeem-control button { width: 100%; }
  .redeem-meta span + span::before { display: none; }
  .sms-footer { flex-wrap: wrap; width: calc(100% - 24px); gap: 10px 18px; font-size: 10px; }
  .claim-shell { width: calc(100% - 24px); padding: 28px 0 40px; }
  .claim-listening { align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; padding: 10px 13px; }
  .claim-panel-head { padding: 16px; }
  .number-value { min-height: 68px; padding: 21px 16px 7px; font-size: 27px; }
  .number-meta { gap: 7px 15px; padding: 6px 16px 18px; }
  .number-meta span + span::before { left: -9px; }
  .sms-button.block { width: calc(100% - 32px); margin: 0 16px 16px; }
  .code-screen { min-height: 125px; padding: 22px 16px; }
  .code-screen strong { font-size: 31px; }
  .replace-panel { grid-template-columns: 1fr; padding: 17px 16px; }
  .claim-shell > .replace-panel { grid-template-columns: 1fr; }
  .replace-panel .sms-button { width: 100%; }
  .claim-shell > .replace-panel .sms-button { width: 100%; }
  .claim-footer { align-items: stretch; flex-direction: column-reverse; }
  .claim-footer > * { width: 100%; }
}
