/* Same click target and accessible name as the original action. */
:root {
  --cta-segment: #ef7e22;
  --cta-seam: #a45318;
  --cta-segment-hover: #fa8c34;
  --cta-segment-disabled: #e2cbb1;
  --cta-seam-disabled: #af9475;
  --cta-disabled: #ead9c4;
  --cta-disabled-ink: #68482c;
  --cta-segment-width: 43px;
  --cta-arrow: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%2012h15m-6-6%206%206-6%206%22%2F%3E%3C%2Fsvg%3E");
  --cta-back: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M20%2012H5m6-6-6%206%206%206%22%2F%3E%3C%2Fsvg%3E");
  --cta-plus: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%205v14M5%2012h14%22%2F%3E%3C%2Fsvg%3E");
  --cta-file: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M14%203H5v18h14V8zM14%203v5h5M8%2012h8M8%2016h5%22%2F%3E%3C%2Fsvg%3E");
  --cta-download: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%203v12m-5-5%205%205%205-5M4%2016v5h16v-5%22%2F%3E%3C%2Fsvg%3E");
  --cta-upload: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%2016V3m-5%205%205-5%205%205M4%2015v6h16v-6%22%2F%3E%3C%2Fsvg%3E");
  --cta-card: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%225%22%20width%3D%2218%22%20height%3D%2214%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M3%2010h18M6%2015h4%22%2F%3E%3C%2Fsvg%3E");
  --cta-key: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%228%22%20cy%3D%228%22%20r%3D%225%22%2F%3E%3Cpath%20d%3D%22m12%2012%209%209m-4-4%203-3m-7-1%203-3%22%2F%3E%3C%2Fsvg%3E");
  --cta-check: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m5%2012%204%204L19%206%22%2F%3E%3C%2Fsvg%3E");
  --cta-mail: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%225%22%20width%3D%2218%22%20height%3D%2214%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22m4%207%208%206%208-6%22%2F%3E%3C%2Fsvg%3E");
  --cta-external: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M13%205h6v6m0-6-9%209M19%2013v6H5V5h6%22%2F%3E%3C%2Fsvg%3E");
  --cta-wallet: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M20%207H5a2%202%200%200%201%200-4h14v4M3%205v14a2%202%200%200%200%202%202h15V7M16%2012h5v5h-5z%22%2F%3E%3C%2Fsvg%3E");
  --cta-search: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%2210%22%20r%3D%226%22%2F%3E%3Cpath%20d%3D%22m15%2015%206%206%22%2F%3E%3C%2Fsvg%3E");
  --cta-send: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m3%204%2018%208-18%208%204-8zm4%208h14%22%2F%3E%3C%2Fsvg%3E");
  --cta-chart: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%203v17h16M8%2016v-4m5%204V8m5%208V5%22%2F%3E%3C%2Fsvg%3E");
  --cta-refresh: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M20%207v5h-5M4%2017v-5h5M6%206a8%208%200%200%201%2014%206M4%2012a8%208%200%200%200%2014%206%22%2F%3E%3C%2Fsvg%3E");
  --cta-stop: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%226%22%20y%3D%226%22%20width%3D%2212%22%20height%3D%2212%22%20rx%3D%222%22%2F%3E%3C%2Fsvg%3E");
  --cta-publish: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M5%2014v6h14v-6M12%2015V3m-4%204%204-4%204%204%22%2F%3E%3C%2Fsvg%3E");
  --cta-save: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%204h13l3%203v13H4zM8%204v6h8V4M8%2020v-6h8v6%22%2F%3E%3C%2Fsvg%3E");
  --cta-play: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m8%205%2012%207-12%207z%22%2F%3E%3C%2Fsvg%3E");
  --cta-gift: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%2010h16v11H4zM3%207h18v3H3zM12%207v14m0-14C6%208%206%201%209%203c1%200%203%204%203%204Zm0%200c6%201%206-6%203-4-1%200-3%204-3%204Z%22%2F%3E%3C%2Fsvg%3E");
  --cta-home: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m3%2011%209-8%209%208M5%209v11h14V9m-9%2011v-6h4v6%22%2F%3E%3C%2Fsvg%3E");
  --cta-link: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m9%2015%206-6M8%2016l-2%202a4%204%200%200%201-6-6l6-6a4%204%200%200%201%206%200m2%200%202-2a4%204%200%200%201%206%206l-6%206a4%204%200%200%201-6%200%22%2F%3E%3C%2Fsvg%3E");
}

