/* Polaris unified custom controls — supersedes native OS chrome for form widgets */
:root{
  --ctrl-radius:5px;
  --ctrl-field-radius:5px;
  --ctrl-check-size:16px;
  --ctrl-surface:#25252b40;
  --ctrl-border:var(--line,#ffffff28);
  --ctrl-ink:var(--ink,#fff);
  --ctrl-muted:var(--muted,#b0b0b8);
  --ctrl-fill:#fff;
  --ctrl-fill-ink:#121214;
  --ctrl-hover:#ffffff18;
  --ctrl-focus:color-mix(in srgb,var(--ctrl-ink) 55%,transparent);
  --ctrl-ring:color-mix(in srgb,var(--ctrl-ink) 12%,transparent);
  --ctrl-min-h:42px;
  --ctrl-track:#ffffff22;
  --ctrl-thumb:#fff;
}
html[data-theme=light],
[data-theme=light],
html[data-auth-theme=light]{
  --ctrl-surface:color-mix(in srgb,var(--ink,#191c24) 4%,transparent);
  --ctrl-fill:#202532;
  --ctrl-fill-ink:#fff;
  --ctrl-hover:color-mix(in srgb,var(--ink,#191c24) 7%,transparent);
  --ctrl-track:color-mix(in srgb,var(--ink,#191c24) 14%,transparent);
  --ctrl-thumb:#202532;
}
.entry-shell{
  --ctrl-surface:var(--entry-field,#191b22);
  --ctrl-border:var(--entry-line,#ffffff20);
  --ctrl-ink:var(--entry-ink,#f0f3f9);
  --ctrl-muted:var(--entry-muted,#949aa8);
  --ctrl-fill:var(--entry-button,#e4edff);
  --ctrl-fill-ink:var(--entry-button-ink,#171d2b);
  --ctrl-focus:var(--entry-blue,#8bb4ff);
  --ctrl-ring:color-mix(in srgb,var(--entry-blue,#8bb4ff) 14%,transparent);
  --ctrl-hover:color-mix(in srgb,var(--entry-ink,#f0f3f9) 5%,transparent);
  --ctrl-thumb:var(--entry-button,#e4edff);
  --ctrl-track:color-mix(in srgb,var(--entry-ink,#f0f3f9) 12%,transparent);
  --ctrl-min-h:42px;
}

/* —— Shared field tokens (text / password / email / number / search / url / tel / textarea / select) —— */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=hidden]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]),
textarea,
select{
  appearance:none;
  -webkit-appearance:none;
  background:var(--ctrl-surface);
  color:var(--ctrl-ink);
  border:1px solid var(--ctrl-border);
  border-radius:var(--ctrl-field-radius);
  min-height:var(--ctrl-min-h);
  padding:10px 12px;
  font:inherit;
  line-height:1.4;
  box-shadow:none;
  transition:border-color .15s,box-shadow .15s,background .15s;
}
textarea{min-height:96px;resize:vertical}
select{
  padding-right:34px;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23b0b0b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat:no-repeat;
  background-position:right 12px center;
  background-size:12px 8px;
  cursor:pointer;
}
html[data-theme=light] select,
[data-theme=light] select,
html[data-auth-theme=light] select,
.entry-shell select{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23636875' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=hidden]):not([type=button]):not([type=submit]):not([type=reset]):focus-visible,
textarea:focus-visible,
select:focus-visible{
  outline:none;
  border-color:var(--ctrl-focus);
  box-shadow:0 0 0 3px var(--ctrl-ring);
}
input::placeholder,textarea::placeholder{color:var(--ctrl-muted);opacity:.72}

/* Tighter marketing toolbar / docs sidebar fields */
.client-toolbar input,
.docs-sidebar input{
  min-height:32px;
  padding:7px 10px;
  font-size:10px;
  border-radius:var(--ctrl-field-radius);
}

/* —— Custom checkbox —— */
input[type=checkbox]{
  appearance:none;
  -webkit-appearance:none;
  width:var(--ctrl-check-size);
  height:var(--ctrl-check-size);
  margin:0;
  flex:none;
  border:1px solid var(--ctrl-border);
  border-radius:5px;
  background:var(--ctrl-surface);
  vertical-align:middle;
  cursor:pointer;
  transition:background .15s,border-color .15s,box-shadow .15s;
  accent-color:unset;
}
input[type=checkbox]:hover{border-color:color-mix(in srgb,var(--ctrl-ink) 40%,var(--ctrl-border))}
input[type=checkbox]:checked{
  background-color:var(--ctrl-fill);
  border-color:var(--ctrl-fill);
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='%23121214' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.2l3 3.1 6-6.4'/></svg>");
  background-size:12px 12px;
  background-position:center;
  background-repeat:no-repeat;
}
html[data-theme=light] input[type=checkbox]:checked,
[data-theme=light] input[type=checkbox]:checked,
html[data-auth-theme=light] input[type=checkbox]:checked{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.2l3 3.1 6-6.4'/></svg>");
}
input[type=checkbox]:focus-visible{
  outline:2px solid var(--ctrl-focus);
  outline-offset:2px;
}
input[type=checkbox]:disabled{opacity:.45;cursor:default}

/* —— Custom radio —— */
input[type=radio]{
  appearance:none;
  -webkit-appearance:none;
  width:var(--ctrl-check-size);
  height:var(--ctrl-check-size);
  margin:0;
  flex:none;
  border:1px solid var(--ctrl-border);
  border-radius:50%;
  background:var(--ctrl-surface);
  vertical-align:middle;
  cursor:pointer;
  transition:background .15s,border-color .15s,box-shadow .15s;
  accent-color:unset;
}
input[type=radio]:hover{border-color:color-mix(in srgb,var(--ctrl-ink) 40%,var(--ctrl-border))}
input[type=radio]:checked{
  border-color:var(--ctrl-fill);
  background:
    radial-gradient(circle at center,var(--ctrl-fill-ink) 0 3.5px,transparent 4px),
    var(--ctrl-fill);
}
input[type=radio]:focus-visible{
  outline:2px solid var(--ctrl-focus);
  outline-offset:2px;
}
input[type=radio]:disabled{opacity:.45;cursor:default}

/* —— Labels for check / radio —— */
.check-label,
.ctrl-option,
label.ctrl-option{
  display:inline-flex;
  align-items:center;
  gap:8px;
  cursor:pointer;
  font-size:13px;
  color:var(--ctrl-muted);
  user-select:none;
  line-height:1.4;
}
.check-label{font-size:11px}
.entry-main .check-label{font-size:10px;color:var(--entry-muted,var(--ctrl-muted))}
.ctrl-option-stack{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin:0 0 14px 24px;
  font-size:13px;
}
.ctrl-option-stack[hidden]{display:none!important}

/* —— Range (WebKit + Moz) —— */
input[type=range]{
  appearance:none;
  -webkit-appearance:none;
  width:100%;
  height:16px;
  background:transparent;
  cursor:pointer;
  accent-color:unset;
}
input[type=range]::-webkit-slider-runnable-track{
  height:3px;
  border-radius:999px;
  background:var(--ctrl-track);
  border:0;
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width:14px;
  height:14px;
  margin-top:-5.5px;
  border-radius:50%;
  background:var(--ctrl-thumb);
  border:1px solid var(--ctrl-border);
  box-shadow:0 1px 4px #0004;
}
input[type=range]::-moz-range-track{
  height:3px;
  border-radius:999px;
  background:var(--ctrl-track);
  border:0;
}
input[type=range]::-moz-range-thumb{
  width:14px;
  height:14px;
  border-radius:50%;
  background:var(--ctrl-thumb);
  border:1px solid var(--ctrl-border);
  box-shadow:0 1px 4px #0004;
}
input[type=range]:focus-visible{outline:none}
input[type=range]:focus-visible::-webkit-slider-thumb{
  outline:2px solid var(--ctrl-focus);
  outline-offset:2px;
}
input[type=range]:focus-visible::-moz-range-thumb{
  outline:2px solid var(--ctrl-focus);
  outline-offset:2px;
}
.range-line input[type=range]{width:130px;max-width:65%}

/* —— Buttons family —— */
.button,
a.button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  border:1px solid var(--ctrl-border);
  border-radius:var(--ctrl-radius);
  background:var(--ctrl-surface);
  color:var(--ctrl-ink);
  min-height:var(--ctrl-min-h);
  padding:10px 18px;
  font:inherit;
  font-size:12px;
  font-weight:500;
  line-height:1.4;
  text-decoration:none;
  cursor:pointer;
  transition:background .15s,transform .15s,border-color .15s,opacity .15s;
}
.button:hover,a.button:hover{background:var(--ctrl-hover);text-decoration:none}
.button.primary,a.button.primary,.primary.button{
  background:var(--ctrl-fill);
  color:var(--ctrl-fill-ink);
  border-color:var(--ctrl-fill);
}
.button.primary:hover,a.button.primary:hover{filter:brightness(.94);opacity:1}
.button.secondary,a.button.secondary{background:var(--ctrl-surface)}
.button.danger,a.button.danger{
  background:#e6b3bc12;
  color:var(--danger,#e6b3bc);
  border-color:#e6b3bc38;
}
.button.subtle,a.button.subtle,.subtle.button{
  background:var(--ctrl-surface);
  color:var(--ctrl-ink);
  border-color:var(--ctrl-border);
}
.button:focus-visible,a.button:focus-visible{
  outline:2px solid var(--ctrl-focus);
  outline-offset:2px;
}
.button:disabled,a.button[aria-disabled=true]{opacity:.55;cursor:default;transform:none}

/* Marketing hero buttons already use .button / .primary — keep radius family, don't force tall min-height on nav chip */
.nav-download{
  border-radius:var(--ctrl-radius);
  border:1px solid var(--ctrl-border);
}
.actions .button,.actions .primary,.actions .subtle{border-radius:var(--ctrl-radius)}

/* Toolbar / segmented / utility buttons */
.site-theme-toggle{
  border-radius:var(--ctrl-radius);
  border:1px solid var(--ctrl-border);
  background:transparent;
  min-height:30px;
  padding:5px 10px;
  color:inherit;
  cursor:pointer;
  transition:background .15s;
}
.site-theme-toggle:hover{background:var(--ctrl-hover)}
.site-theme-toggle:focus-visible{outline:2px solid var(--ctrl-focus);outline-offset:2px}

.auth-tools{
  border:1px solid var(--ctrl-border);
  border-radius:var(--ctrl-radius);
  overflow:hidden;
  background:transparent;
}
.auth-tools button{
  background:transparent;
  color:var(--ctrl-muted);
  border:0;
  border-right:1px solid var(--ctrl-border);
  border-radius:0;
  padding:5px 9px;
  font-size:10px;
  min-height:26px;
  cursor:pointer;
}
.auth-tools button:last-child{border-right:0}
.auth-tools button[aria-pressed=true]{
  color:var(--ctrl-ink);
  background:var(--ctrl-hover);
}
.auth-tools button:focus-visible{outline:2px solid var(--ctrl-focus);outline-offset:-2px}

.subnav button{
  border:1px solid var(--ctrl-border);
  border-radius:var(--ctrl-radius);
  background:var(--ctrl-surface);
  padding:10px 18px;
  font-size:12px;
  color:var(--ctrl-ink);
  cursor:pointer;
  min-height:36px;
}
.subnav button[aria-pressed=true]{
  background:var(--ctrl-fill);
  color:var(--ctrl-fill-ink);
  border-color:var(--ctrl-fill);
}
.subnav button:focus-visible{outline:2px solid var(--ctrl-focus);outline-offset:2px}

.text-button{
  border:0;
  background:none;
  padding:8px 0;
  color:var(--ctrl-ink);
  font:inherit;
  font-size:13px;
  min-height:36px;
  display:inline-flex;
  align-items:center;
  cursor:pointer;
  border-radius:var(--ctrl-radius);
}
.text-button:hover{text-decoration:underline;text-underline-offset:5px}
.text-button:focus-visible{outline:2px solid var(--ctrl-focus);outline-offset:2px}

.password-eye{
  border-radius:var(--ctrl-radius);
  border:0;
  background:transparent;
  color:var(--ctrl-muted);
  cursor:pointer;
}
.password-eye:hover{color:var(--ctrl-ink);background:var(--ctrl-hover)}
.password-eye:focus-visible{outline:2px solid var(--ctrl-focus);outline-offset:1px}

.code-toolbar button,
.site-opening button,
.demo-play{
  border-radius:var(--ctrl-radius);
  border:1px solid var(--ctrl-border);
  background:var(--ctrl-surface);
  color:inherit;
  cursor:pointer;
}
.code-toolbar button:hover,
.demo-play:hover{background:var(--ctrl-hover)}

/* Download stealth options — shared classes */
#stealth-modes.ctrl-option-stack{margin:0 0 14px 24px}

/* module-toggle / preview-menu / lottery cards keep their own custom chrome */

@media(prefers-reduced-motion:reduce){
  .button,.button:hover,a.button{transition:none;transform:none}
}
