@layer components {
  /* The phone simulator: an iPhone. Before a call, the Phone keypad; during one, the USSD alert over the phone pad keyboard. */
  .phone { max-width: 32rem; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .device { position: relative; margin: 0 auto; max-width: 30rem; padding: 9px; border-radius: 44px; background: #1b2320; box-shadow: inset 0 0 0 1.5px #3a4641, inset 0 0 0 4px #141a18, 0 1px 2px rgb(var(--shade) / .1), 0 18px 40px rgb(var(--shade) / .16); }
  .device::before, .device::after { content: ""; position: absolute; width: 3px; border-radius: 2px; background: #2c3632; }
  .device::before { left: -3px; top: 96px; height: 52px; box-shadow: 0 64px 0 #2c3632; }
  .device::after { right: -3px; top: 132px; height: 72px; }
  .device-screen { position: relative; display: flex; flex-direction: column; height: clamp(50rem, 62vh, 60rem); overflow: hidden; border-radius: 36px; background: var(--phone-app-bg); color: var(--phone-ink); font-family: var(--phone-font); -webkit-font-smoothing: antialiased; }
  .device-status { position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 20px 0 26px; font-size: 13px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
  .device-island { position: absolute; left: 50%; top: 9px; width: 74px; height: 21px; margin-left: -37px; border-radius: 999px; background: #000; }
  .device-signal { display: flex; align-items: center; gap: 5px; }
  .device-signal .status-cellular { width: 17px; height: 17px; }
  .device-signal .status-battery { width: 25px; height: 25px; margin-right: -2px; }
  .device-body { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .device-home { position: absolute; left: 50%; bottom: 7px; z-index: 4; width: 108px; height: 4px; margin-left: -54px; border-radius: 999px; background: var(--phone-ink); }

  /* The Phone app keypad: round keys, letters under the digits, a green call key. */
  .dialer { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-height: 0; padding: 0 0 34px; }
  .dialer.is-behind { pointer-events: none; }
  .dialer.is-behind .phone-note { visibility: hidden; }
  .dialer-display { flex: 1; display: grid; align-content: center; justify-items: center; gap: 6px; min-height: 0; padding: 0 20px; text-align: center; }
  .dialer-number { min-height: 38px; max-width: 100%; overflow: hidden; font-size: 32px; font-weight: 400; letter-spacing: .02em; white-space: nowrap; text-overflow: ellipsis; }
  .phone-note { max-width: 24ch; margin: 0; font-size: 13px; line-height: 1.35; color: var(--phone-muted); }
  .phone-note.is-error { color: #ff3b30; }
  .dialer > .phone-note { margin: auto; }
  .dial-pad { display: grid; grid-template-columns: repeat(3, 62px); grid-auto-rows: 62px; justify-content: center; gap: 12px 20px; }
  .dial-key { display: grid; place-content: center; justify-items: center; border: 0; border-radius: 50%; background: var(--phone-dial-key); color: var(--phone-ink); font: inherit; line-height: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color .15s ease; }
  .dial-key:active { background: var(--phone-dial-key-press); transition: none; }
  .dial-key:disabled { cursor: default; }
  .dial-digit { font-size: 28px; font-weight: 400; font-variant-numeric: tabular-nums; }
  .dial-letters { margin-top: 1px; font-size: 8px; font-weight: 700; letter-spacing: .2em; padding-left: .2em; }
  .dial-key.is-symbol .dial-digit { font-size: 32px; font-weight: 300; }
  .dial-key[aria-label="*"] .dial-digit { transform: translateY(9px); font-size: 52px; font-weight: 300; }
  .call-key { display: grid; place-items: center; border: 0; border-radius: 50%; background: #34c759; color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .call-key .icon { width: 28px; height: 28px; }
  .call-key:active { filter: brightness(.9); }
  .call-key:disabled { cursor: default; }
  .dial-delete { display: grid; place-items: center; border: 0; background: transparent; color: var(--phone-dial-key-press); cursor: pointer; }
  .dial-delete .icon { width: 26px; height: 26px; color: var(--phone-muted); }
  .dial-delete[hidden] { display: grid !important; visibility: hidden; }

  /* During a session: iOS dims the app and shows the USSD message as an alert. */
  .ussd-stage { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 12px 12px 0; background: var(--phone-dim); }
  .device-screen:has(.keypad) .ussd-stage { bottom: var(--keyboard-height); }
  .ussd-dialog { position: relative; width: min(100%, 222px); overflow: hidden; border-radius: 13px; background: var(--phone-alert); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6); }
  .ussd-message { padding: 16px 14px 14px; text-align: center; }
  .phone-text { max-height: 15rem; margin: 0; overflow: auto; font-size: 13px; line-height: 1.33; color: var(--phone-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
  .ussd-detail { max-height: 8rem; margin: 8px 0 0; padding: 6px 8px; overflow: auto; border-radius: 6px; background: var(--error-soft); color: var(--error-ink); font-family: var(--mono); font-size: 10px; line-height: 1.4; text-align: left; white-space: pre-wrap; }
  .ussd-reply { margin-top: 12px; }
  .ussd-input { box-sizing: border-box; width: 100%; height: 26px; padding: 0 6px; border: .5px solid var(--phone-field-line); border-radius: 6px; background: var(--phone-field); color: var(--phone-ink); font: inherit; font-size: 13px; caret-color: var(--phone-link); }
  .ussd-input:focus { outline: none; }
  .ussd-input::placeholder { color: var(--phone-muted); }
  .ussd-buttons { display: grid; grid-template-columns: 1fr 1fr; border-top: .5px solid var(--phone-alert-line); }
  .ussd-buttons.is-single { grid-template-columns: 1fr; }
  .ussd-buttons > * + * { border-left: .5px solid var(--phone-alert-line); }
  .ussd-buttons .button_to { display: block; }
  .ussd-button { width: 100%; height: 42px; border: 0; background: transparent; color: var(--phone-link); font: inherit; font-size: 16px; font-weight: 400; cursor: pointer; }
  .ussd-button.is-primary { font-weight: 600; }
  .ussd-button:active { background: var(--phone-alert-press); }
  .ussd-progress { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; gap: 8px; margin: 0; background: var(--phone-veil); font-size: 13px; color: var(--phone-muted); }
  turbo-frame#simulator[busy] .ussd-progress { display: flex; }
  .ussd-spinner { width: 16px; height: 16px; border: 2px solid var(--phone-spinner-track); border-top-color: var(--phone-muted); border-radius: 50%; animation: ussd-spin .8s linear infinite; }
  @keyframes ussd-spin { to { transform: rotate(360deg); } }

  /* The phone pad keyboard: white keys on grey, +*# and delete without key caps. */
  .device-screen { --keyboard-height: 222px; }
  .keypad { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; height: var(--keyboard-height); padding: 6px 6px 30px; background: var(--phone-keypad); }
  .keypad-layer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, 1fr); gap: 6px; height: 100%; }
  .phone-key { display: grid; place-content: center; justify-items: center; border: 0; border-radius: 5px; background: var(--phone-key); color: var(--phone-key-ink); font: inherit; line-height: 1; cursor: pointer; box-shadow: 0 1px 0 var(--phone-key-shadow); -webkit-tap-highlight-color: transparent; }
  .key-digit { font-size: 22px; font-weight: 400; font-variant-numeric: tabular-nums; }
  .key-digit.is-small { font-size: 16px; letter-spacing: .04em; }
  .key-letters { min-height: 9px; font-size: 8px; font-weight: 600; letter-spacing: .18em; padding-left: .18em; }
  .phone-key.is-symbol .key-digit { font-size: 26px; }
  .phone-key:active { background: var(--phone-key-press); }
  .phone-key.is-function { background: transparent; box-shadow: none; }
  .phone-key.is-function:active { background: var(--phone-key); }
  .phone-key .icon { width: 24px; height: 24px; }
  .phone-key:focus-visible, .dial-key:focus-visible, .call-key:focus-visible, .ussd-button:focus-visible { outline: 2px solid var(--phone-link); outline-offset: 1px; }
  .keypad-gap { display: block; }

  .phone-status { display: flex; align-items: center; justify-content: center; gap: .8rem; margin: 1.2rem 0 0; font-size: 1.25rem; color: var(--ink-2); }
  .phone-state { display: inline-flex; align-items: center; gap: .5rem; }
  .phone-state::before { content: ""; width: .7rem; height: .7rem; border-radius: 50%; background: #2fb567; box-shadow: 0 0 0 3px rgba(47, 181, 103, .18); }
  .phone-state.is-ended::before { background: var(--ink-3); box-shadow: none; }
  .phone-status code { font-size: 1.15rem; }
  @media (prefers-reduced-motion: reduce) { .ussd-spinner { animation: none; } }

  .receipt { margin-top: 1.6rem; padding: 1.2rem 1.4rem 1.4rem; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
  .receipt-title { margin: 0 0 .6rem; font-size: 1.35rem; font-weight: 650; }
  .trace { position: relative; list-style: none; margin: 0; padding: 0; font-size: 1.3rem; }
  .trace li { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; padding: .5rem 0 .5rem 2rem; }
  .trace li::before { content: ""; position: absolute; left: .4rem; top: 1.25rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 1.5px var(--ink-3); }
  .trace li:not(:last-child)::after { content: ""; position: absolute; left: .75rem; top: 2rem; bottom: -.5rem; width: 1px; background: var(--line-strong); }
  .trace li:last-child::before { background: #2fb567; box-shadow: 0 0 0 1.5px #2fb567; }
  .trace-input { min-width: 3.2rem; padding: 0 .6rem; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r-control); background: var(--surface); font-family: var(--mono); font-size: 1.2rem; font-weight: 600; text-align: center; }
  .trace-screen { font-family: var(--mono); font-size: 1.2rem; }
  .trace-call { flex-basis: 100%; font-family: var(--mono); font-size: 1.1rem; color: var(--ink-3); overflow-wrap: anywhere; }
}