html[data-izi-theme="dark"] {
  --cta-segment: #f29542;
  --cta-seam: #b66b3a;
  --cta-segment-hover: #ffa95e;
  --cta-segment-disabled: #604531;
  --cta-seam-disabled: #86654a;
  --cta-disabled: #664b38;
  --cta-disabled-ink: #f7e5d3;
}

/* Controls that already carry an inline icon reuse it. These mappings supply
   the glyph for text-only actions, including buttons updated by controllers. */
:where([data-builder-price], [data-action="quote"], #annual-code-form button, [data-action="classroom-evaluate"]) { --cta-glyph: var(--cta-search); }
:where([data-cta-icon="file"]) { --cta-glyph: var(--cta-file); }
:where([data-action="retry-generation-with-files"]) { --cta-glyph: var(--cta-upload); }
:where([data-action^="download-"], [data-action^="classroom-download-"]) { --cta-glyph: var(--cta-download); }
:where(#login-session, #recover-passkey, #annual-code-login, [data-action="passkey-register"], [id*="passkey-register"], #wallet-reconnect) { --cta-glyph: var(--cta-key); }
:where(#register button[type="submit"], #recover button[type="submit"], [data-confirm-send], [data-action="request-package-recovery"]) { --cta-glyph: var(--cta-mail); }
:where(#confirm-email-code, #activate, #account-operation-confirmation [type="submit"], [data-action="classroom-mark-suggestion"]) { --cta-glyph: var(--cta-check); }
:where(#pay, #annual-pay, #new-topup, [data-action="create-checkout"]) { --cta-glyph: var(--cta-card); }
:where([data-action="open-payment"], [href*="paywall.paynow.pl"], [href*="paywall.sandbox.paynow.pl"]) { --cta-glyph: var(--cta-external); }
:where([data-action="focus-builder-funding"], [data-action="refresh-builder-wallet"]) { --cta-glyph: var(--cta-wallet); }
:where([data-action="confirm-package-recovery"], #annual-activate, [data-use-code]) { --cta-glyph: var(--cta-gift); }
:where([data-study-start]) { --cta-glyph: var(--cta-play); }
:where(.solve-submit, [data-cta-icon="send"], [data-action="submit-feedback"]) { --cta-glyph: var(--cta-send); }
:where([data-show-classroom-lookup], [data-action="refresh-result"], .identity-card button[type="submit"]) { --cta-glyph: var(--cta-chart); }
:where([data-action="classroom-close"]) { --cta-glyph: var(--cta-stop); }
:where([data-action="classroom-save-review"], [data-cta-icon="save"]) { --cta-glyph: var(--cta-save); }
:where([data-show-publication], [data-action="classroom-finalize-start"]) { --cta-glyph: var(--cta-publish); }
:where([data-action="classroom-finalize-cancel"], #wallet-builder-return) { --cta-glyph: var(--cta-back); }
:where([data-action="retry-generation"], [data-action="prepare-wallet-again"], [data-action="refresh-history"],
       [data-action="reload-public-link"], [data-action="retry-public-error"], [data-action="classroom-refresh"],
       #refresh-purchase, #annual-check-purchase, #annual-new-purchase, #retry-account-read, #wallet-retry) { --cta-glyph: var(--cta-refresh); }
:where([data-action="create-order"]:not([data-cta-icon]), [data-action="start"], .collection-create, a.btn[href="/#/builder"]) { --cta-glyph: var(--cta-plus); }
:where(.history-action-student) { --cta-glyph: var(--cta-link); }
:where(.history-action-student[data-cta-icon="chart"]) { --cta-glyph: var(--cta-chart); }
:where(.erasure-receipt-card .btn[href="/"]) { --cta-glyph: var(--cta-home); }

:root :is(#app.workspace, #account-page, #account-operation-confirmation, body.access-page,
          #app.workspace #account-page #wallet-content, #app.workspace #account-page #access-content)
.btn.primary:not(.danger, .account-erasure-submit) {
  position: relative;
  box-sizing: border-box;
  inline-size: fit-content;
  max-inline-size: 100%;
  justify-self: start;
  min-height: 50px;
  justify-content: center;
  padding-inline: 10.5px calc(var(--cta-segment-width) + 10.5px);
  border-radius: 9px;
  text-align: center;

  &::before, &::after {
    content: "";
    position: absolute;
    inset: 0 0 0 auto;
    inline-size: var(--cta-segment-width);
    pointer-events: none;
  }

  &::before {
    background: var(--cta-segment);
    border-inline-start: 1px solid var(--cta-seam);
    border-radius: 0 8px 8px 0;
    opacity: 1;
    transform: none;
  }

  &::after {
    background: currentColor;
    border: 0;
    border-radius: 0;
    mask: var(--cta-glyph, var(--cta-arrow)) center / 19px 19px no-repeat;
    opacity: 1;
    transform: none;
  }

  & > svg.ui-icon {
    position: absolute;
    inset-inline-end: calc((var(--cta-segment-width) - 19px) / 2);
    inset-block-start: 50%;
    inline-size: 19px;
    block-size: 19px;
    margin: 0;
    transform: translateY(-50%);
    pointer-events: none;
  }

  &:has(> svg.ui-icon):not([data-cta-icon], [aria-busy="true"])::after { content: none; }
  &:is([data-cta-icon], [aria-busy="true"]) > svg.ui-icon { visibility: hidden; }

  @media (min-width: 801px) {
    &.ready-link-action:not(:only-child) { inline-size: 100%; }
    &:is([data-builder-page="settings"], [data-builder-price], [data-action="quote"],
          [data-action="create-order"], [data-study-start],
          .account-setting-body :is(#register, #setup-email) .btn, #wallet-builder-return) {
      min-inline-size: calc(100% / 3);
      flex: 0 0 auto;
    }
    &.collection-create {
      min-inline-size: max(170px, calc(100% / 6));
      flex: 0 0 auto;
    }
    &:is(.history-entry__actions > .btn) {
      min-inline-size: 50%;
      flex: 0 0 auto;
    }
    &:is(.study-submit-dialog [data-confirm]) {
      inline-size: calc(200% / 3);
      margin-inline: auto;
    }
  }

  @media (max-width: 800px) {
    inline-size: 100%;
    min-inline-size: 0;
    flex-shrink: 0;
  }

  &:is(:disabled, [aria-disabled="true"]) {
    opacity: 1;
    background: var(--cta-disabled);
    border-color: var(--cta-seam-disabled);
    color: var(--cta-disabled-ink);
  }

  &:is(:disabled, [aria-disabled="true"])::before {
    background: var(--cta-segment-disabled);
    border-color: var(--cta-seam-disabled);
  }

  &[aria-busy="true"]::after {
    inset: calc(50% - 8px) calc((var(--cta-segment-width) - 16px) / 2) auto auto;
    inline-size: 16px;
    block-size: 16px;
    background: none;
    border: 2px solid var(--cta-seam-disabled);
    border-block-start-color: currentColor;
    border-radius: 50%;
    mask: none;
    animation: primary-action-spin .7s linear infinite;
  }

  @media (hover:hover) {
    &:hover:not(:disabled, [aria-disabled="true"])::before { background: var(--cta-segment-hover); }
  }

  @media (prefers-reduced-motion:reduce) {
    &[aria-busy="true"]::after { animation: none; }
  }
}

@keyframes primary-action-spin { to { rotate: 360deg; } }

@media (max-width: 800px) {
  #app.workspace .question-actions:has([data-study-next]) { flex-wrap: wrap; }
  #app.workspace .question-actions > [data-study-next].btn.primary { flex: 0 0 100%; max-width: 100%; }
}

/* The visible file action shares its hit area with the native file input. */
:root #app.workspace .builder-upload-drop.has-files { text-align: start; }
:root #app.workspace .builder-upload-drop.has-files::after { content: none; }
:root #app.workspace .builder-upload-drop.has-files .btn.drop-picker-cta.secondary {
  inline-size: auto;
  min-block-size: 44px;
  justify-content: flex-start;
  padding: 6px;
  color: var(--ui-blue);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
