:root {
  color-scheme: light;
  --brand-ink: #111827;
  --brand-night: #312e81;
  --brand-grape: #6d28d9;
  --brand-bubble: #0f766e;
  --brand-mint: #0f766e;
  --brand-sunny: #facc15;
  --brand-cream: #fff7ed;
  --brand-white: #ffffff;
  --brand-danger: #b91c1c;
  --brand-success: #166534;
  --text-primary: #111827;
  --text-inverse: #ffffff;
  --bg-page: #fff7ed;
  --focus-ring: #111827;
  --focus-offset: #facc15;
  --selection-bg: #312e81;
  --selection-text: #ffffff;
  --scrollbar-track: #fff7ed;
  --scrollbar-thumb: #312e81;
  --scrollbar-thumb-hover: #1e1b4b;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.875rem;
  --radius-lg: 1.25rem;
  --radius-xl: 1.75rem;
  --radius-pill: 9999px;
  --shadow-focus: 0 0 0 4px var(--focus-offset), 0 0 0 7px var(--focus-ring);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body,
button,
input,
textarea,
select {
  font: inherit;
}

html,
body,
#appShell {
  max-width: 100vw;
}

::-webkit-scrollbar {
  width: 0.875rem;
  height: 0.875rem;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border: 0.25rem solid var(--scrollbar-track);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
  text-shadow: none;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 4px;
  box-shadow: 0 0 0 6px var(--focus-offset);
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
a,
label,
li {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

a,
button,
input,
textarea,
select,
summary {
  max-width: 100%;
}

img,
video,
canvas,
iframe,
svg {
  max-width: 100%;
  height: auto;
}

iframe {
  border: 0;
}

table {
  max-width: 100%;
  border-collapse: collapse;
}

pre,
code,
kbd,
samp {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

/* === Components, Animations & UX Defenses === */

#appShell::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(250, 204, 21, .38), transparent 28%),
    radial-gradient(circle at 86% 12%, rgba(109, 40, 217, .22), transparent 30%),
    radial-gradient(circle at 20% 88%, rgba(15, 118, 110, .24), transparent 34%),
    linear-gradient(135deg, rgba(255,255,255,.55), transparent 45%);
  animation: ambient-drift 18s ease-in-out infinite alternate;
}

#appShell > *:not(#confettiLayer) {
  position: relative;
  z-index: 2;
}

#confettiLayer {
  z-index: 1;
  pointer-events: none !important;
}

#confettiLayer > * {
  animation: floaty 7s ease-in-out infinite;
}

#confettiLayer > *:nth-child(2) { animation-delay: -2s; }
#confettiLayer > *:nth-child(3) { animation-delay: -4s; }
#confettiLayer > *:nth-child(4) { animation-delay: -1s; }

#utilityStrip,
#heroCopyPanel,
#bitMascotPanel,
#converterSection,
#howItWorksSection,
.card,
.panel {
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}

#heroCopyPanel {
  background:
    radial-gradient(circle at 90% 8%, rgba(250, 204, 21, .95) 0 11%, transparent 12%),
    radial-gradient(circle at 8% 92%, rgba(49, 46, 129, .45), transparent 30%),
    linear-gradient(135deg, #1e1b4b, #4338ca 48%, #6d28d9);
}

#heroCopyPanel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.28) 2px, transparent 2.5px),
    linear-gradient(120deg, rgba(255,255,255,.18), transparent 36%);
  background-size: 28px 28px, 100% 100%;
  mix-blend-mode: screen;
}

#heroCopyPanel > *:not(.absolute) {
  position: relative;
  z-index: 1;
}

#bitMascotPanel {
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.75), transparent 24%),
    radial-gradient(circle at 85% 78%, rgba(109,40,217,.28), transparent 28%),
    linear-gradient(145deg, #facc15, #fde047);
}

#bitMascotPanel [class*="rounded-3xl"] {
  box-shadow: 0 .55rem 0 rgba(17,24,39,.18), inset 0 2px 0 rgba(255,255,255,.45);
  transform-origin: center;
  animation: bit-pop 3.8s ease-in-out infinite;
}

#bitMascotPanel [class*="rounded-3xl"]:nth-child(2n) { animation-delay: -.8s; }
#bitMascotPanel [class*="rounded-3xl"]:nth-child(3n) { animation-delay: -1.6s; }

#brandHomeLink,
#learnLink,
#themeToggleButton,
button,
[role="button"],
a,
label,
select,
summary,
input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  cursor: pointer;
}

button,
[role="button"],
a {
  touch-action: manipulation;
}

button:not(:disabled),
[role="button"]:not([aria-disabled="true"]),
a[href] {
  transition-property: transform, box-shadow, background-color, color, border-color, opacity, filter;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(.2,.8,.2,1);
}

button:not(:disabled):hover,
[role="button"]:not([aria-disabled="true"]):hover,
a[href]:hover {
  transform: translateY(-2px) scale(1.025);
  filter: saturate(1.08);
}

button:not(:disabled):active,
[role="button"]:not([aria-disabled="true"]):active,
a[href]:active {
  transform: translateY(1px) scale(.97);
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  filter: grayscale(.45);
}

