:root {
  color-scheme: light dark;
  --bg: #0b0c10;
  --fg: #e5e7eb;
  --card: #111827;
  --muted: #9ca3af;
  --pane-height: 260px;
}

/* Ensure padding/border don't break alignment with the card */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  margin: 0;
}

.wrap {
  max-width: 800px;
  margin: 40px auto;
  padding: 16px
}

.card {
  border-radius: 18px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
  padding: 20px
}

.grid {
  display: grid;
  gap: 16px
}

textarea {
  width: 100%;
  min-height: var(--pane-height);
  resize: vertical;
  font: inherit;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--muted, #ccc)
}

label {
  font-weight: 600
}

/* Align the size slider nicely within rows */
.row .muted { display: flex; align-items: center; gap: 8px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  width: 200px;
  border-radius: 999px;
  background: #e5e7eb;
  outline: none;
  vertical-align: middle;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #2563eb; border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #2563eb; border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
input[type="range"]::-moz-range-track { height: 6px; background: #e5e7eb; border-radius: 999px; }

/* Pretty selects (match buttons/inputs) */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font: inherit;
  color: inherit;
  background-color: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 36px 10px 12px;
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  transition: box-shadow .2s ease, border-color .2s ease, background-color .2s ease;
  background-image: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='UTF-8'?><svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,.35);
  border-color: #2563eb;
}

/* Keep label+select inline and tidy */
label > select { margin-left: 8px; }

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition: transform .06s ease, box-shadow .2s ease, opacity .2s ease
}

.btn:active {
  transform: translateY(1px) scale(.98)
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .35)
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none
}

.btn:disabled .ripple {
  display: none
}

/* Anchor-like buttons disabled via ARIA */
.btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  pointer-events: none
}

.btn.primary {
  background: #2563eb;
  color: white
}

.btn.ghost {
  background: transparent;
  border: 1px solid #cbd5e1
}

.btn .ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  transform: scale(0);
  background: currentColor;
  opacity: .25;
  animation: btn-ripple .55s ease-out
}

@keyframes btn-ripple {
  to {
    transform: scale(12);
    opacity: 0
  }
}

/* Tooltip for button feedback */
.tooltip {
  position: fixed;
  transform: translate(-50%, -8px);
  background: #111827;
  color: #fff;
  font-size: .75rem;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  animation: tooltip-fade .9s ease-out forwards;
  z-index: 9999
}

@keyframes tooltip-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, -4px)
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -8px)
  }

  80% {
    opacity: 1;
    transform: translate(-50%, -8px)
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -12px)
  }
}

.muted {
  color: #6b7280
}

.qrbox {
  width: 100%;
  display: grid;
  place-items: center;
  min-height: var(--pane-height);
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.02)
}

footer {
  margin-top: 16px;
  font-size: .9rem
}

@media (prefers-color-scheme: dark) {
  body {
    background: var(--bg);
    color: var(--fg)
  }

  .card {
    background: var(--card)
  }

  textarea {
    background: #0f172a;
    color: var(--fg);
    border-color: #334155
  }

  input[type="range"] { background: #334155; }
  input[type="range"]::-moz-range-track { background: #334155; }

  select {
    background-color: #0f172a;
    color: var(--fg);
    border-color: #334155;
    background-image: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='UTF-8'?><svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  }

  .btn.ghost {
    border-color: #334155;
    color: #e5e7eb
  }

  .qrbox {
    border-color: #334155;
    background: #0b1220
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none
  }

  .btn .ripple {
    animation: none
  }

  .tooltip {
    animation: none;
    opacity: 1
  }
}
