/* Form labels and inputs */
label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin: 10px 0 8px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--field-radius);
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  background: #fff;
  font-family: inherit;
}

input:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--brand) 55%, white);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}

/* Output textarea */
.output {
  margin-top: 10px;
  height: 170px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}

/* Buttons */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.1s;
}

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

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, #cbd5e1);
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    #ffffff 0%,
    color-mix(in srgb, var(--ui-bg) 35%, #ffffff) 100%
  );
  box-shadow:
    0 1px 0 rgba(15,23,42,.04),
    0 10px 24px rgba(15,23,42,.06);
}

.toggle-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  color: var(--muted);
  padding: 6px 12px;
  min-width: 56px;
  text-align: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ui-bg) 55%, #ffffff);
  border: 1px solid color-mix(in srgb, var(--border) 70%, #cbd5e1);
  line-height: 1;
  user-select: none;
}

.switch {
  position: relative;
  width: 52px;
  height: 28px;
  flex: 0 0 auto;
}

.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 100%;
  margin: 0;
  outline: none;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, #cbd5e1);
  background: #e5e7eb;
  cursor: pointer;
  position: relative;
  transition:
    background .18s ease,
    border-color .18s ease,
    box-shadow .18s ease;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.04);
}

.switch input:hover {
  box-shadow:
    inset 0 0 0 1px rgba(15,23,42,.06),
    0 6px 16px rgba(15,23,42,.08);
}

.switch input:focus-visible {
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent),
    inset 0 0 0 1px rgba(15,23,42,.06);
}

.switch input:checked {
  background: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 85%, #0f172a);
}

.switch input::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  transform: translateY(-50%);
  transition:
    transform .18s ease,
    box-shadow .18s ease;
  box-shadow:
    0 8px 16px rgba(15,23,42,.18),
    inset 0 1px 0 rgba(255,255,255,.7);
}

.switch input:checked::after {
  transform: translate(24px, -50%);
}

.toggle-wrap:has(#demoToggle:checked) .toggle-label {
  color: color-mix(in srgb, var(--brand) 70%, #0f172a);
  background: color-mix(in srgb, var(--brand) 12%, #ffffff);
  border-color: color-mix(in srgb, var(--brand) 22%, var(--border));
}

/* Segmented control */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  flex-wrap: nowrap;
}

.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  transition: background .12s ease, color .12s ease;
  white-space: nowrap;
  flex: 0 0 auto;
  font-family: inherit;
}

.segmented button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brand) 18%, white);
  color: #0f172a;
}

.segmented button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}

/* Mobile adjustments for components */
@media (max-width: 640px) {
  .btn {
    padding: 12px 16px;
    width: 100%;
  }

  .actions {
    flex-direction: column;
    gap: 8px;
  }

  .segmented {
    width: 100%;
    justify-content: space-between;
  }

  .segmented button {
    flex: 1 1 auto;
    padding: 10px 8px;
    font-size: 12px;
  }
}