input,
textarea {
  caret-color: #6d28d9;
}

textarea:focus,
input:focus,
select:focus {
  box-shadow: 0 0 0 4px rgba(250,204,21,.9), 0 0 0 8px rgba(49,46,129,.95), 0 18px 45px rgba(49,46,129,.18);
}

#binaryInput,
#decimalOutput,
.output,
.result {
  background-image:
    linear-gradient(90deg, rgba(49,46,129,.06) 1px, transparent 1px),
    linear-gradient(rgba(49,46,129,.06) 1px, transparent 1px);
  background-size: 18px 18px;
}

#decimalOutput,
.result,
[data-result] {
  text-shadow: 0 2px 0 rgba(250,204,21,.55);
}

#copyButton.copied,
.copied {
  animation: scale-bounce .55s cubic-bezier(.2,1.35,.4,1);
}

.loading,
[data-loading="true"] {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  overflow: hidden;
}

.loading::after,
[data-loading="true"]::after {
  content: "";
  position: absolute;
  inset: .35rem;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255,255,255,.18), rgba(255,255,255,.75), rgba(255,255,255,.18));
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.2s linear infinite;
}

.fade-in,
[data-animate="fade-in"] {
  animation: fade-in .45s ease both;
}

.slide-up,
[data-animate="slide-up"] {
  animation: slide-up .55s cubic-bezier(.2,.9,.25,1) both;
}

.scale-bounce,
[data-animate="scale-bounce"] {
  animation: scale-bounce .6s cubic-bezier(.2,1.35,.4,1) both;
}

[aria-live],
.toast,
#toast,
.notification {
  z-index: 9999 !important;
}

.toast,
#toast,
.notification,
[role="status"].floating {
  pointer-events: none;
}

.toast.is-active,
#toast.is-active,
.notification.is-active,
[role="status"].floating.is-active {
  pointer-events: auto;
}

.overlay,
.backdrop,
.modal-backdrop,
.dialog-backdrop,
[popover]:not(:popover-open) {
  pointer-events: none;
}

.overlay.is-active,
.backdrop.is-active,
.modal-backdrop.is-active,
.dialog-backdrop.is-active,
[popover]:popover-open {
  pointer-events: auto;
}

.overlay,
.backdrop,
.modal-backdrop,
.dialog-backdrop {
  z-index: 40;
}

.dialog,
.modal,
[role="dialog"],
[aria-modal="true"],
[popover]:popover-open {
  z-index: 45;
}

.floating,
.tooltip,
.dropdown,
.popover {
  z-index: 30;
}

header,
.sticky,
[aria-label*="navigation" i] {
  z-index: 20;
}

.dark #appShell::before {
  background:
    radial-gradient(circle at 12% 18%, rgba(250,204,21,.16), transparent 28%),
    radial-gradient(circle at 86% 12%, rgba(139,92,246,.28), transparent 30%),
    radial-gradient(circle at 20% 88%, rgba(20,184,166,.18), transparent 34%),
    linear-gradient(135deg, rgba(15,23,42,.65), transparent 45%);
}

.dark #heroCopyPanel {
  background:
    radial-gradient(circle at 90% 8%, rgba(250,204,21,.75) 0 11%, transparent 12%),
    radial-gradient(circle at 8% 92%, rgba(20,184,166,.3), transparent 30%),
    linear-gradient(135deg, #134e4a, #312e81 55%, #581c87);
  box-shadow: 0 1.2rem 0 rgba(255,255,255,.14), 0 2rem 4rem rgba(0,0,0,.38);
}

.dark #bitMascotPanel {
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.38), transparent 24%),
    radial-gradient(circle at 85% 78%, rgba(20,184,166,.25), transparent 28%),
    linear-gradient(145deg, #854d0e, #facc15);
}

.dark #utilityStrip,
.dark .card,
.dark .panel {
  background-image: linear-gradient(135deg, rgba(15,23,42,.88), rgba(30,41,59,.72));
  box-shadow: 0 1rem 0 rgba(255,255,255,.08), 0 1.5rem 4rem rgba(0,0,0,.42);
}

.dark #binaryInput,
.dark #decimalOutput,
.dark .output,
.dark .result {
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px);
}

.dark textarea:focus,
.dark input:focus,
.dark select:focus {
  box-shadow: 0 0 0 4px rgba(250,204,21,.95), 0 0 0 8px rgba(255,255,255,.9), 0 18px 45px rgba(0,0,0,.45);
}

@keyframes ambient-drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to { transform: translate3d(1.5%, 1%, 0) scale(1.04); }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  50% { transform: translateY(-18px) rotate(8deg) scale(1.06); }
}

@keyframes bit-pop {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-7px) scale(1.06); }
  60% { transform: translateY(2px) scale(.98); }
}

@keyframes skeleton-shimmer {
  from { background-position: 220% 0; }
  to { background-position: -220% 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scale-bounce {
  0% { transform: scale(.88); }
  55% { transform: scale(1.08); }
  78% { transform: scale(.97); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}